deconz

package module
v0.0.0-...-18e4e41 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 7 Imported by: 1

README

deconz-go

A library for interfacing with the deCONZ REST API.

This library is designed to be a very basic wrapper around the API offered by the deconz REST API - it is not designed to maintain state. It simply exposes the objects and their operations in an idiomatic Go way. It provides a convenience handler for the deconz websocket to make it easy to build additional software which is maintaining a state-aware view of the gateway.

Currently implemented and tested functionality includes:

  1. All methods on the groups endpoint
  2. All methods on the lights endpoint
  3. All methods on the scenes endpoint
  4. Read methods on the sensors endpoint
  5. Some methods on the configuration endpoint
  6. The websocket endpoint

Adding support for rules, schedules and touchlink should be fairly straightforward, however this work has not yet been undertaken.

The currently supported pieces of the configuration API allow for the creation & deletion of API keys and retrieval of gateway state.

It is possible to see small CLI tools which exercise the above API endpoints in the examples/ directory.

Documentation

Index

Constants

This section is empty.

Variables

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

func NewClient(httpClient *http.Client, hostname string, port int, apiKey string) *Client

NewClient creates a new deconz API client

func (*Client) CreateAPIKey

func (c *Client) CreateAPIKey(ctx context.Context, reqType *CreateAPIKeyRequest) (string, error)

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

func (c *Client) CreateGroup(ctx context.Context, req *CreateGroupRequest) (int, error)

CreateGroup creates a new group on the gateway. The new ID is returned on success.

func (*Client) CreateScene

func (c *Client) CreateScene(ctx context.Context, groupID int, req *CreateSceneRequest) (int, error)

CreateScene creates a new scene for the specified group on the gateway. The new scene ID is returned on success.

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey(ctx context.Context, keyToDelete string) error

DeleteAPIKey is used to delete the specified API key.

func (*Client) DeleteGroup

func (c *Client) DeleteGroup(ctx context.Context, id int) error

DeleteGroup removes the specified group from the gateway

func (*Client) DeleteLight

func (c *Client) DeleteLight(ctx context.Context, id string) error

DeleteLight removes the specified light from the gateway

func (*Client) DeleteLightGroups

func (c *Client) DeleteLightGroups(ctx context.Context, id string) error

DeleteLightGroups removes the light from all its groups

func (*Client) DeleteLightScenes

func (c *Client) DeleteLightScenes(ctx context.Context, id string) error

DeleteLightScenes removes the light from all its scenes

func (*Client) DeleteScene

func (c *Client) DeleteScene(ctx context.Context, groupID, sceneID int) error

DeleteScene removes the specified scene from the gateway

func (*Client) DeleteSensor

func (c *Client) DeleteSensor(ctx context.Context, id string) error

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

func (c *Client) GetGroup(ctx context.Context, id int) (*Group, error)

GetGroup retrieves the specified group

func (*Client) GetGroups

func (c *Client) GetGroups(ctx context.Context) (*GetGroupsResponse, error)

GetGroups retrieves all the groups available on the gatway

func (*Client) GetLight

func (c *Client) GetLight(ctx context.Context, id string) (*Light, error)

GetLight retrieves the specified light

func (*Client) GetLights

func (c *Client) GetLights(ctx context.Context) (GetLightsResponse, error)

GetLights retrieves all the lights available on the gatway

func (*Client) GetScene

func (c *Client) GetScene(ctx context.Context, groupID int, sceneID int) (*Scene, error)

GetScene retrieves the specified scene in the group

func (*Client) GetScenes

func (c *Client) GetScenes(ctx context.Context, groupID int) (*GetScenesResponse, error)

GetScenes retrieves all the scenes for the specified group available on the gatway

func (*Client) GetSensor

func (c *Client) GetSensor(ctx context.Context, id string) (*Sensor, error)

GetSensor retrieves the specified sensor

func (*Client) GetSensors

func (c *Client) GetSensors(ctx context.Context) (GetSensorsResponse, error)

GetSensors retrieves all the sensors available on the gatway

func (*Client) RecallScene

func (c *Client) RecallScene(ctx context.Context, groupID, sceneID int) error

RecallScene applies the saved light state from the specified scene ID to the lights in the specified group ID. If a light is not currently on, the recall will have no effect.

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

func (c *Client) SetGroupState(ctx context.Context, id int, newState *SetGroupStateRequest) error

SetGroupState specifies the new state of a group

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

func (c *Client) SetSceneConfig(ctx context.Context, groupID, sceneID int, newConfig *SetSceneConfigRequest) error

SetSceneConfig specifies the new config of a scene in the specified group

func (*Client) SetSceneLightState

func (c *Client) SetSceneLightState(ctx context.Context, groupID, sceneID, lightID int, newState *SetSceneLightConfigRequest) error

SetSceneLightState specifies the new state of a light in the specified scene. If the light is not a member of the group the scene is linked to, this will fail.

func (*Client) SetSensor

func (c *Client) SetSensor(ctx context.Context, id string, newConfig *SetSensorRequest) error

SetSensor specifies the new options for a sensor

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

func (*Client) StoreScene

func (c *Client) StoreScene(ctx context.Context, groupID, sceneID int) error

StoreScene saves the current state of the lights in the group to the supplied scene ID

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 CreateSceneRequest

type CreateSceneRequest struct {
	Name string `json:"name"`
}

CreateSceneRequest is used to create a new scene with the specified name

type CreateScheduleRequest

type CreateScheduleRequest struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Command     ScheduleCommand `json:"command"`
	// Status must be one of "enabled" or "disabled"
	Status     string `json:"status"`
	AutoDelete bool   `json:"autodelete"`
	// Time represents when this scheduled action will occur
	// Supported formats include:
	// - a specific date (yyyy-MM-ddThh:mm:ss)
	// - a repeated date (W[0..127]/Thh:mm:ss)
	// for repeated dates, the field is a bitmask formed by 0MTWTFSS
	// For example: 01111100 = 124 is all weekdays, 00000011 = 3 is the weekend.
	// - a timer (PThh:mm:ss)
	// - a recurring timer (R[0..99]/PThh:mm:ss)
	// the number after the R is the number of repetitions of the timer. No number means infinite.
	Time string `json:"time"`
}

CreateScheduleRequest specifies the fields to create a new schedule.

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

type GetGroupsResponse map[string]Group

GetGroupsResponse contains the fields returned by the 'list groups' API call

type GetLightsResponse

type GetLightsResponse map[string]Light

GetLightsResponse contains the result of all active lights.

type GetRulesResponse

type GetRulesResponse map[string]Rule

GetRulesResponse contains the data returned by a call to list the rules.

type GetScenesResponse

type GetScenesResponse map[string]struct {
	LightIDs []string `json:"lights"`
	Name     string   `json:"name"`
}

GetScenesResponse contains a collection of scenes in a group

type GetSchedulesResponse

type GetSchedulesResponse map[string]Schedule

GetSchedulesResponse contains the set of schedules.

type GetSensorsResponse

type GetSensorsResponse map[string]Sensor

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

type GroupState struct {
	AllOn bool `json:"all_on"`
	AnyOn bool `json:"any_on"`
}

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 LightState struct {
	On         bool      `json:"on"`
	Brightness int       `json:"bri"`
	Hue        int       `json:"hue"`
	Saturation int       `json:"sat"`
	CT         int       `json:"ct"`
	XY         []float64 `json:"xy"`
	Alert      string    `json:"alert"`
	ColorMode  string    `json:"colormode"`
	Effect     string    `json:"effect"`
	Reachable  bool      `json:"reachable"`
}

LightState contains the specific, controllable fields of a light.

type Response

type Response []ResponseEntry

Response is a generic response returned by the API

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 Rule

type Rule struct {
	// ID contains the bridge-specified ID of this rule.
	ID              string
	Actions         []RuleAction    `json:"actions"`
	Conditions      []RuleCondition `json:"conditions"`
	CreatedAt       string          `json:"created"`
	ETag            string          `json:"etag"`
	LastTriggeredAt string          `json:"lasttriggered"`
	Name            string          `json:"name"`
	Owner           string          `json:"owner"`
	Periodic        int             `json:"periodic"`
	// Status can be one of "enabled", "disabled"
	Status         string `json:"status"`
	TriggeredCount int    `json:"timestriggered"`
}

Rule contains the fields of a rule

type RuleAction

type RuleAction struct {
	Address string          `json:"address,omitempty"`
	Body    json.RawMessage `json:"body,omitempty"`
	// Method can be one of PUT, POST, DELETE, BIND
	Method string `json:"method,omitempty"`
}

RuleAction contains a single action in a rule. The Body is a JSON object serialized outside this format.

type RuleCondition

type RuleCondition struct {
	Address string `json:"address,omitempty"`
	// Operator can be one of eq (equals), gt (greater than), lt (less than), dx (on change)
	Operator string `json:"operator,omitempty"`
	Value    string `json:"value,omitempty"`
}

RuleCondition contains a single condition in a rule.

type Scene

type Scene struct {
	// ID contains the bridge-specified ID of this scene.
	ID     string
	Lights []struct {
		ID             string  `json:"id"`
		IsOn           bool    `json:"on"`
		Brightness     int     `json:"bri"`
		TransitionTime int     `json:"transitiontime"`
		X              float64 `json:"x"`
		Y              float64 `json:"y"`
		CT             int     `json:"ct"`
		Hue            int     `json:"hue"`
		Saturation     int     `json:"sat"`
	} `json:"lights"`
	Name string `json:"name"`
}

Scene contains the details of a scene

type Schedule

type Schedule struct {
	// ID contains the bridge-specified ID of this schedule.
	ID          string
	AutoDelete  bool            `json:"autodelete"`
	Command     ScheduleCommand `json:"command"`
	Description string          `json:"description"`
	ETag        string          `json:"etag"`
	Name        string          `json:"name"`
	// Status is specified as one of "enabled" or "disabled"
	Status string `json:"status"`
	// Time follows the rules in the CreateScheduleRequest documentation
	Time string `json:"time"`
}

Schedule contains the fields of a single specified scheduled event.

type ScheduleCommand

type ScheduleCommand struct {
	Address string `json:"address"`
	// Method must be specified as "PUT"
	Method string          `json:"method"`
	Body   json.RawMessage `json:"body"`
}

ScheduleCommand contains the command a scheduled action will run when triggered.

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

func (s *Sensor) UnmarshalJSON(b []byte) error

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"`
	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 SetRulesRequest

type SetRulesRequest struct {
	Actions    []RuleAction    `json:"actions,omitempty"`
	Conditions []RuleCondition `json:"conditions,omitempty"`
	Name       string          `json:"name,omitempty"`
	Perodic    int             `json:"perodic,omitempty"`
	Status     string          `json:"status,omitempty"`
}

SetRulesRequest contains the fields which can be set on a rule.

type SetSceneConfigRequest

type SetSceneConfigRequest struct {
	Name string `json:"name"`
}

SetSceneConfigRequest is used to update the scene metadata

type SetSceneLightConfigRequest

type SetSceneLightConfigRequest struct {
	IsOn           bool      `json:"on"`
	Brightness     int       `json:"bri"`
	TransitionTime int       `json:"transitiontime"`
	XY             []float64 `json:"xy"`
}

SetSceneLightConfigRequest contains the fields which can be set on a single light in a scene

type SetScheduleConfigRequest

type SetScheduleConfigRequest struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Command     ScheduleCommand `json:"command"`
	Status      string          `json:"status"`
	AutoDelete  bool            `json:"autodelete"`
	Time        string          `json:"time"`
}

SetScheduleConfigRequest contains the config fields of a schedule which can be edited.

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

type ZHAHumidity struct {
	Humidity    int    `json:"humidity"`
	LastUpdated string `json:"lastupdated"`
}

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

type ZHAOpenClose struct {
	Open        bool   `json:"open"`
	LastUpdated string `json:"lastupdated"`
}

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

type ZHAPresence struct {
	Presence    bool   `json:"presence"`
	LastUpdated string `json:"lastupdated"`
}

ZHAPresence represents a Zigbee presence monitor

type ZHAPressure

type ZHAPressure struct {
	Pressure    int    `json:"pressure"`
	LastUpdated string `json:"lastupdated"`
}

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

type ZHAWater

type ZHAWater struct {
	Water       bool   `json:"water"`
	LastUpdated string `json:"lastupdated"`
	LowBattery  bool   `json:"lowbattery"`
	Tampered    bool   `json:"tampered"`
}

ZHAWater represents a Zigbee water sensor

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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