config

package
v0.0.0-...-a662f2c Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TimeLayout used for time configuration
	TimeLayout = "15:04:05"
)

Variables

This section is empty.

Functions

func MapstructureDecodeHookFunc

func MapstructureDecodeHookFunc() mapstructure.DecodeHookFunc

MapstructureDecodeHookFunc returns a mapstructure decode hook func to handle Gotomation configuration objects

func NewMapstructureDecoder

func NewMapstructureDecoder(result interface{}) *mapstructure.Decoder

NewMapstructureDecoder returns a new mapstructure.Decoder ready to read Gotomation configuration

Types

type FileWatcher

type FileWatcher interface {
	routines.Runnable
	SetFilename(filename string)
	AddOnReloadCallbacks(funcs ...func(data interface{}, err error))
}

FileWatcher is a watcher for file changes, it loads it using viper (mapstructure)

func NewFileWatcher

func NewFileWatcher(filename string, getTypeFunc func() interface{}) FileWatcher

NewFileWatcher returns a FileWatcher

type Gotomation

type Gotomation struct {
	// LogLevel is the log level configured
	LogLevel string `mapstructure:"log_level"`
	// Google is used to authenticate to Google's API
	Google struct {
		CredentialsFile string `mapstructure:"creds_file"`
	} `mapstructure:"google"`

	// HomeAssistant server related options
	HomeAssistant HomeAssistantConfig `mapstructure:"home_assistant"`

	// Senders configures all sender configuration
	Senders []SenderConfig `mapstructure:"senders"`

	// Modules configuration
	Modules []map[string]interface{} `mapstructure:"modules"`

	// Triggers configuration
	Triggers []map[string]interface{} `mapstructure:"triggers"`

	// Crons configuration
	Crons []interface{} `mapstructure:"crons"`
}

Gotomation is the struct to unmarshal configuration It is using mapstructure for a compatibility with Viper config files

func (Gotomation) ReadConfigFromFile

func (g Gotomation) ReadConfigFromFile(vi *viper.Viper, loadConfig func(config Gotomation) error) error

ReadConfigFromFile loads or reloads config from viper's config file

func (Gotomation) Validate

func (g Gotomation) Validate() bool

Validate indicates whether or not the config is valid for gotomation to run

type HomeAssistantConfig

type HomeAssistantConfig struct {
	Host                string             `mapstructure:"host"`
	Token               string             `mapstructure:"token"`
	SubscribeEvents     []string           `mapstructure:"subscribe_events"`
	HomeZoneName        string             `mapstructure:"home_zone_name"`
	TLSEnabled          bool               `mapstructure:"tls_enabled"`
	HealthCheckEntities []model.HassEntity `mapstructure:"health_check_entities"`
}

type SenderConfig

type SenderConfig struct {
	// Name of this config
	Name string `mapstructure:"name" json:"name"`
	// Telegram configures a telegram sender
	Telegram *messaging.TelegramSender `mapstructure:"telegram" json:"telegram"`
	// StatusLed configures a status LED
	StatusLed *messaging.StatusLedSender `mapstructure:"statusLed" json:"statusLed"`
}

func (*SenderConfig) GetSender

func (s *SenderConfig) GetSender() (messaging.Sender, error)

GetSender gets the Sender interface depending on what field is set

Jump to

Keyboard shortcuts

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