smarthome

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: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeFormat                     = time.RFC3339
	DefaultFreshnessCheckerTemplateString = `The following entities have not been seen since {{ .Checker.Freshness }}: {{ JoinEntities .Entities ", " }}`
)
View Source
const (
	DefaultTemperatureCheckerTempThreshold       = 25
	DefaultTemperatureCheckerSendMessageInterval = 24 * time.Hour
	DefaultTemperatureCheckerTemplate            = `The following sensors have exceeded the temperature threshold: {{ JoinEntities .Entities ", " }}`
)
View Source
const (
	// ModuleInternetChecker is a module to check the internet connection
	ModuleInternetChecker = "internetChecker"
	// ModuleHeaterChecker is a module to set heater temperature
	ModuleHeaterChecker = "heaterChecker"
	// ModuleCalendarChecker checks a calendar at regular interval
	ModuleCalendarChecker = "calendarChecker"
	// ModuleFreshness checks at a regular interval if device has been last seen not too long ago
	ModuleFreshness = "freshnessChecker"
	// ModuleTemperatureChecker checks at a regular interval if device exceeds a certain temperature and alert if it does
	ModuleTemperatureChecker = "temperatureChecker"
	// TriggerDehumidifier triggers dehumidifier on or off depending on humidity
	TriggerDehumidifier = "dehumidifier"
	// TriggerHarmony uses Roku Emulated to make actions based on Harmony remote buttons press
	TriggerHarmony = "harmony"
	// TriggerCalendarLights set to on or off lights based on calendar events
	TriggerCalendarLights = "calendarLights"
	// TriggerHeaterCheckersDisabler globally disables heaters' automatic programmation
	TriggerHeaterCheckersDisabler = "heaterCheckersDisabler"
	// TriggerRandomLights is a module to set on/off lights randomly between a specific time frame
	TriggerRandomLights = "randomLights"
	// TriggerAlertBool is a module to send alerts to a specific sender depending on binary entity state change
	TriggerAlertBool = "alert"
)
View Source
const (
	DefaultAlertTriggerBoolTemplateString = "{{ .Event.EntityID }} has been changed to {{ .Event.NewState.State }}"
)
View Source
const (
	// DefaultEcoTemp is the default eco temperature when not set in the config file
	DefaultEcoTemp = float64(15)
)

Variables

This section is empty.

Functions

func EventCallback

func EventCallback(msg model.HassAPIObject)

EventCallback is called when a listen event occurs

func GetCheckersByType

func GetCheckersByType(name string) []core.Checkable

GetCheckersByType returns all checkers corresponding to a given name

func GetSender

func GetSender(name string) messaging.Sender

func Init

func Init(config config.Gotomation) error

Init inits checkers from configuration

func StopAndWait

func StopAndWait()

StopAndWait stops and free all allocated smarthome objects

Types

type AlertTriggerBool

type AlertTriggerBool struct {
	core.Action `mapstructure:",squash"`
	Sender      string `mapstructure:"sender"`
	// Templates are the template to use to send notification message
	Templates map[string]struct {
		// MsgTemplate is used to format the message sent
		MsgTemplate string `mapstructure:"msg_template"`
	} `mapstructure:"templates"`
}

AlertTriggerBool sends alert to a Sender when a specific boolean has its state changed

func (*AlertTriggerBool) GinHandler

func (a *AlertTriggerBool) GinHandler(c *gin.Context)

GinHandler godoc

func (*AlertTriggerBool) Trigger

func (a *AlertTriggerBool) Trigger(event *model.HassEvent)

Trigger godoc

type CalendarChecker

type CalendarChecker struct {
	core.Module `mapstructure:",squash"`
	Cals        []struct {
		Name string `mapstructure:"name"`
		ID   string `mapstructure:"id"`
	} `mapstructure:"cals"`
}

CalendarChecker checks calendar for new events once in a while

func (*CalendarChecker) Check

func (c *CalendarChecker) Check()

Check runs a single check

func (*CalendarChecker) GinHandler

func (c *CalendarChecker) GinHandler(ctx *gin.Context)

type CalendarLightsTrigger

type CalendarLightsTrigger struct {
	core.Action `mapstructure:",squash"`
	Cals        []struct {
		Name string `mapstructure:"name"`
		ID   string `mapstructure:"id"`
	} `mapstructure:"cals"`
}

CalendarLightsTrigger checks calendar for new events once in a while

func (*CalendarLightsTrigger) GinHandler

func (c *CalendarLightsTrigger) GinHandler(ctx *gin.Context)

GinHandler godoc

func (*CalendarLightsTrigger) Trigger

func (c *CalendarLightsTrigger) Trigger(event *model.HassEvent)

Trigger godoc

type DehumidifierTrigger

type DehumidifierTrigger struct {
	core.Action `mapstructure:",squash"`
	// SwitchEntity is the entity used to switch on / off the dehumidifier
	SwitchEntity model.HassEntity `mapstructure:"switch_entity"`
	// TimeBeg is the time where monitoring begins
	TimeBeg time.Time `mapstructure:"time_beg"`
	// TimeEnd is the time where monitoring ends
	TimeEnd time.Time `mapstructure:"time_end"`
	// ThresholdMin is the threshold which drives the dehumidifier on/off
	ThresholdMin float64 `mapstructure:"threshold_min"`
	// ThresholdMax is the threshold which drives the dehumidifier on/off
	ThresholdMax float64 `mapstructure:"threshold_max"`
	// ManualOverride is the input_boolean to deactivate manually the DehumidifierChecker automatic behavior
	ManualOverride model.HassEntity `mapstructure:"manual_override"`
}

DehumidifierTrigger checks for humidity and activate/deactivate a dehumidifier

func (*DehumidifierTrigger) GinHandler

func (d *DehumidifierTrigger) GinHandler(c *gin.Context)

GinHandler godoc

func (*DehumidifierTrigger) Trigger

func (d *DehumidifierTrigger) Trigger(event *model.HassEvent)

Trigger godoc

type FreshnessChecker

type FreshnessChecker struct {
	core.Module `mapstructure:",squash"`
	// Entities are the entities returning device's last seen value
	Entities []model.HassEntity `mapstructure:"entities"`
	// Sender is used to send an alert if one or more entities have not been seen soon enough
	Sender string `mapstructure:"sender"`
	// Freshness configures the max allowed time a device has to be seen
	Freshness time.Duration `mapstructure:"freshness"`
	// TimeFormat sets the time format if different from default
	TimeFormat string `mapstructure:"time_format"`
	// Template to use for sending message to the sender
	Template string `mapstructure:"template"`
}

FreshnessChecker checks freshness of devices against a duration (using last_seen property)

func (*FreshnessChecker) Check

func (c *FreshnessChecker) Check()

Check runs a single check

func (*FreshnessChecker) GinHandler

func (c *FreshnessChecker) GinHandler(ctx *gin.Context)

type HarmonyTrigger

type HarmonyTrigger struct {
	core.Action `mapstructure:",squash"`
	WorkActions []workAction `mapstructure:"work_actions"`
}

HarmonyTrigger checks for harmony remote button press and takes action accordingly

func (*HarmonyTrigger) GinHandler

func (h *HarmonyTrigger) GinHandler(c *gin.Context)

GinHandler godoc

func (*HarmonyTrigger) Trigger

func (h *HarmonyTrigger) Trigger(event *model.HassEvent)

Trigger godoc

type HeaterChecker

type HeaterChecker struct {
	core.Module   `mapstructure:",squash"`
	SchedulesFile string `mapstructure:"schedules_file"`
	// contains filtered or unexported fields
}

HeaterChecker sets the heater's thermostat based on schedules

func (*HeaterChecker) Check

func (h *HeaterChecker) Check()

Check runs a single check

func (*HeaterChecker) GetClimateEntity

func (h *HeaterChecker) GetClimateEntity() (model.HassEntity, error)

GetClimateEntity returns the climate entity attached to the Heater's schedules object

func (*HeaterChecker) GetDefaultEcoTemp

func (h *HeaterChecker) GetDefaultEcoTemp() float64

GetDefaultEcoTemp returns the

func (*HeaterChecker) GetManualOverrideEntity

func (h *HeaterChecker) GetManualOverrideEntity() (model.HassEntity, error)

GetManualOverrideEntity returns the manual override entity attached to the Heater's schedules object

func (*HeaterChecker) GinHandler

func (h *HeaterChecker) GinHandler(c *gin.Context)

GinHandler godoc

type HeaterCheckersDisablerTrigger

type HeaterCheckersDisablerTrigger struct {
	core.Action `mapstructure:",squash"`
}

HeaterCheckersDisablerTrigger globally disables all heaters (or specified ones) and set a default temperature

func (*HeaterCheckersDisablerTrigger) Trigger

func (d *HeaterCheckersDisablerTrigger) Trigger(event *model.HassEvent)

Trigger godoc

type InternetChecker

type InternetChecker struct {
	core.Module `mapstructure:",squash"`
	// PingHost is the host to ping
	PingHost string `mapstructure:"ping_host"`
	// MaxRebootEvery is the min duration between 2 reboots
	MaxRebootEvery time.Duration `mapstructure:"max_reboot_every"`
	// RestartEntity is the entity to restart in case of failure
	RestartEntity model.HassEntity `mapstructure:"restart_entity"`
	// contains filtered or unexported fields
}

InternetChecker module pings a host at a regular interval and restart the internet box if it fails

func (*InternetChecker) Check

func (c *InternetChecker) Check()

Check runs a single check

func (*InternetChecker) GinHandler

func (c *InternetChecker) GinHandler(ctx *gin.Context)

GinHandler godoc

type RandomLightsTrigger

type RandomLightsTrigger struct {
	core.Action `mapstructure:",squash"`
	// Name is the name of this RandomLightsTrigger
	Name string `mapstructure:"name"`
	// Lights are all the lights driven by the module
	Lights []model.RandomLight `mapstructure:"lights"`
	// NbSlots is the number maximum of lights set to on at the same time
	NbSlots uint32 `mapstructure:"nb_slots"`
	// TimeBegin is the starting time when the lights can be set to on
	TimeBegin time.Time `mapstructure:"time_begin"`
	// TimeEnd is the ending time when the lights can be set to on
	TimeEnd time.Time `mapstructure:"time_end"`
	// Odds is the probability to turn on a light (P = 1/Odds)
	Odds         uint32        `mapstructure:"odds"`
	RefreshEvery time.Duration `mapstructure:"refresh_every"`
	// contains filtered or unexported fields
}

RandomLightsTrigger checks for humidity and activate/deactivate a dehumidifier

func (*RandomLightsTrigger) GinHandler

func (d *RandomLightsTrigger) GinHandler(c *gin.Context)

GinHandler godoc

func (*RandomLightsTrigger) NeedsInitialization

func (d *RandomLightsTrigger) NeedsInitialization() bool

NeedsInitialization specifies if this Actionable needs to be triggered with a dummy event when program starts (or conf is reloaded)

func (*RandomLightsTrigger) Trigger

func (d *RandomLightsTrigger) Trigger(event *model.HassEvent)

Trigger godoc

type TemperatureChecker

type TemperatureChecker struct {
	core.Module `mapstructure:",squash"`
	// Sensors are the entities to check for temperature threshold
	Sensors []struct {
		Entity        model.HassEntity `mapstructure:"entity"`
		TempThreshold float64          `mapstructure:"temp_threshold"`
	} `mapstructure:"sensors"`
	DateBegin           model.DayMonthDate `mapstructure:"date_begin"`
	DateEnd             model.DayMonthDate `mapstructure:"date_end"`
	Sender              string             `mapstructure:"sender"`
	SendMessageInterval time.Duration      `mapstructure:"send_message_interval"`
	Template            string             `mapstructure:"template"`
	// contains filtered or unexported fields
}

func (*TemperatureChecker) Check

func (c *TemperatureChecker) Check()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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