Documentation ¶
Index ¶
- Constants
- func DebugString(l Light) string
- func SendDMXWorker(ctx context.Context, client OLAClient, tick time.Duration, manager Manager, ...) error
- type DMXLight
- type DMXState
- type DiscoveredHues
- type GenericLight
- type HueConnection
- type HueLight
- type Light
- type Manager
- type MockHueConnection
- type MockLight
- type MockManager
- func (_m *MockManager) GetAllStates() *StateMap
- func (_m *MockManager) GetByName(name string) Light
- func (_m *MockManager) GetDMXState() *DMXState
- func (_m *MockManager) GetDiscoveredHues() DiscoveredHues
- func (_m *MockManager) GetHueConnection() HueConnection
- func (_m *MockManager) GetLightNames() []string
- func (_m *MockManager) GetLightsByName() NameMap
- func (_m *MockManager) GetState(name string) *State
- func (_m *MockManager) SetDMXState(ctx context.Context, ops ...dmxOperation) error
- func (_m *MockManager) SetState(name string, new State)
- type MockOLAClient
- type NameMap
- type OLAClient
- type State
- type StateManager
- func (m *StateManager) GetAllStates() *StateMap
- func (m *StateManager) GetByName(name string) Light
- func (m *StateManager) GetDMXState() *DMXState
- func (m *StateManager) GetDiscoveredHues() DiscoveredHues
- func (m *StateManager) GetHueConnection() HueConnection
- func (m *StateManager) GetLightNames() []string
- func (m *StateManager) GetLightsByName() NameMap
- func (m *StateManager) GetState(name string) *State
- func (m *StateManager) SetDMXState(ctx context.Context, ops ...dmxOperation) error
- func (m *StateManager) SetState(name string, new State)
- type StateMap
- type TargetState
Constants ¶
const ( ChannelRed = "red" ChannelGreen = "green" ChannelBlue = "blue" )
Holds strings for the different channel types
const ( TypeHue = "hue" TypeDMX = "DMX" TypeGeneric = "generic" )
constants for the different types of lights
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DMXLight ¶
type DMXLight struct { Name string `json:"name" yaml:"name"` StartAddress int `json:"start_address" yaml:"start_address"` Universe int `json:"universe" yaml:"universe"` Profile string `json:"profile" yaml:"profile"` }
DMXLight is a DMX light
type DMXState ¶
type DMXState struct {
// contains filtered or unexported fields
}
DMXState holds the DMX512 values for each channel
type DiscoveredHues ¶
type DiscoveredHues struct { AllLights []lights.Light `json:"all_lights"` ByName map[string]int `json:"by_name"` }
DiscoveredHues is for wrapping hue info
type GenericLight ¶
type GenericLight struct {
Name string `json:"name" yaml:"name"`
}
GenericLight is for testing
func (*GenericLight) GetName ¶
func (gl *GenericLight) GetName() string
GetName returns the light's name.
func (*GenericLight) GetType ¶
func (gl *GenericLight) GetType() string
GetType returns the type of light.
func (*GenericLight) SetState ¶
func (gl *GenericLight) SetState(ctx context.Context, m Manager, target TargetState)
SetState updates the light's state.
type HueConnection ¶
type HueConnection interface { SetLightState(lightID int, state lights.State) ([]hue.ApiResponse, error) GetAllLights() ([]lights.Light, error) }
HueConnection represents a connection to a hue bridge
type HueLight ¶
type HueLight struct { HueID int `json:"hue_id" yaml:"hue_id"` Name string `json:"name" yaml:"name"` // contains filtered or unexported fields }
HueLight is a philips hue light.
type Light ¶
type Light interface { GetName() string GetType() string GetID() string SetState(context.Context, Manager, TargetState) }
Light is a light
type Manager ¶
type Manager interface { SetState(name string, new State) GetState(name string) *State GetLightNames() []string GetAllStates() *StateMap GetByName(name string) Light GetLightsByName() NameMap GetDMXState() *DMXState SetDMXState(ctx context.Context, ops ...dmxOperation) error GetHueConnection() HueConnection GetDiscoveredHues() DiscoveredHues }
Manager is the light manager interface
func NewManager ¶
func NewManager(ctx context.Context, h HueConnection) (Manager, error)
NewManager parses light config
type MockHueConnection ¶
MockHueConnection is an autogenerated mock type for the HueConnection type
func (*MockHueConnection) GetAllLights ¶
func (_m *MockHueConnection) GetAllLights() ([]lights.Light, error)
GetAllLights provides a mock function with given fields:
func (*MockHueConnection) SetLightState ¶
func (_m *MockHueConnection) SetLightState(lightID int, state lights.State) ([]hue.ApiResponse, error)
SetLightState provides a mock function with given fields: lightID, state
type MockLight ¶
MockLight is an autogenerated mock type for the Light type
type MockManager ¶
MockManager is an autogenerated mock type for the Manager type
func (*MockManager) GetAllStates ¶
func (_m *MockManager) GetAllStates() *StateMap
GetAllStates provides a mock function with given fields:
func (*MockManager) GetByName ¶
func (_m *MockManager) GetByName(name string) Light
GetByName provides a mock function with given fields: name
func (*MockManager) GetDMXState ¶
func (_m *MockManager) GetDMXState() *DMXState
GetDMXState provides a mock function with given fields:
func (*MockManager) GetDiscoveredHues ¶
func (_m *MockManager) GetDiscoveredHues() DiscoveredHues
GetDiscoveredHues provides a mock function with given fields:
func (*MockManager) GetHueConnection ¶
func (_m *MockManager) GetHueConnection() HueConnection
GetHueConnection provides a mock function with given fields:
func (*MockManager) GetLightNames ¶
func (_m *MockManager) GetLightNames() []string
GetLightNames provides a mock function with given fields:
func (*MockManager) GetLightsByName ¶
func (_m *MockManager) GetLightsByName() NameMap
GetLightsByName provides a mock function with given fields:
func (*MockManager) GetState ¶
func (_m *MockManager) GetState(name string) *State
GetState provides a mock function with given fields: name
func (*MockManager) SetDMXState ¶
func (_m *MockManager) SetDMXState(ctx context.Context, ops ...dmxOperation) error
SetDMXState provides a mock function with given fields: ctx, ops
func (*MockManager) SetState ¶
func (_m *MockManager) SetState(name string, new State)
SetState provides a mock function with given fields: name, new
type MockOLAClient ¶
MockOLAClient is an autogenerated mock type for the OLAClient type
func (*MockOLAClient) Close ¶
func (_m *MockOLAClient) Close()
Close provides a mock function with given fields:
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager holds the state of lights
func (*StateManager) GetAllStates ¶
func (m *StateManager) GetAllStates() *StateMap
GetAllStates will get the current state for all lights
func (*StateManager) GetByName ¶
func (m *StateManager) GetByName(name string) Light
GetByName looks up a light by name
func (*StateManager) GetDMXState ¶
func (m *StateManager) GetDMXState() *DMXState
GetDMXState returns the current dmx state
func (*StateManager) GetDiscoveredHues ¶
func (m *StateManager) GetDiscoveredHues() DiscoveredHues
GetDiscoveredHues finds all the hues on the network
func (*StateManager) GetHueConnection ¶
func (m *StateManager) GetHueConnection() HueConnection
GetHueConnection returns the hue connection object
func (*StateManager) GetLightNames ¶
func (m *StateManager) GetLightNames() []string
GetLightNames returns all the light names
func (*StateManager) GetLightsByName ¶
func (m *StateManager) GetLightsByName() NameMap
GetLightsByName returns lights keyed by name
func (*StateManager) GetState ¶
func (m *StateManager) GetState(name string) *State
GetState will get the current state for a light
func (*StateManager) SetDMXState ¶
func (m *StateManager) SetDMXState(ctx context.Context, ops ...dmxOperation) error
SetDMXState updates the dmxstate
func (*StateManager) SetState ¶
func (m *StateManager) SetState(name string, new State)
SetState will set the current state for a light
type TargetState ¶
type TargetState struct { // On bool State Duration time.Duration `json:"duration"` //time to transition to the new state }
TargetState represents the state of a light, is source of truth
func (*TargetState) String ¶
func (t *TargetState) String() string
func (*TargetState) ToState ¶
func (t *TargetState) ToState() State
ToState converts a TargetState to a State