Documentation ¶
Overview ¶
Package timeswitch implements the time switch logic for outlets. Outlets can be configured to automatically be turned on or off during certain periods of the day or week. The time switch will emit state correction commands based on the schedule that may be defined on an outlet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimeSwitch ¶
type TimeSwitch struct { Registry *outlet.Registry CommandQueue chan<- command.Command Clock clockwork.Clock }
TimeSwitch checks if outlets should be enabled or disabled based on their schedule and send out commands to bring them to the desired state.
func New ¶
func New(registry *outlet.Registry, queue chan<- command.Command) *TimeSwitch
New creates a new *TimeSwitch which will observe the outlets in the registry and eventually push commands to the queue if a state change is required.
func (*TimeSwitch) Run ¶
func (s *TimeSwitch) Run(stopCh <-chan struct{})
Run runs the time switch control loop which periodically checks if an outlet should be enabled or disabled. Whenever an outlet should change its state, it will push a TimeSwitchCommand into the CommandQueue.