Documentation ¶
Index ¶
- Constants
- func InitCoordinates(zoneName string) error
- func StringInSliceP(str string, patterns []string) bool
- type Action
- func (a *Action) Disable()
- func (a *Action) Enable()
- func (a *Action) GetEntitiesForTrigger() []model.HassEntity
- func (a *Action) GetEventTypesForTrigger() []string
- func (a *Action) GetName() string
- func (a *Action) GinHandler(c *gin.Context)
- func (a *Action) IsDisabled() bool
- func (a *Action) IsEnabled() bool
- func (a *Action) NeedsInitialization() bool
- func (a *Action) Trigger(e *model.HassEvent)
- type Actionable
- type Automate
- type Checkable
- type Checker
- type Configurable
- type Coordinates
- type CronEntry
- type Crontab
- type HeaterSchedule
- type HeaterSchedules
- type Modular
- type Module
- type RandomLightsRoutine
- type SchedulesDays
- type Trigger
- type Triggerable
Constants ¶
const ( Sunday = 1 << iota Monday Tuesday Wednesday Thursday Friday Saturday Week WeekEnd )
const ( // DefaultInterval is used when interval is not set (or set to zero) DefaultInterval = time.Minute * 10 )
Variables ¶
This section is empty.
Functions ¶
func InitCoordinates ¶
InitCoordinates gets the latitude and longitude of a Home Assistant zone entity
func StringInSliceP ¶
StringInSliceP checks whether a string is present in the given slice (using regexp patterns)
Types ¶
type Action ¶
type Action struct { // Entities triggers events only from specific lights. No filter -> all events arrive // Use either trigger_entities OR trigger_events Entities []model.HassEntity `mapstructure:"trigger_entities"` // EventTypes triggers events only from specific event type // Use either trigger_entities OR trigger_events EventTypes []string `mapstructure:"trigger_events"` // contains filtered or unexported fields }
Action is triggered on state change
func (*Action) GetEntitiesForTrigger ¶
func (a *Action) GetEntitiesForTrigger() []model.HassEntity
GetEntitiesForTrigger godoc
func (*Action) GetEventTypesForTrigger ¶
GetEventTypesForTrigger godoc
func (*Action) NeedsInitialization ¶
NeedsInitialization specifies if this Actionable needs to be triggered with a dummy event when program starts (or conf is reloaded)
type Actionable ¶
type Actionable interface { Automate GetEntitiesForTrigger() []model.HassEntity GetEventTypesForTrigger() []string Trigger(e *model.HassEvent) GinHandler(c *gin.Context) // NeedsInitialization specifies if this Actionable needs to be triggered with a dummy event // when program starts (or conf is reloaded) NeedsInitialization() bool }
Actionable is an interface to react on change event
type Checkable ¶
type Checkable interface { Configurable routines.Runnable GetModular() Modular }
Checkable is an interface to check something at a regular interval
type Checker ¶
type Checker struct { Module Modular // contains filtered or unexported fields }
Checker checks a Modular at a regular interval
func (*Checker) IsAutoStart ¶
type Configurable ¶
type Configurable interface {
Configure(config interface{}, obj interface{}) error
}
Configurable is an interface to make any object configurable using a config file
type Coordinates ¶
type Coordinates interface { routines.Runnable GetSunriseSunset() (time.Time, time.Time, error) IsDarkNow(offsetDawn, offsetDusk time.Duration) bool GetLatitude() float64 GetLongitude() float64 }
Coordinates represents GPS coordinates using latitude and longitude
type CronEntry ¶
type CronEntry struct { Expr string `mapstructure:"expr"` Action string `mapstructure:"action"` Entities []model.HassEntity `mapstructure:"entities"` }
CronEntry is a struct to configure a crontab's entry
func (*CronEntry) GetActionFunc ¶
func (c *CronEntry) GetActionFunc() func()
GetActionFunc returns a func to execute when cron time is triggered
type HeaterSchedule ¶
type HeaterSchedule struct { Beg time.Time `mapstructure:"beg"` End time.Time `mapstructure:"end"` Comfort float64 `mapstructure:"comfort"` Eco float64 `mapstructure:"eco"` }
HeaterSchedule represents a heater's schedule
func (HeaterSchedule) IsActive ¶
func (c HeaterSchedule) IsActive(t time.Time) bool
IsActive returns true if given 't' is between c.Beg and c.End
func (HeaterSchedule) MarshalZerologObject ¶
func (c HeaterSchedule) MarshalZerologObject(event *zerolog.Event)
MarshalZerologObject godoc
type HeaterSchedules ¶
type HeaterSchedules struct { Scheds map[SchedulesDays][]HeaterSchedule `mapstructure:"schedules"` DefaultEco float64 `mapstructure:"default_eco"` ManualOverride model.HassEntity `mapstructure:"manual_override"` Thermostat model.HassEntity `mapstructure:"thermostat"` DateBegin model.DayMonthDate `mapstructure:"date_begin"` DateEnd model.DayMonthDate `mapstructure:"date_end"` }
HeaterSchedules stores all schedules for a heater
func (*HeaterSchedules) Configure ¶
func (c *HeaterSchedules) Configure(data interface{}, i interface{}) error
Configure reads the configuration and returns a new Checkable object
func (*HeaterSchedules) GetTemperatureToSet ¶
func (c *HeaterSchedules) GetTemperatureToSet(t time.Time) float64
GetTemperatureToSet returns the temperature to set corresponding to the time given in parameter
func (*HeaterSchedules) MarshalZerologObject ¶
func (c *HeaterSchedules) MarshalZerologObject(event *zerolog.Event)
MarshalZerologObject godoc
type Module ¶
type Module struct { Interval time.Duration `mapstructure:"interval"` // contains filtered or unexported fields }
Module is the base struct to build a module
type RandomLightsRoutine ¶
func NewRandomLightsRoutine ¶
type SchedulesDays ¶
type SchedulesDays string
SchedulesDays are the days when the schedules applies Examples:
- week
- monday,tuesday,friday
- monday,wednesday,weekend
func (SchedulesDays) AsFlag ¶
func (s SchedulesDays) AsFlag() int
AsFlag returns an int from a SchedulesDays
func (SchedulesDays) IsScheduled ¶
func (s SchedulesDays) IsScheduled(t time.Time) bool
IsScheduled returns true if the day of 't' is contained into 's' SchedulesDays
type Trigger ¶
type Trigger struct {
Action Actionable
}
Trigger triggers an action when a change occurs
type Triggerable ¶
type Triggerable interface { Configurable GetActionable() Actionable GetName() string }
Triggerable is an interface to trigger an action when a change is detected