Documentation ¶
Overview ¶
Package enums contains various enumerations and rules for device plugins.
Index ¶
- Variables
- func SliceContainsCommand(s []Command, e Command) bool
- func SliceContainsDeviceType(s []DeviceType, e DeviceType) bool
- func SliceContainsProperty(s []Property, e Property) bool
- type Command
- func (i Command) GetCommandMethodName() string
- func (i Command) IsACommand() bool
- func (i Command) IsCommandAllowed(deviceType DeviceType) bool
- func (i Command) MarshalJSON() ([]byte, error)
- func (i Command) MarshalText() ([]byte, error)
- func (i Command) MarshalYAML() (interface{}, error)
- func (i Command) String() string
- func (i *Command) UnmarshalJSON(data []byte) error
- func (i *Command) UnmarshalText(text []byte) error
- func (i *Command) UnmarshalYAML(unmarshal func(interface{}) error) error
- type DeviceType
- func (i DeviceType) IsADeviceType() bool
- func (i DeviceType) MarshalJSON() ([]byte, error)
- func (i DeviceType) MarshalText() ([]byte, error)
- func (i DeviceType) MarshalYAML() (interface{}, error)
- func (i DeviceType) String() string
- func (i *DeviceType) UnmarshalJSON(data []byte) error
- func (i *DeviceType) UnmarshalText(text []byte) error
- func (i *DeviceType) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Property
- func (i Property) GetPropertyName() string
- func (i Property) IsAProperty() bool
- func (i Property) IsPropertyAllowed(deviceType DeviceType) bool
- func (i Property) MarshalJSON() ([]byte, error)
- func (i Property) MarshalText() ([]byte, error)
- func (i Property) MarshalYAML() (interface{}, error)
- func (i Property) String() string
- func (i *Property) UnmarshalJSON(data []byte) error
- func (i *Property) UnmarshalText(text []byte) error
- func (i *Property) UnmarshalYAML(unmarshal func(interface{}) error) error
- type SensorType
- func (i SensorType) IsASensorType() bool
- func (i SensorType) MarshalJSON() ([]byte, error)
- func (i SensorType) MarshalText() ([]byte, error)
- func (i SensorType) MarshalYAML() (interface{}, error)
- func (i SensorType) String() string
- func (i *SensorType) UnmarshalJSON(data []byte) error
- func (i *SensorType) UnmarshalText(text []byte) error
- func (i *SensorType) UnmarshalYAML(unmarshal func(interface{}) error) error
- type UOM
- func (i UOM) IsAUOM() bool
- func (i UOM) MarshalJSON() ([]byte, error)
- func (i UOM) MarshalText() ([]byte, error)
- func (i UOM) MarshalYAML() (interface{}, error)
- func (i UOM) String() string
- func (i *UOM) UnmarshalJSON(data []byte) error
- func (i *UOM) UnmarshalText(text []byte) error
- func (i *UOM) UnmarshalYAML(unmarshal func(interface{}) error) error
- type VacStatus
- func (i VacStatus) IsAVacStatus() bool
- func (i VacStatus) MarshalJSON() ([]byte, error)
- func (i VacStatus) MarshalText() ([]byte, error)
- func (i VacStatus) MarshalYAML() (interface{}, error)
- func (i VacStatus) String() string
- func (i *VacStatus) UnmarshalJSON(data []byte) error
- func (i *VacStatus) UnmarshalText(text []byte) error
- func (i *VacStatus) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
var AllowedCommands = map[DeviceType][]Command{ DevHub: {}, DevLight: {CmdToggle, CmdOn, CmdOff, CmdSetColor, CmdSetTransitionTime, CmdSetBrightness, CmdSetScene}, DevSwitch: {CmdToggle, CmdOn, CmdOff}, DevSensor: {}, DevVacuum: {CmdOn, CmdOff, CmdPause, CmdDock, CmdFindMe, CmdSetFanSpeed}, DevCamera: {CmdTakePicture}, DevLock: {CmdOn, CmdOff, CmdToggle}, }
AllowedCommands contains set of all possible allowed commands per device type.
var AllowedProperties = map[DeviceType][]Property{ DevHub: {PropNumDevices}, DevLight: {PropOn, PropColor, PropTransitionTime, PropBrightness, PropScenes}, DevSwitch: {PropOn, PropPower}, DevSensor: {PropSensorType, PropOn, PropBatteryLevel, PropPower, PropTemperature, PropHumidity, PropPressure, PropClick, PropDoubleClick, PropPress, PropUser}, DevWeather: {PropTemperature, PropSunrise, PropSunset, PropHumidity, PropPressure, PropVisibility, PropWindDirection, PropWindSpeed, PropDescription}, DevVacuum: {PropVacStatus, PropBatteryLevel, PropArea, PropDuration, PropFanSpeed}, DevCamera: {PropPicture, PropDistance}, DevLock: {PropOn, PropBatteryLevel}, }
AllowedProperties contains set of all possible allowed properties per device type.
Functions ¶
func SliceContainsCommand ¶
SliceContainsCommand checks whether slice contains certain command.
func SliceContainsDeviceType ¶
func SliceContainsDeviceType(s []DeviceType, e DeviceType) bool
SliceContainsDeviceType is a helper Slice.contains.
func SliceContainsProperty ¶
SliceContainsProperty checks whether slice contains certain property.
Types ¶
type Command ¶
type Command int
Command describes enum with known device commands.
const ( // CmdInput describes user's input command. CmdInput Command = iota // CmdOn describes turning on command. CmdOn // CmdOff describes turning off command. CmdOff // CmdToggle describes toggling on-off status command. CmdToggle // CmdSetColor describes color changing on command. CmdSetColor // CmdSetScene describes turning on certain scene command. CmdSetScene // CmdSetBrightness describes changing brightness command. CmdSetBrightness // CmdSetTransitionTime describes transition time changing command. CmdSetTransitionTime // CmdPause describes pausing the device. CmdPause // CmdDock describes sending device to a dock station. CmdDock // CmdFindMe describes sending find me command. CmdFindMe // CmdSetFanSpeed describes setting fan speed command. CmdSetFanSpeed // CmdTakePicture describes taking a picture. CmdTakePicture )
func CommandString ¶
CommandString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (Command) GetCommandMethodName ¶
GetCommandMethodName transforms string representation of the command into actual method name.
func (Command) IsACommand ¶
IsACommand returns "true" if the value is listed in the enum definition. "false" otherwise
func (Command) IsCommandAllowed ¶
func (i Command) IsCommandAllowed(deviceType DeviceType) bool
IsCommandAllowed checks whether command is allowed for this device type.
func (Command) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for Command
func (Command) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Command
func (Command) MarshalYAML ¶
MarshalYAML implements a YAML Marshaler for Command
func (*Command) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for Command
func (*Command) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Command
func (*Command) UnmarshalYAML ¶
UnmarshalYAML implements a YAML Unmarshaler for Command
type DeviceType ¶
type DeviceType int
DeviceType describes enum with known device types.
const ( // DevUnknown describes unknown device type. DevUnknown DeviceType = iota // DevHub describes hub device type. DevHub // DevLight describes lights device type. DevLight // DevSwitch describes switch device type. DevSwitch // DevSensor describes sensor device type. DevSensor // DevGroup describes devices group type. DevGroup // DevWeather describes weather device. DevWeather // DevVacuum describes vacuum device. DevVacuum // DevCamera describes camera device. DevCamera // DevLock describes lock device. DevLock // DevTrigger describes a fake device for a trigger status updates. DevTrigger )
func DeviceTypeString ¶
func DeviceTypeString(s string) (DeviceType, error)
DeviceTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func DeviceTypeValues ¶
func DeviceTypeValues() []DeviceType
DeviceTypeValues returns all values of the enum
func (DeviceType) IsADeviceType ¶
func (i DeviceType) IsADeviceType() bool
IsADeviceType returns "true" if the value is listed in the enum definition. "false" otherwise
func (DeviceType) MarshalJSON ¶
func (i DeviceType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for DeviceType
func (DeviceType) MarshalText ¶
func (i DeviceType) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for DeviceType
func (DeviceType) MarshalYAML ¶
func (i DeviceType) MarshalYAML() (interface{}, error)
MarshalYAML implements a YAML Marshaler for DeviceType
func (DeviceType) String ¶
func (i DeviceType) String() string
func (*DeviceType) UnmarshalJSON ¶
func (i *DeviceType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for DeviceType
func (*DeviceType) UnmarshalText ¶
func (i *DeviceType) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for DeviceType
func (*DeviceType) UnmarshalYAML ¶
func (i *DeviceType) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements a YAML Unmarshaler for DeviceType
type Property ¶
type Property int
Property describes enum with known devices' properties.
const ( // PropInput describes user's input request state. PropInput Property = iota // PropOn describes On/Off status of the device. PropOn // PropColor describes color of the device. PropColor // PropNumDevices describes number of devices per hub. PropNumDevices // PropTransitionTime describes transition time of the device. PropTransitionTime // PropBrightness describes brightness of the device. PropBrightness // PropScenes describes list of scenes available for the device. PropScenes // PropPower describes device consumption power. PropPower // PropTemperature describes temperature. PropTemperature // PropBatteryLevel describes device battery level. PropBatteryLevel // PropSunrise describes sunrise time. PropSunrise // PropSunset describes sunset time. PropSunset // PropHumidity describes humidity. PropHumidity // PropPressure describes pressure. PropPressure // PropVisibility describes visibility. PropVisibility // PropWindDirection describes wind direction. PropWindDirection // PropWindSpeed describes wind speed. PropWindSpeed // PropClick describes single click button. PropClick // PropDoubleClick describes double click button. PropDoubleClick // PropPress describes long press button. PropPress // PropSensorType describes possible sensor type. PropSensorType // PropVacStatus describes status for the device. PropVacStatus // PropArea describes device operated area area. PropArea // PropDuration describes device operation duration. PropDuration // PropFanSpeed describes fan speed. PropFanSpeed // PropPicture describes camera's current picture. PropPicture // PropDistance describes distance. PropDistance // PropUser describes user name. PropUser // PropDescription describes generic text description. PropDescription )
func PropertyString ¶
PropertyString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func PropertyValues ¶
func PropertyValues() []Property
PropertyValues returns all values of the enum
func (Property) GetPropertyName ¶
GetPropertyName returns actual property name.
func (Property) IsAProperty ¶
IsAProperty returns "true" if the value is listed in the enum definition. "false" otherwise
func (Property) IsPropertyAllowed ¶
func (i Property) IsPropertyAllowed(deviceType DeviceType) bool
IsPropertyAllowed checks whether property is allowed to certain device type.
func (Property) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for Property
func (Property) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Property
func (Property) MarshalYAML ¶
MarshalYAML implements a YAML Marshaler for Property
func (*Property) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for Property
func (*Property) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Property
func (*Property) UnmarshalYAML ¶
UnmarshalYAML implements a YAML Unmarshaler for Property
type SensorType ¶
type SensorType int
SensorType defines type of the sensor.
const ( // SenGeneric describes generic sensor. SenGeneric SensorType = iota //SenMotion describes motion sensor. SenMotion // SenTemperature describes temperature sensor. SenTemperature // SenButton describes button sensor. SenButton // SenLock describes lock sensor. SenLock // SenPresence describes presence sensor. SenPresence )
func SensorTypeString ¶
func SensorTypeString(s string) (SensorType, error)
SensorTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func SensorTypeValues ¶
func SensorTypeValues() []SensorType
SensorTypeValues returns all values of the enum
func (SensorType) IsASensorType ¶
func (i SensorType) IsASensorType() bool
IsASensorType returns "true" if the value is listed in the enum definition. "false" otherwise
func (SensorType) MarshalJSON ¶
func (i SensorType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for SensorType
func (SensorType) MarshalText ¶
func (i SensorType) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for SensorType
func (SensorType) MarshalYAML ¶
func (i SensorType) MarshalYAML() (interface{}, error)
MarshalYAML implements a YAML Marshaler for SensorType
func (SensorType) String ¶
func (i SensorType) String() string
func (*SensorType) UnmarshalJSON ¶
func (i *SensorType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for SensorType
func (*SensorType) UnmarshalText ¶
func (i *SensorType) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for SensorType
func (*SensorType) UnmarshalYAML ¶
func (i *SensorType) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements a YAML Unmarshaler for SensorType
type UOM ¶
type UOM int
UOM defines units of measure.
func UOMString ¶
UOMString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func (UOM) IsAUOM ¶
IsAUOM returns "true" if the value is listed in the enum definition. "false" otherwise
func (UOM) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for UOM
func (UOM) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for UOM
func (UOM) MarshalYAML ¶
MarshalYAML implements a YAML Marshaler for UOM
func (*UOM) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for UOM
func (*UOM) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for UOM
func (*UOM) UnmarshalYAML ¶
UnmarshalYAML implements a YAML Unmarshaler for UOM
type VacStatus ¶
type VacStatus int
VacStatus defines Vacuum device status.
const ( // VacUnknown describes unknown status. VacUnknown VacStatus = iota // VacCleaning describes a vacuum in a cleaning stage. VacCleaning // VacPaused describes a vacuum in a paused state. VacPaused // VacDocked describes a vacuum in a docked/docking state. VacDocked // VacCharging describes a vacuum in a charging state. VacCharging // VacFull describes a vacuum in a full state. VacFull )
func VacStatusString ¶
VacStatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func VacStatusValues ¶
func VacStatusValues() []VacStatus
VacStatusValues returns all values of the enum
func (VacStatus) IsAVacStatus ¶
IsAVacStatus returns "true" if the value is listed in the enum definition. "false" otherwise
func (VacStatus) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface for VacStatus
func (VacStatus) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for VacStatus
func (VacStatus) MarshalYAML ¶
MarshalYAML implements a YAML Marshaler for VacStatus
func (*VacStatus) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for VacStatus
func (*VacStatus) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for VacStatus
func (*VacStatus) UnmarshalYAML ¶
UnmarshalYAML implements a YAML Unmarshaler for VacStatus