Documentation ¶
Index ¶
- Variables
- type Action
- type Client
- func (c *Client) CreateAPIKey(ctx context.Context, reqType *CreateAPIKeyRequest) (string, error)
- func (c *Client) CreateGroup(ctx context.Context, req *CreateGroupRequest) (int, error)
- func (c *Client) DeleteAPIKey(ctx context.Context, keyToDelete string) error
- func (c *Client) DeleteGroup(ctx context.Context, id int) error
- func (c *Client) DeleteLight(ctx context.Context, id string) error
- func (c *Client) DeleteLightGroups(ctx context.Context, id string) error
- func (c *Client) DeleteLightScenes(ctx context.Context, id string) error
- func (c *Client) DeleteSensor(ctx context.Context, id string) error
- func (c *Client) GetGatewayState(ctx context.Context) (*GatewayState, error)
- func (c *Client) GetGroup(ctx context.Context, id int) (*Group, error)
- func (c *Client) GetGroups(ctx context.Context) (*GetGroupsResponse, error)
- func (c *Client) GetLight(ctx context.Context, id string) (*Light, error)
- func (c *Client) GetLights(ctx context.Context) (GetLightsResponse, error)
- func (c *Client) GetSensor(ctx context.Context, id string) (*Sensor, error)
- func (c *Client) GetSensors(ctx context.Context) (GetSensorsResponse, error)
- func (c *Client) SetGroupConfig(ctx context.Context, id int, newConfig *SetGroupConfigRequest) error
- func (c *Client) SetGroupState(ctx context.Context, id int, newState *SetGroupStateRequest) error
- func (c *Client) SetGroupStateFromJSON(ctx context.Context, id int, json string) error
- func (c *Client) SetLightConfig(ctx context.Context, id string, newConfig *SetLightConfigRequest) error
- func (c *Client) SetLightState(ctx context.Context, id string, newState *SetLightStateRequest) error
- func (c *Client) SetSensor(ctx context.Context, id string, newConfig *SetSensorRequest) error
- func (c *Client) SetSensorConfig(ctx context.Context, id string, newConfig *SetSensorConfigRequest) error
- func (c *Client) SetSensorState(ctx context.Context, id string, newState *SetSensorStateRequest) error
- type CreateAPIKeyRequest
- type CreateGroupRequest
- type EmptyRequest
- type GatewayState
- type GetGatewayResponse
- type GetGroupsResponse
- type GetLightsResponse
- type GetSensorsResponse
- type Group
- type GroupState
- type Light
- type LightState
- type Response
- type ResponseEntry
- type ResponseError
- type Sensor
- type SensorConfig
- type SensorMetadata
- type SensorState
- type SetConfigRequest
- type SetGroupConfigRequest
- type SetGroupStateRequest
- type SetLightConfigRequest
- type SetLightStateRequest
- type SetSensorConfigRequest
- type SetSensorRequest
- type SetSensorStateRequest
- type SoftwareUpdateState
- type WebsocketUpdate
- type WebsocketUpdateMetadata
- type ZGPSwitch
- type ZHAAlarm
- type ZHACarbonMonoxide
- type ZHAConsumption
- type ZHAFire
- type ZHAHumidity
- type ZHALightLevel
- type ZHAOpenClose
- type ZHAPower
- type ZHAPresence
- type ZHAPressure
- type ZHASwitch
- type ZHATemperature
- type ZHAThermostat
- type ZHAVibration
- type ZHAWater
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMalformedResponse is returned if the deconz response JSON isn't formatted as expected ErrMalformedResponse = errors.New("malformed deconz response") )
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { On *bool `json:"on"` Brightness int `json:"bri"` Hue *int `json:"hue"` Saturation *int `json:"sat"` ColourTemperature int `json:"ct"` XY *[]float64 `json:"xy"` Effect *string `json:"effect"` }
Action represents a state change which has occurred
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a handle to the deconz API
func (*Client) CreateAPIKey ¶
CreateAPIKey attempts to generate an API key to use for subequent operations. The username is optional - if not specified a random string will be generated.
func (*Client) CreateGroup ¶
CreateGroup creates a new group on the gateway. The new ID is returned on success.
func (*Client) DeleteAPIKey ¶
DeleteAPIKey is used to delete the specified API key.
func (*Client) DeleteGroup ¶
DeleteGroup removes the specified group from the gateway
func (*Client) DeleteLight ¶
DeleteLight removes the specified light from the gateway
func (*Client) DeleteLightGroups ¶
DeleteLightGroups removes the light from all its groups
func (*Client) DeleteLightScenes ¶
DeleteLightScenes removes the light from all its scenes
func (*Client) DeleteSensor ¶
DeleteSensor removes the specified sensor from the gateway
func (*Client) GetGatewayState ¶
func (c *Client) GetGatewayState(ctx context.Context) (*GatewayState, error)
GetGatewayState collects the current state from the gateway and returns it
func (*Client) GetGroups ¶
func (c *Client) GetGroups(ctx context.Context) (*GetGroupsResponse, error)
GetGroups retrieves all the groups available on the gatway
func (*Client) GetLights ¶
func (c *Client) GetLights(ctx context.Context) (GetLightsResponse, error)
GetLights retrieves all the lights available on the gatway
func (*Client) GetSensors ¶
func (c *Client) GetSensors(ctx context.Context) (GetSensorsResponse, error)
GetSensors retrieves all the sensors available on the gatway
func (*Client) SetGroupConfig ¶
func (c *Client) SetGroupConfig(ctx context.Context, id int, newConfig *SetGroupConfigRequest) error
SetGroupConfig specifies the new config of a group
func (*Client) SetGroupState ¶
SetGroupState specifies the new state of a group
func (*Client) SetGroupStateFromJSON ¶
func (*Client) SetLightConfig ¶
func (c *Client) SetLightConfig(ctx context.Context, id string, newConfig *SetLightConfigRequest) error
SetLightConfig specifies the new config of a light
func (*Client) SetLightState ¶
func (c *Client) SetLightState(ctx context.Context, id string, newState *SetLightStateRequest) error
SetLightState specifies the new state of a light
func (*Client) SetSensorConfig ¶
func (c *Client) SetSensorConfig(ctx context.Context, id string, newConfig *SetSensorConfigRequest) error
SetSensorConfig specifies the new config of a sensor
func (*Client) SetSensorState ¶
func (c *Client) SetSensorState(ctx context.Context, id string, newState *SetSensorStateRequest) error
SetSensorState specifies the new state of a sensor
type CreateAPIKeyRequest ¶
type CreateAPIKeyRequest struct { ApplicationName string `json:"devicetype"` Username string `json:"username,omitempty"` }
CreateAPIKeyRequest contains the fields which will be used to request an API key.
type CreateGroupRequest ¶
type CreateGroupRequest struct {
Name string `json:"name"`
}
CreateGroupRequest is used to create a new group with the specified name.
type EmptyRequest ¶
type EmptyRequest struct { }
EmptyRequest is a placeholder struct used for any request which has no parameters.
type GatewayState ¶
type GatewayState struct { APIVersion string `json:"apiversion"` SoftwareVersion string `json:"swversion"` SoftwareUpdateState SoftwareUpdateState `json:"swupdate"` MACAddress string `json:"mac"` ZigbeeChannel int `json:"zigbeechannel"` ZigbeePANID int `json:"panid"` GatewayID string `json:"uuid"` WebsocketNotifyAll bool `json:"websocketnotifyall"` WebsocketPort int `json:"websocketport"` LinkButtonPressed bool `json:"linkbutton"` Name string `json:"name"` LocalTime string `json:"localtime"` UTCTime string `json:"utc"` TimeFormat string `json:"timeformat"` Timezone string `json:"timezone"` UsingDHCP bool `json:"dhcp"` GatewayIP string `json:"gateway"` IP string `json:"ipaddress"` Netmask string `json:"netmask"` }
GatewayState contains the current state of the gateway
type GetGatewayResponse ¶
type GetGatewayResponse struct { GatewayState GatewayState `json:"config"` //Groups map[string]Group `json:"groups` Lights GetLightsResponse `json:"lights"` // Rules map[string]Rule `json:"rules"` // Schedules map[string]Schedule `json:"schedules"` Sensors map[int]Sensor `json:"sensors"` }
GetGatewayResponse contains the returned data from the full gateway API call
type GetGroupsResponse ¶
GetGroupsResponse contains the fields returned by the 'list groups' API call
type GetLightsResponse ¶
GetLightsResponse contains the result of all active lights.
type GetSensorsResponse ¶
GetSensorsResponse contains the set of sensors in the gateway
type Group ¶
type Group struct { LastAction Action `json:"action"` DeviceIDs []string `json:"devicemembership"` ETag string `json:"etag"` Hidden bool `json:"hidden"` ID string `json:"id"` // LightIDs contains a gateway-sorted list of all the light IDs in this group LightIDs []string `json:"lights"` // LightIDSequence contains a user-sorted list of a subset of all the light IDs in this group LightIDSequence []string `json:"lightsequence"` // MultiDeviceIDs contains the subsequent IDs of multi-device lights MultiDeviceIDs []string `json:"multideviceids"` Name string `json:"name"` Scenes []struct { ID string `json:"id"` Name string `json:"name"` TransitionTime int `json:"transitiontime"` LightCount int `json:"lightcount"` } `json:"scenes"` State GroupState `json:"state"` }
Group represents a collection of lights and provides the foundation for scenes
type GroupState ¶
GroupState contains the fields relevant to the state of a group
type Light ¶
type Light struct { // ID contains the gateway-specified ID; could change. // Exists only for accessing by path; dedup using UniqueID instead ID string CTMax int `json:"ctmax"` CTMin int `json:"ctmin"` LastAnnounced string `json:"lastannounced"` LastSeen string `json:"lastseen"` ETag string `json:"etag"` Manufacturer string `json:"manufacturer"` Name string `json:"name"` ModelID string `json:"modelid"` SoftwareVersion string `json:"swversion"` Type string `json:"type"` State LightState `json:"state"` UniqueID string `json:"uniqueid"` }
Light contains the fields of a light.
type LightState ¶
type ResponseEntry ¶
type ResponseEntry struct { Success map[string]interface{} `json:"success"` Error ResponseError `json:"error"` }
ResponseEntry is one of the multiple response entries returned by the API
type ResponseError ¶
type ResponseError struct { Type int `json:"type"` Address string `json:"address"` Description string `json:"description"` }
ResponseError contains a general error which was detected.
func (ResponseError) Error ¶
func (re ResponseError) Error() string
Error allows the response error to be returned as an Error compatible type.
type Sensor ¶
type Sensor struct { SensorMetadata AlarmState *ZHAAlarm CarbonMonoxideState *ZHACarbonMonoxide ConsumptionState *ZHAConsumption FireState *ZHAFire HumidityState *ZHAHumidity LightLevelState *ZHALightLevel OpenCloseState *ZHAOpenClose PowerState *ZHAPower PresenceState *ZHAPresence SwitchState *ZHASwitch PressureState *ZHAPressure TemperatureState *ZHATemperature ThermostatState *ZHAThermostat VibrationState *ZHAVibration WaterState *ZHAWater ButtonState *ZGPSwitch }
Sensor represents a generic sensor in a Zigbee network
func (*Sensor) UnmarshalJSON ¶
UnmarshalJSON is a custom unmarshaler for the State object
type SensorConfig ¶
type SensorConfig struct { On bool `json:"on"` Reachable bool `json:"reachable"` BatteryLevel int `json:"battery"` }
SensorConfig contains the settable properties of a sensor
type SensorMetadata ¶
type SensorMetadata struct { ID int `json:"ep"` Config SensorConfig `json:"config"` ETag string `json:"etag"` ManufacturerName string `json:"manufacturername"` ModelID string `json:"modelid"` Mode int `json:"mode"` Name string `json:"name"` SoftwareVersion string `json:"swversion"` Type string `json:"type"` UniqueID string `json:"uniqueid"` StateRaw json.RawMessage `json:"state"` }
SensorMetadata contains a bunch of fields about all sensors
type SensorState ¶
type SensorState struct { LastUpdated string `json:"lastupdated"` LowBattery bool `json:"lowbattery"` Tampered bool `json:"tampered"` Alarm bool `json:"alarm"` CarbonMonoxide bool `json:"carbonmonoxide"` Consumption int `json:"consumption"` Power int `json:"power"` Fire bool `json:"fire"` Humidity int `json:"humidity"` Lux int `json:"lux"` LightLevel int `json:"lightlevel"` Dark bool `json:"dark"` Daylight bool `json:"daylight"` Open bool `json:"open"` Current int `json:"current"` Voltage int `json:"voltage"` Presence bool `json:"presence"` ButtonEvent int `json:"buttonevent"` Gesture int `json:"gesture"` EventDuration int `json:"eventduration"` X int `json:"x"` Y int `json:"y"` Angle int `json:"angle"` Pressure int `json:"pressure"` Temperature int `json:"temperature"` Valve int `json:"valve"` WindowOpen string `json:"windowopen"` }
SensorState contains the reported, immutable properties of a sensor. This is a generic type which contains state for all possible Zigbee sensors. Specific sensor types are subclassed and exposed with only their relevant fields.
type SetConfigRequest ¶
type SetConfigRequest struct { Name string `json:"name,omitempty"` RFConnected bool `json:"rfconnected,omitempty"` // UpdateChannel can be set to one of stable, alpha, beta UpdateChannel string `json:"updatechannel,omitempty"` // PermitJoin when set to 0 indicates no Zigbee devices can join // 255 means the network is open // 1..254 represents the time in seconds the network will be open // These values decrement automatically PermitJoin int `json:"permitjoin,omitempty"` // GroupDelay contains the time between two group commands, in milliseconds GroupDelay int `json:"groupdelay,omitempty"` OTAUActive bool `json:"otauactive,omitempty"` GWDiscoveryActive bool `json:"discovery,omitempty"` // Unlock being set to a value > 0 (and less than 600, the max) indicates the number of seconds the gateway is open for pairing Unlock int `json:"unlock,omitempty"` // ZigbeeChannel specifies one of 11, 15, 20 or 25 (the valid Zigbee channel numbers) ZigbeeChannel int `json:"zigbeechannel,omitempty"` Timezone string `json:"timezone,omitempty"` UTC string `json:"utc,omitempty"` // TimeFormat is specified as either 12h or 24h TimeFormat string `json:"timeformat,omitempty"` }
SetConfigRequest contains the set of possible gateway configuration parameters.
type SetGroupConfigRequest ¶
type SetGroupConfigRequest struct { Name string `json:"name,omitempty"` LightIDs []string `json:"lights,omitempty"` Hidden bool `json:"hidden,omitempty"` LightIDSequence []string `json:"lightsequence,omitempty"` MultiDeviceIDs []string `json:"multideviceids,omitempty"` }
SetGroupConfigRequest sets the config options of the group
type SetGroupStateRequest ¶
type SetGroupStateRequest struct { SetLightStateRequest // Toggle flips the state from on to off or vice versa. // This superscedes the values set directly. Toggle bool `json:"toggle,omitempty"` }
SetGroupStateRequest sets the state of the specified group.
type SetLightConfigRequest ¶
type SetLightConfigRequest struct {
Name string `json:"name,omitempty"`
}
SetLightConfigRequest lets a user update certain properties of the light. This is metadata and not directly changing the light behaviour.
type SetLightStateRequest ¶
type SetLightStateRequest struct { On *bool `json:"on,omitempty"` Brightness int `json:"bri,omitempty"` Hue *int `json:"hue,omitempty"` Saturation *int `json:"sat,omitempty"` CT int `json:"ct,omitempty"` XY *[]float64 `json:"xy,omitempty"` Alert *string `json:"alert,omitempty"` // Effect contains the light effect to apply. Either 'none' or 'colorloop' Effect *string `json:"effect,omitempty"` // ColorLoopSpeed contains the speed of a colorloop. // 1 is very fast, 255 is very slow. // This is only read if the 'colorloop' effect is specifed ColorLoopSpeed *int `json:"colorloopspeed,omitempty"` // TransitionTime is represented in 1/10th of a second between states TransitionTime *int `json:"transitiontime,omitempty"` }
SetLightStateRequest lets a user update certain properties of the light. These are directly changing the active light and what it is showing.
type SetSensorConfigRequest ¶
type SetSensorConfigRequest SensorConfig
SetSensorConfigRequest contains the fields of a sensor which can be changed.
type SetSensorRequest ¶
type SetSensorRequest struct { Name string `json:"name,omitempty"` // Mode is only available for dresden elektronik Lighting Switches // 1 represents Scene mode // 2 represents two-groups mode // 3 represents colour temperature mode Mode int `json:"mode,omitempty"` }
SetSensorRequest allows for specific parts of a sensor to be changed
type SetSensorStateRequest ¶
type SetSensorStateRequest struct { // ButtonEvent is settable for CLIPSwitch type ButtonEvent int `json:"buttonevent,omitempty"` // Open is settable for CLIPOpenClose Open bool `json:"open,omitempty"` // Presence is settable for CLIPPresence Presence bool `json:"presence,omitempty"` // Temperature is settable for CLIPTemperature Temperature int `json:"temperature,omitempty"` // Flag is settable for CLIPGenericFlag Flag bool `json:"flag,omitempty"` // Status is settable for CLIPGenericStatus Status int `json:"status,omitempty"` // Humidity is settable for CLIPHumidity Humidity int `json:"humidity,omitempty"` }
SetSensorStateRequest contains the relevant properties which can be set.
type SoftwareUpdateState ¶
type SoftwareUpdateState struct { Notify bool `json:"notify"` Text string `json:"text"` UpdateState int `json:"updatestate"` URL string `json:"url"` }
SoftwareUpdateState contains the important data about the current software update profile of the gateway
type WebsocketUpdate ¶
type WebsocketUpdate struct { Meta WebsocketUpdateMetadata // These are conditionally filled in by parsing the State json.RawMessage field GroupState *GroupState LightState *LightState SensorState *SensorState // These are conditionally filled in by parsing the relevant json.RawMessage field Group *Group Light *Light Sensor *Sensor }
WebsocketUpdate contains the data deserialized from the async channel
func (*WebsocketUpdate) UnmarshalJSON ¶
func (wsu *WebsocketUpdate) UnmarshalJSON(b []byte) error
UnmarshalJSON allows us to conditionally deserialize the websocket update so that only the relevant fields are available.
type WebsocketUpdateMetadata ¶
type WebsocketUpdateMetadata struct { Type string `json:"t"` Event string `json:"e"` Resource string `json:"r"` ResourceID string `json:"id"` UniqueID string `json:"uniqueid"` // The following are set on `changed` events Config json.RawMessage `json:"config"` Name string `json:"name"` State json.RawMessage `json:"state"` // The following fields are only set on `scene-called` events GroupID string `json:"gid"` SceneID string `json:"scid"` // The following fields are set on the `added` event for the relevant resource type Group json.RawMessage `json:"group"` Light json.RawMessage `json:"light"` Sensor json.RawMessage `json:"sensor"` }
WebsocketUpdateMetadata contains the common metadata fields about the update.
type ZGPSwitch ¶
type ZGPSwitch struct { ButtonEvent int `json:"buttonevent"` LastUpdated string `json:"lastupdated"` }
ZGPSwitch represents a Zigbee general button event
type ZHAAlarm ¶
type ZHAAlarm struct { Alarm bool `json:"alarm"` LastUpdated string `json:"lastupdated"` LowBattery bool `json:"lowbattery"` Tampered bool `json:"tampered"` }
ZHAAlarm represents a Zigbee Home Automation Alarm
type ZHACarbonMonoxide ¶
type ZHACarbonMonoxide struct { CarbonMonoxide bool `json:"carbonmonoxide"` LastUpdated string `json:"lastupdated"` LowBattery bool `json:"lowbattery"` Tampered bool `json:"tampered"` }
ZHACarbonMonoxide represents a Zigbee Home Automation Carbon Monoxide detector
type ZHAConsumption ¶
type ZHAConsumption struct { Consumption int `json:"consumption"` LastUpdated string `json:"lastupdated"` Power int `json:"power"` }
ZHAConsumption represents a Zigbee Home Automation consumption monitor
type ZHAFire ¶
type ZHAFire struct { Fire bool `json:"fire"` LastUpdated string `json:"lastupdated"` LowBattery bool `json:"lowbattery"` Tampered bool `json:"tampered"` }
ZHAFire represents a Zigbee Home Automation fire detector
type ZHAHumidity ¶
ZHAHumidity represents a Zigbee Home Automation humidity monitor
type ZHALightLevel ¶
type ZHALightLevel struct { Lux int `json:"lux"` LastUpdated string `json:"lastupdated"` LightLevel int `json:"lightlevel"` Dark bool `json:"dark"` Daylight bool `json:"daylight"` }
ZHALightLevel represents a Zigbee Home Automation light level sensor
type ZHAOpenClose ¶
ZHAOpenClose represents an open/close sensor
type ZHAPower ¶
type ZHAPower struct { Current int `json:"current"` LastUpdated string `json:"lastupdated"` Power int `json:"power"` Voltage int `json:"voltage"` }
ZHAPower represents a Zigbee power monitor
type ZHAPresence ¶
ZHAPresence represents a Zigbee presence monitor
type ZHAPressure ¶
ZHAPressure represents a Zigbee pressure monitor
type ZHASwitch ¶
type ZHASwitch struct { ButtonEvent int `json:"buttonevent"` LastUpdated string `json:"lastupdated"` Gesture int `json:"gesture"` EventDuration int `json:"eventduration"` X int `json:"x"` Y int `json:"y"` Angle int `json:"angle"` }
ZHASwitch represents a Zigbee switch
type ZHATemperature ¶
type ZHATemperature struct { Temperature int `json:"temperature"` LastUpdated string `json:"lastupdated"` }
ZHATemperature represents a Zigbee temperature sensor
type ZHAThermostat ¶
type ZHAThermostat struct { On bool `json:"on"` LastUpdated string `json:"lastupdated"` Temperature int `json:"temperature"` Valve int `json:"valve"` WindowOpen string `json:"windowopen"` }
ZHAThermostat represents a Zigbee thermostat
type ZHAVibration ¶
type ZHAVibration struct { Vibration bool `json:"vibration"` LastUpdated string `json:"lastupdated"` OrientationX int `json:"orientation_x"` OrientationY int `json:"orientation_y"` OrientationZ int `json:"orientation_z"` TiltAngle int `json:"tiltangle"` VibrationStrength int `json:"vibrationstrength"` }
ZHAVibration represents a Zigbee vibration sensor