enums

package
v0.0.0-...-8f3712b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package enums contains various enumerations and rules for device plugins.

Index

Constants

This section is empty.

Variables

View Source
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.

AllowedProperties contains set of all possible allowed properties per device type.

Functions

func SliceContainsCommand

func SliceContainsCommand(s []Command, e Command) bool

SliceContainsCommand checks whether slice contains certain command.

func SliceContainsDeviceType

func SliceContainsDeviceType(s []DeviceType, e DeviceType) bool

SliceContainsDeviceType is a helper Slice.contains.

func SliceContainsProperty

func SliceContainsProperty(s []Property, e Property) bool

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

func CommandString(s string) (Command, error)

CommandString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func CommandValues

func CommandValues() []Command

CommandValues returns all values of the enum

func (Command) GetCommandMethodName

func (i Command) GetCommandMethodName() string

GetCommandMethodName transforms string representation of the command into actual method name.

func (Command) IsACommand

func (i Command) IsACommand() bool

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

func (i Command) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Command

func (Command) MarshalText

func (i Command) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Command

func (Command) MarshalYAML

func (i Command) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for Command

func (Command) String

func (i Command) String() string

func (*Command) UnmarshalJSON

func (i *Command) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Command

func (*Command) UnmarshalText

func (i *Command) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Command

func (*Command) UnmarshalYAML

func (i *Command) UnmarshalYAML(unmarshal func(interface{}) error) error

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

func PropertyString(s string) (Property, error)

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

func (i Property) GetPropertyName() string

GetPropertyName returns actual property name.

func (Property) IsAProperty

func (i Property) IsAProperty() bool

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

func (i Property) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Property

func (Property) MarshalText

func (i Property) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Property

func (Property) MarshalYAML

func (i Property) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for Property

func (Property) String

func (i Property) String() string

func (*Property) UnmarshalJSON

func (i *Property) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Property

func (*Property) UnmarshalText

func (i *Property) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Property

func (*Property) UnmarshalYAML

func (i *Property) UnmarshalYAML(unmarshal func(interface{}) error) error

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.

const (
	// UOMImperial defines imperial system.
	UOMImperial UOM = iota
	// UOMMetric defines metric system.
	UOMMetric
)

func UOMString

func UOMString(s string) (UOM, error)

UOMString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UOMValues

func UOMValues() []UOM

UOMValues returns all values of the enum

func (UOM) IsAUOM

func (i UOM) IsAUOM() bool

IsAUOM returns "true" if the value is listed in the enum definition. "false" otherwise

func (UOM) MarshalJSON

func (i UOM) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for UOM

func (UOM) MarshalText

func (i UOM) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for UOM

func (UOM) MarshalYAML

func (i UOM) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for UOM

func (UOM) String

func (i UOM) String() string

func (*UOM) UnmarshalJSON

func (i *UOM) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for UOM

func (*UOM) UnmarshalText

func (i *UOM) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for UOM

func (*UOM) UnmarshalYAML

func (i *UOM) UnmarshalYAML(unmarshal func(interface{}) error) error

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

func VacStatusString(s string) (VacStatus, error)

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

func (i VacStatus) IsAVacStatus() bool

IsAVacStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (VacStatus) MarshalJSON

func (i VacStatus) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for VacStatus

func (VacStatus) MarshalText

func (i VacStatus) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for VacStatus

func (VacStatus) MarshalYAML

func (i VacStatus) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for VacStatus

func (VacStatus) String

func (i VacStatus) String() string

func (*VacStatus) UnmarshalJSON

func (i *VacStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for VacStatus

func (*VacStatus) UnmarshalText

func (i *VacStatus) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for VacStatus

func (*VacStatus) UnmarshalYAML

func (i *VacStatus) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for VacStatus

Jump to

Keyboard shortcuts

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