feature

package
v0.0.0-...-0896cb3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
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"
)
View Source
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"
)
View Source
const (
	// ButtonStateLocalID is the local ID for the state attribute such as pressed/released
	ButtonStateLocalID string = "state"
)
View Source
const (
	// OutletOnOffLocalID is the local ID of the onoff attribute
	OutletOnOffLocalID string = "onoff"
)
View Source
const (
	// SwitchOnOffLocalID is the local ID of the onoff attribute
	SwitchOnOffLocalID string = "onoff"
)

Variables

This section is empty.

Functions

func ButtonCloneAttrs

func ButtonCloneAttrs(f *Feature) (state *attr.Attribute)

ButtonCloneAttrs clones the common attributes for a button so they can be updated

func HeatZoneCloneAttrs

func HeatZoneCloneAttrs(f *Feature) (current, target *attr.Attribute)

HeatZoneCloneAttrs clone the common attributes for a heat zone so they can be updated

func LightZoneCloneAttrs

func LightZoneCloneAttrs(f *Feature) (onoff, brightness, hsl *attr.Attribute)

LightZoneCloneAttrs clone the common attributes for a light zone so they can be updated

func LightZoneGetBrightness

func LightZoneGetBrightness(attrs map[string]*attr.Attribute) (float32, error)

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

func OutletCloneAttrs(f *Feature) (onOff *attr.Attribute)

OutletCloneAttrs clone the common attributes for an Outlet so they can be updated

func SwitchCloneAttrs

func SwitchCloneAttrs(f *Feature) (onOff *attr.Attribute)

SwitchCloneAttrs clone the common attributes for a switch so they can be updated

func WindowTreatmentCloneAttrs

func WindowTreatmentCloneAttrs(f *Feature) (openClose, offset *attr.Attribute)

WindowTreatmentCloneAttrs clone the common attributes for a window treatment so they can be updated

func WindowTreatmentGetOffset

func WindowTreatmentGetOffset(attrs map[string]*attr.Attribute) (float32, error)

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 Attrs

type Attrs map[string]*attr.Attribute

Attrs a map of attributes, keyed by the attributes local ID

func NewAttrs

func NewAttrs(attrs ...*attr.Attribute) Attrs

NewAttrs returns a map of attributes keyed by the LocalID field

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 NewButton

func NewButton(ID string) *Feature

NewButton returns a new button instance

func NewFromType

func NewFromType(ID, fType string) *Feature

NewFromType returns a new feature instance based on the speicifed feature type passed in to the function

func NewHeatZone

func NewHeatZone(ID string) *Feature

NewHeatZone returns a featuer instance initialized as a heat zone. Heat Zones represents zones on a thermostat that can provide heat

func NewLightZone

func NewLightZone(ID, mode string) *Feature

NewLightZone returns a feature initialized as a LightZone. A Light zone represents a single or multiple bulbs

func NewOutlet

func NewOutlet(ID string) *Feature

NewOutlet returns a new feature initialized as an outlet. An outlet is a plug socket that can be turned on or off

func NewSensor

func NewSensor(ID string, attribute *attr.Attribute) *Feature

NewSensor returns a feature instance initialized as a Sensor

func NewSwitch

func NewSwitch(ID string) *Feature

NewSwitch returns a new feature initialized as a Switch feature. Switches can be turned on and off

func NewWindowTreatment

func NewWindowTreatment(ID string) *Feature

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) String

func (f *Feature) String() string

String returns a debug string for the feature

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

Jump to

Keyboard shortcuts

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