Documentation
¶
Index ¶
- Constants
- func ButtonCloneAttrs(f *Feature) (state *attr.Attribute)
- func HeatZoneCloneAttrs(f *Feature) (current, target *attr.Attribute)
- func LightZoneCloneAttrs(f *Feature) (onoff, brightness, hsl *attr.Attribute)
- func LightZoneGetBrightness(attrs map[string]*attr.Attribute) (float32, error)
- func OutletCloneAttrs(f *Feature) (onOff *attr.Attribute)
- func SwitchCloneAttrs(f *Feature) (onOff *attr.Attribute)
- func WindowTreatmentCloneAttrs(f *Feature) (openClose, offset *attr.Attribute)
- func WindowTreatmentGetOffset(attrs map[string]*attr.Attribute) (float32, error)
- type Attrs
- type Feature
- func NewButton(ID string) *Feature
- func NewFromType(ID, fType string) *Feature
- func NewHeatZone(ID string) *Feature
- func NewLightZone(ID, mode string) *Feature
- func NewOutlet(ID string) *Feature
- func NewSensor(ID string, attribute *attr.Attribute) *Feature
- func NewSwitch(ID string) *Feature
- func NewWindowTreatment(ID string) *Feature
Constants ¶
const ( // FTButton button, can be phycial or virtual FTButton string = "Button" // FTCoolZone cooling zone FTCoolZone string = "CoolZone" // FTHeatZone heating zone FTHeatZone string = "HeatZone" // FTLightZone lighting zone FTLightZone string = "LightZone" // FTOutlet outlet FTOutlet string = "Outlet" // FTSensor sensor FTSensor string = "Sensor" // FTSwitch switch FTSwitch string = "Switch" // FTWindowTreatment window treatment such as a shade or curtain FTWindowTreatment string = "WindowTreatment" )
const ( // HeatZoneCurrentTempLocalID is the localID value for the current temp attribute HeatZoneCurrentTempLocalID string = "currenttemp" // HeatZoneTargetTempLocalID is the localID value for the target temp attribute HeatZoneTargetTempLocalID string = "targettemp" )
const ( // LightZoneOnOffLocalID is the local ID for the onoff attribute LightZoneOnOffLocalID string = "onoff" // LightZoneBrightnessLocalID is the local ID for the brightness attribute LightZoneBrightnessLocalID string = "brightness" // LightZoneHSLLocalID is the local ID for the HSL attribute LightZoneHSLLocalID string = "hsl" // LightZoneModeBinary indicates the light can only be in either an on or off // state, nothing inbetween i.e. not dimmable LightZoneModeBinary = "binary" // LightZoneModeContinuous indicates the light can be dimmed LightZoneModeContinuous = "continuous" // LightZoneModeHSL indicates the light supports different colours mapped to // values in the HSL color space LightZoneModeHSL = "hsl" )
const ( // WindowTreatmentOffsetLocalID is the local ID of the offset attribute WindowTreatmentOffsetLocalID string = "offset" // WindowTreatmentOpenCloseLocalID is the local ID of the openclose attribute WindowTreatmentOpenCloseLocalID string = "openclose" )
const ( // ButtonStateLocalID is the local ID for the state attribute such as pressed/released ButtonStateLocalID string = "state" )
const ( // OutletOnOffLocalID is the local ID of the onoff attribute OutletOnOffLocalID string = "onoff" )
const ( // SwitchOnOffLocalID is the local ID of the onoff attribute SwitchOnOffLocalID string = "onoff" )
Variables ¶
This section is empty.
Functions ¶
func ButtonCloneAttrs ¶
ButtonCloneAttrs clones the common attributes for a button so they can be updated
func HeatZoneCloneAttrs ¶
HeatZoneCloneAttrs clone the common attributes for a heat zone so they can be updated
func LightZoneCloneAttrs ¶
LightZoneCloneAttrs clone the common attributes for a light zone so they can be updated
func LightZoneGetBrightness ¶
LightZoneGetBrightness returns the brightness the light should be set to. It takes in to account if you have an onoff and brightness attribute or just a brightness attribute
func OutletCloneAttrs ¶
OutletCloneAttrs clone the common attributes for an Outlet so they can be updated
func SwitchCloneAttrs ¶
SwitchCloneAttrs clone the common attributes for a switch so they can be updated
func WindowTreatmentCloneAttrs ¶
WindowTreatmentCloneAttrs clone the common attributes for a window treatment so they can be updated
func WindowTreatmentGetOffset ¶
WindowTreatmentGetOffset returns the desired offset, taking into account the open/close value if it is present in the attributes. So if openclose is closed even if there is a offset value it is ignored.
Types ¶
type Feature ¶
type Feature struct { // ID a globally unique ID for the feature ID string `json:"id"` // Type represents a concrete type for the feature e.g. LightZone, Outlet etc. Type string `json:"type"` // AutomationID is a more user friendly automation ID, that can be any value the user // wants to reference a feature in an automation script, vs the ID attribute that is // an unfriendly GUID AutomationID string `json:"aid"` // Address an optional address to identify the feature locally Address string `json:"address"` // Name a user friendly name that may be displayed in the UI Name string `json:"name"` // Description more details about the feature which may be shown in the UI Description string `json:"description"` // DeviceID is the ID of the device that owns the feature DeviceID string `json:"deviceId"` // Attrs is a map of attributes, keyed by the attributes LocalID field Attrs Attrs `json:"attrs"` //TODO: Remove - don't use, only for API serialization purposes IsDupe bool `json:"isDupe"` }
Feature represents a unit of functionality that a device may provide, such as a button, sensor, switch etc. Devices can potentially export many features.
func NewFromType ¶
NewFromType returns a new feature instance based on the speicifed feature type passed in to the function
func NewHeatZone ¶
NewHeatZone returns a featuer instance initialized as a heat zone. Heat Zones represents zones on a thermostat that can provide heat
func NewLightZone ¶
NewLightZone returns a feature initialized as a LightZone. A Light zone represents a single or multiple bulbs
func NewOutlet ¶
NewOutlet returns a new feature initialized as an outlet. An outlet is a plug socket that can be turned on or off
func NewSwitch ¶
NewSwitch returns a new feature initialized as a Switch feature. Switches can be turned on and off
func NewWindowTreatment ¶
NewWindowTreatment returns a new feature initialized as a WindowTreatment. A window treatment can be a shade or curtain or anything covering a window that can be monitored and controlled and has an offset position. An offset of 100% means the window treamtent is fully open, 0% means fully closed
func (*Feature) Validate ¶
func (f *Feature) Validate() *validation.Errors
Validate returns nil if the feature is in a valid state, otherwise a validation error is returned detailing the issues