dashboard

package
v0.0.0-...-3214176 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(ctx context.Context, w http.ResponseWriter, error string, code int)

Types

type Action

type Action string
const (
	ActionRefresh   Action = "refresh"
	ActionNextPage  Action = "next_page"
	ActionLastPage  Action = "last_page"
	ActionPrevPage  Action = "prev_page"
	ActionFirstPage Action = "first_page"
)

type Base

type Base struct {
	Vars      map[string]any
	Body      []byte
	PageIndex int
	Pages     []Page
	Config    DashboardConfig
}

type CalendarConfig

type CalendarConfig struct {
	Name           string   `toml:"name"`
	IDs            []string `toml:"ids"`
	Days           int      `toml:"days"`
	MaxEvents      int      `toml:"max_events"`
	SkipPastEvents bool     `toml:"skip_past_events"`
}

type CalendarDay

type CalendarDay struct {
	Time    time.Time
	IsPast  bool
	IsToday bool
	Events  []homeassistant.CalendarEvent
}

type Config

type Config struct {
	Dev           bool                 `toml:"dev"`
	ListenAddr    string               `toml:"listen_addr"`
	ListenPort    int                  `toml:"listen_port"`
	DashboardDir  string               `toml:"dashboard_dir"`
	Log           LogConfig            `toml:"log"`
	HomeAssistant *HomeAssistantConfig `toml:"home_assistant"`
}

func LoadConfig

func LoadConfig(cfgPath string) (Config, error)

func (Config) String

func (c Config) String() string

type DashboardConfig

type DashboardConfig struct {
	Height        int                          `toml:"height"`
	Width         int                          `toml:"width"`
	Base          string                       `toml:"base"`
	Pages         []string                     `toml:"pages"`
	HomeAssistant DashboardHomeAssistantConfig `toml:"home_assistant"`
}

type DashboardHomeAssistantConfig

type DashboardHomeAssistantConfig struct {
	Entities  []EntityConfig   `toml:"entities"`
	Calendars []CalendarConfig `toml:"calendars"`
	Services  []ServiceConfig  `toml:"services"`
}

type EntityConfig

type EntityConfig struct {
	Name string `toml:"name"`
	ID   string `toml:"id"`
}

type HomeAssistantConfig

type HomeAssistantConfig struct {
	Host   string `toml:"host"`
	Port   int    `toml:"port"`
	Secure bool   `toml:"secure"`
	Token  string `toml:"token"`
}

func (HomeAssistantConfig) String

func (c HomeAssistantConfig) String() string

func (HomeAssistantConfig) URL

func (c HomeAssistantConfig) URL() string

type HomeAssistantRenderData

type HomeAssistantRenderData struct {
	Entities  map[string]homeassistant.EntityState
	Calendars map[string][]CalendarDay
	Services  map[string]homeassistant.Response
}

type LogConfig

type LogConfig struct {
	Level     slog.Level `toml:"level"`
	Format    LogFormat  `toml:"format"`
	AddSource bool       `toml:"add_source"`
	NoColor   bool       `toml:"no_color"`
}

func (LogConfig) String

func (c LogConfig) String() string

type LogFormat

type LogFormat string
const (
	LogFormatJSON   LogFormat = "json"
	LogFormatText   LogFormat = "text"
	LogFormatLogFMT LogFormat = "log-fmt"
)

type Page

type Page struct {
	Name  string
	Index int
	Vars  map[string]any
	Body  []byte
}

type PageRenderData

type PageRenderData struct {
	Index int
	Vars  map[string]any
}

type RenderData

type RenderData struct {
	PageIndex     int
	PageCount     int
	Pages         []PageRenderData
	Vars          map[string]any
	HomeAssistant HomeAssistantRenderData
}

func (RenderData) Page

func (r RenderData) Page() PageRenderData

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config, version string, goVersion string, templates fs.FS) *Server

func (*Server) Routes

func (s *Server) Routes() http.Handler

func (*Server) Start

func (s *Server) Start()

type ServiceConfig

type ServiceConfig struct {
	Name           string         `toml:"name"`
	Domain         string         `toml:"domain"`
	Service        string         `toml:"service"`
	ReturnResponse bool           `toml:"return_response"`
	Data           map[string]any `toml:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL