Documentation ¶
Index ¶
- Variables
- func ParseHexColor(s string) (c color.RGBA, err error)
- func RegisterLightsServer(s grpc.ServiceRegistrar, srv LightsServer)
- type Brightness
- type ColorTempSchedule
- type ColorTempSchedulerFunc
- type ColorTemperature
- func (ColorTemperature) Descriptor() protoreflect.EnumDescriptor
- func (x ColorTemperature) Enum() *ColorTemperature
- func (ColorTemperature) EnumDescriptor() ([]byte, []int)deprecated
- func (x ColorTemperature) Number() protoreflect.EnumNumber
- func (x ColorTemperature) String() string
- func (ColorTemperature) Type() protoreflect.EnumType
- type Config
- type Handler
- type Light
- type LightGroup
- func (*LightGroup) Descriptor() ([]byte, []int)deprecated
- func (x *LightGroup) GetId() int32
- func (x *LightGroup) GetLights() []int32
- func (x *LightGroup) GetName() string
- func (x *LightGroup) GetType() string
- func (*LightGroup) ProtoMessage()
- func (x *LightGroup) ProtoReflect() protoreflect.Message
- func (x *LightGroup) Reset()
- func (x *LightGroup) String() string
- type LightResponse
- func (*LightResponse) Descriptor() ([]byte, []int)deprecated
- func (x *LightResponse) GetGroups() []*LightGroup
- func (x *LightResponse) GetLights() []*Light
- func (*LightResponse) ProtoMessage()
- func (x *LightResponse) ProtoReflect() protoreflect.Message
- func (x *LightResponse) Reset()
- func (x *LightResponse) String() string
- type Lights
- func (l *Lights) ActionHandler(ctx context.Context, action *iot.Action) error
- func (l *Lights) AddHandler(h Handler)
- func (l *Lights) NamedTimerHandler(ctx context.Context, e string) error
- func (l *Lights) SetColorTempScheduler(c ColorTempSchedulerFunc)
- func (l *Lights) SetRoomForEvent(ctx context.Context, event string) error
- type LightsClient
- type LightsServer
- type MockLight
- func (m *MockLight) Alert(ctx context.Context, groupName string) error
- func (m *MockLight) Off(ctx context.Context, groupName string) error
- func (m *MockLight) On(ctx context.Context, groupName string) error
- func (m *MockLight) RandomColor(ctx context.Context, groupName string, colors []string) error
- func (m *MockLight) SetBrightness(ctx context.Context, groupName string, brightness int32) error
- func (m *MockLight) SetColor(ctx context.Context, groupName string, hex string) error
- func (m *MockLight) SetColorTemp(ctx context.Context, groupName string, temp int32) error
- func (m *MockLight) Toggle(ctx context.Context, groupName string) error
- type Room
- type StateSpec
- type UnimplementedLightsServer
- type UnsafeLightsServer
- type Zone
- func (z *Zone) Alert(ctx context.Context) error
- func (z *Zone) DecrementBrightness(ctx context.Context) error
- func (z *Zone) Flush(ctx context.Context) error
- func (z *Zone) IncrementBrightness(ctx context.Context) error
- func (z *Zone) Name() string
- func (z *Zone) Off(ctx context.Context) error
- func (z *Zone) On(ctx context.Context) error
- func (z *Zone) RandomColor(ctx context.Context, colors []string) error
- func (z *Zone) SetBrightness(ctx context.Context, brightness Brightness) error
- func (z *Zone) SetBrightnessMap(m map[Brightness]int32)
- func (z *Zone) SetColor(ctx context.Context, color string) error
- func (z *Zone) SetColorTemperature(ctx context.Context, colorTemp ColorTemperature) error
- func (z *Zone) SetColorTemperatureMap(m map[ColorTemperature]int32)
- func (z *Zone) SetHandlers(handlers ...Handler)
- func (z *Zone) SetName(name string)
- func (z *Zone) SetState(ctx context.Context, state ZoneState) error
- func (z *Zone) Toggle(ctx context.Context) error
- type ZoneState
- type ZoneStateRequest
- func (*ZoneStateRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ZoneStateRequest) GetName() string
- func (x *ZoneStateRequest) GetState() ZoneState
- func (*ZoneStateRequest) ProtoMessage()
- func (x *ZoneStateRequest) ProtoReflect() protoreflect.Message
- func (x *ZoneStateRequest) Reset()
- func (x *ZoneStateRequest) String() string
- type ZoneStateResponse
- type Zones
Constants ¶
This section is empty.
Variables ¶
var ( ZoneState_name = map[int32]string{ 0: "ON", 1: "OFF", 2: "OFFTIMER", 3: "COLOR", 4: "RANDOMCOLOR", 5: "NIGHTVISION", 6: "EVENINGVISION", 7: "MORNINGVISION", } ZoneState_value = map[string]int32{ "ON": 0, "OFF": 1, "OFFTIMER": 2, "COLOR": 3, "RANDOMCOLOR": 4, "NIGHTVISION": 5, "EVENINGVISION": 6, "MORNINGVISION": 7, } )
Enum value maps for ZoneState.
var ( ColorTemperature_name = map[int32]string{ 0: "FIRSTLIGHT", 1: "MORNING", 2: "DAY", 3: "LATEAFTERNOON", 4: "EVENING", } ColorTemperature_value = map[string]int32{ "FIRSTLIGHT": 0, "MORNING": 1, "DAY": 2, "LATEAFTERNOON": 3, "EVENING": 4, } )
Enum value maps for ColorTemperature.
var ( Brightness_name = map[int32]string{ 0: "FULL", 1: "DIM", 2: "LOW", 3: "DIMPLUS", 4: "LOWPLUS", 5: "VERYLOW", } Brightness_value = map[string]int32{ "FULL": 0, "DIM": 1, "LOW": 2, "DIMPLUS": 3, "LOWPLUS": 4, "VERYLOW": 5, } )
Enum value maps for Brightness.
var ErrHandlerFailed = errors.New("handler failed")
ErrHandlerFailed is used to indicate that a lights handler has failed to execute.
var ErrNilConfig = errors.New("nil lights config")
ErrNilConfig is used to indicate that a method has received a config that was nil.
var ErrNoRoomsConfigured = errors.New("no rooms configured")
ErrNoRoomsConfigured is used to indicate that the configuration contained no Rooms.
var ErrRoomNotFound = errors.New("room not found")
ErrRoomNotFound is used to indicate a named room was not found in the config.
var ErrUnhandledEventName = errors.New("unhandled event name")
ErrUnhandledEventName is used to indicate the evet name was not found in the RoomConfig.
var ErrUnknownActionEvent = errors.New("unknown action event")
ErrUnknownActionEvent is used to indicate that an action was not recognized.
var File_modules_lights_lights_proto protoreflect.FileDescriptor
var Lights_ServiceDesc = grpc.ServiceDesc{ ServiceName: "lights.Lights", HandlerType: (*LightsServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SetState", Handler: _Lights_SetState_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "modules/lights/lights.proto", }
Lights_ServiceDesc is the grpc.ServiceDesc for Lights service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterLightsServer ¶
func RegisterLightsServer(s grpc.ServiceRegistrar, srv LightsServer)
Types ¶
type Brightness ¶
type Brightness int32
const ( Brightness_FULL Brightness = 0 Brightness_DIM Brightness = 1 Brightness_LOW Brightness = 2 Brightness_DIMPLUS Brightness = 3 Brightness_LOWPLUS Brightness = 4 Brightness_VERYLOW Brightness = 5 )
func (Brightness) Descriptor ¶
func (Brightness) Descriptor() protoreflect.EnumDescriptor
func (Brightness) Enum ¶
func (x Brightness) Enum() *Brightness
func (Brightness) EnumDescriptor
deprecated
func (Brightness) EnumDescriptor() ([]byte, []int)
Deprecated: Use Brightness.Descriptor instead.
func (Brightness) Number ¶
func (x Brightness) Number() protoreflect.EnumNumber
func (Brightness) String ¶
func (x Brightness) String() string
func (Brightness) Type ¶
func (Brightness) Type() protoreflect.EnumType
type ColorTempSchedule ¶
type ColorTempSchedule map[ColorTemperature]time.Time
func (ColorTempSchedule) MostRecent ¶
func (c ColorTempSchedule) MostRecent() ColorTemperature
type ColorTempSchedulerFunc ¶
type ColorTempSchedulerFunc func() ColorTempSchedule
func StaticColorTempSchedule ¶
func StaticColorTempSchedule(timezone string) (ColorTempSchedulerFunc, error)
type ColorTemperature ¶
type ColorTemperature int32
const ( ColorTemperature_FIRSTLIGHT ColorTemperature = 0 ColorTemperature_MORNING ColorTemperature = 1 ColorTemperature_DAY ColorTemperature = 2 ColorTemperature_LATEAFTERNOON ColorTemperature = 3 ColorTemperature_EVENING ColorTemperature = 4 )
func (ColorTemperature) Descriptor ¶
func (ColorTemperature) Descriptor() protoreflect.EnumDescriptor
func (ColorTemperature) Enum ¶
func (x ColorTemperature) Enum() *ColorTemperature
func (ColorTemperature) EnumDescriptor
deprecated
func (ColorTemperature) EnumDescriptor() ([]byte, []int)
Deprecated: Use ColorTemperature.Descriptor instead.
func (ColorTemperature) Number ¶
func (x ColorTemperature) Number() protoreflect.EnumNumber
func (ColorTemperature) String ¶
func (x ColorTemperature) String() string
func (ColorTemperature) Type ¶
func (ColorTemperature) Type() protoreflect.EnumType
type Config ¶
type Config struct { Rooms []Room `yaml:"rooms"` PartyColors []string `yaml:"party_colors,omitempty"` TimeZone string `yaml:"timezone" json:"timezone"` }
Config is the configuration for Lights
type Handler ¶
type Handler interface { Alert(context.Context, string) error Off(context.Context, string) error On(context.Context, string) error RandomColor(context.Context, string, []string) error SetBrightness(context.Context, string, int32) error SetColor(context.Context, string, string) error SetColorTemp(context.Context, string, int32) error Toggle(context.Context, string) error }
Handler is the interface to be implemented for a specific API.
type Light ¶
type Light struct { Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
func (*Light) Descriptor
deprecated
func (*Light) ProtoMessage ¶
func (*Light) ProtoMessage()
func (*Light) ProtoReflect ¶
func (x *Light) ProtoReflect() protoreflect.Message
type LightGroup ¶
type LightGroup struct { Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` Lights []int32 `protobuf:"varint,4,rep,packed,name=lights,proto3" json:"lights,omitempty"` // contains filtered or unexported fields }
func (*LightGroup) Descriptor
deprecated
func (*LightGroup) Descriptor() ([]byte, []int)
Deprecated: Use LightGroup.ProtoReflect.Descriptor instead.
func (*LightGroup) GetId ¶
func (x *LightGroup) GetId() int32
func (*LightGroup) GetLights ¶
func (x *LightGroup) GetLights() []int32
func (*LightGroup) GetName ¶
func (x *LightGroup) GetName() string
func (*LightGroup) GetType ¶
func (x *LightGroup) GetType() string
func (*LightGroup) ProtoMessage ¶
func (*LightGroup) ProtoMessage()
func (*LightGroup) ProtoReflect ¶
func (x *LightGroup) ProtoReflect() protoreflect.Message
func (*LightGroup) Reset ¶
func (x *LightGroup) Reset()
func (*LightGroup) String ¶
func (x *LightGroup) String() string
type LightResponse ¶
type LightResponse struct { Lights []*Light `protobuf:"bytes,1,rep,name=lights,proto3" json:"lights,omitempty"` Groups []*LightGroup `protobuf:"bytes,2,rep,name=groups,proto3" json:"groups,omitempty"` // contains filtered or unexported fields }
func (*LightResponse) Descriptor
deprecated
func (*LightResponse) Descriptor() ([]byte, []int)
Deprecated: Use LightResponse.ProtoReflect.Descriptor instead.
func (*LightResponse) GetGroups ¶
func (x *LightResponse) GetGroups() []*LightGroup
func (*LightResponse) GetLights ¶
func (x *LightResponse) GetLights() []*Light
func (*LightResponse) ProtoMessage ¶
func (*LightResponse) ProtoMessage()
func (*LightResponse) ProtoReflect ¶
func (x *LightResponse) ProtoReflect() protoreflect.Message
func (*LightResponse) Reset ¶
func (x *LightResponse) Reset()
func (*LightResponse) String ¶
func (x *LightResponse) String() string
type Lights ¶
type Lights struct { UnimplementedLightsServer services.Service sync.Mutex // contains filtered or unexported fields }
Lights holds the information necessary to communicate with lighting equipment, and the configuration to add a bit of context.
func (*Lights) ActionHandler ¶
ActionHandler is called when an action is requested against a light group. The action speciefies the a button press and a room to give enough context for how to change the behavior of the lights in response to the action.
func (*Lights) AddHandler ¶
AddHandler is used to register the received Handler.
func (*Lights) NamedTimerHandler ¶
func (*Lights) SetColorTempScheduler ¶
func (l *Lights) SetColorTempScheduler(c ColorTempSchedulerFunc)
type LightsClient ¶
type LightsClient interface {
SetState(ctx context.Context, in *ZoneStateRequest, opts ...grpc.CallOption) (*ZoneStateResponse, error)
}
LightsClient is the client API for Lights service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewLightsClient ¶
func NewLightsClient(cc grpc.ClientConnInterface) LightsClient
type LightsServer ¶
type LightsServer interface { SetState(context.Context, *ZoneStateRequest) (*ZoneStateResponse, error) // contains filtered or unexported methods }
LightsServer is the server API for Lights service. All implementations must embed UnimplementedLightsServer for forward compatibility
type MockLight ¶
type MockLight struct { AlertCalls map[string]int OffCalls map[string]int OnCalls map[string]int RandomColorCalls map[string]int SetBrightnessCalls map[string]int SetColorCalls map[string]int SetColorTempCalls map[string]int ToggleCalls map[string]int }
func (*MockLight) RandomColor ¶
func (*MockLight) SetBrightness ¶
func (*MockLight) SetColorTemp ¶
type StateSpec ¶
type StateSpec struct { State ZoneState `yaml:"state"` Brightness *Brightness `yaml:"brightness,omitempty"` ColorTemp *ColorTemperature `yaml:"color_temp,omitempty"` Event string `yaml:"event"` }
func (*StateSpec) UnmarshalYAML ¶
Implements the Unmarshaler interface of the yaml pkg.
type UnimplementedLightsServer ¶
type UnimplementedLightsServer struct { }
UnimplementedLightsServer must be embedded to have forward compatible implementations.
func (UnimplementedLightsServer) SetState ¶
func (UnimplementedLightsServer) SetState(context.Context, *ZoneStateRequest) (*ZoneStateResponse, error)
type UnsafeLightsServer ¶
type UnsafeLightsServer interface {
// contains filtered or unexported methods
}
UnsafeLightsServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to LightsServer will result in compilation errors.
type Zone ¶
type Zone struct {
// contains filtered or unexported fields
}
func (*Zone) SetBrightness ¶
func (z *Zone) SetBrightness(ctx context.Context, brightness Brightness) error
func (*Zone) SetBrightnessMap ¶
func (z *Zone) SetBrightnessMap(m map[Brightness]int32)
func (*Zone) SetColorTemperature ¶
func (z *Zone) SetColorTemperature(ctx context.Context, colorTemp ColorTemperature) error
func (*Zone) SetColorTemperatureMap ¶
func (z *Zone) SetColorTemperatureMap(m map[ColorTemperature]int32)
func (*Zone) SetHandlers ¶
type ZoneState ¶
type ZoneState int32
func (ZoneState) Descriptor ¶
func (ZoneState) Descriptor() protoreflect.EnumDescriptor
func (ZoneState) EnumDescriptor
deprecated
func (ZoneState) Number ¶
func (x ZoneState) Number() protoreflect.EnumNumber
func (ZoneState) Type ¶
func (ZoneState) Type() protoreflect.EnumType
type ZoneStateRequest ¶
type ZoneStateRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` State ZoneState `protobuf:"varint,2,opt,name=state,proto3,enum=lights.ZoneState" json:"state,omitempty"` // contains filtered or unexported fields }
func (*ZoneStateRequest) Descriptor
deprecated
func (*ZoneStateRequest) Descriptor() ([]byte, []int)
Deprecated: Use ZoneStateRequest.ProtoReflect.Descriptor instead.
func (*ZoneStateRequest) GetName ¶
func (x *ZoneStateRequest) GetName() string
func (*ZoneStateRequest) GetState ¶
func (x *ZoneStateRequest) GetState() ZoneState
func (*ZoneStateRequest) ProtoMessage ¶
func (*ZoneStateRequest) ProtoMessage()
func (*ZoneStateRequest) ProtoReflect ¶
func (x *ZoneStateRequest) ProtoReflect() protoreflect.Message
func (*ZoneStateRequest) Reset ¶
func (x *ZoneStateRequest) Reset()
func (*ZoneStateRequest) String ¶
func (x *ZoneStateRequest) String() string
type ZoneStateResponse ¶
type ZoneStateResponse struct { Color string `protobuf:"bytes,1,opt,name=color,proto3" json:"color,omitempty"` // contains filtered or unexported fields }
func (*ZoneStateResponse) Descriptor
deprecated
func (*ZoneStateResponse) Descriptor() ([]byte, []int)
Deprecated: Use ZoneStateResponse.ProtoReflect.Descriptor instead.
func (*ZoneStateResponse) GetColor ¶
func (x *ZoneStateResponse) GetColor() string
func (*ZoneStateResponse) ProtoMessage ¶
func (*ZoneStateResponse) ProtoMessage()
func (*ZoneStateResponse) ProtoReflect ¶
func (x *ZoneStateResponse) ProtoReflect() protoreflect.Message
func (*ZoneStateResponse) Reset ¶
func (x *ZoneStateResponse) Reset()
func (*ZoneStateResponse) String ¶
func (x *ZoneStateResponse) String() string