Documentation ¶
Index ¶
- type Adapter
- type AdapterWebsocketClientGorilla
- type Attr
- type BaseCallback
- type BaseConfig
- type Callback
- type CallbackConfig
- type CallbackHandler
- type ChanCallback
- type Client
- type ConfigDaylight
- type ConfigZHAHumidity
- type ConfigZHALightLevel
- type ConfigZHAOpenClose
- type ConfigZHAPresence
- type ConfigZHAPressure
- type ConfigZHATemperature
- type EventType
- type Filter
- type Message
- type MessageType
- type ResourceType
- type StateBaseDevice
- type StateBaseLight
- type StateCallback
- type StateColortemperaturelight
- type StateDaylight
- type StateDimmablelight
- type StateExtendedcolorlight
- type StateOnOffpluginunit
- type StateZHAHumidity
- type StateZHALightLevel
- type StateZHAOpenClose
- type StateZHAPresence
- type StateZHAPressure
- type StateZHATemperature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type AdapterWebsocketClientGorilla ¶
type AdapterWebsocketClientGorilla struct {
// contains filtered or unexported fields
}
func (*AdapterWebsocketClientGorilla) Close ¶
func (a *AdapterWebsocketClientGorilla) Close() error
func (*AdapterWebsocketClientGorilla) CloseGracefully ¶
func (a *AdapterWebsocketClientGorilla) CloseGracefully() error
func (*AdapterWebsocketClientGorilla) Connect ¶
func (a *AdapterWebsocketClientGorilla) Connect(host *url.URL, messages chan<- []byte) error
func (*AdapterWebsocketClientGorilla) ReadMessages ¶
func (a *AdapterWebsocketClientGorilla) ReadMessages(messages chan<- []byte)
type Attr ¶ added in v0.0.7
type Attr struct { Id string `json:"id,omitempty"` Lastannounced time.Time `json:"lastannounced,omitempty"` Lastseen string `json:"lastseen,omitempty"` Manufacturername string `json:"manufacturername,omitempty"` Modelid string `json:"modelid,omitempty"` Name string `json:"name,omitempty"` Swversion string `json:"swversion,omitempty"` Type string `json:"type,omitempty"` Uniqueid string `json:"uniqueid,omitempty"` }
Attr is not documented but found in the wild. Here are probably other missing fields
type BaseCallback ¶
type BaseCallback struct {
Handler func(message Message)
}
func (BaseCallback) OnMessage ¶
func (b BaseCallback) OnMessage(message Message)
type BaseConfig ¶ added in v0.0.11
type BaseConfig struct { // (default: true) On bool `json:"on"` // (default: true) Reachable *bool `json:"reachable,omitempty"` // (0–100) Battery *uint8 `json:"battery,omitempty"` }
func (BaseConfig) GetBattery ¶ added in v0.0.11
func (b BaseConfig) GetBattery() *uint8
func (BaseConfig) IsOn ¶ added in v0.0.11
func (b BaseConfig) IsOn() bool
func (BaseConfig) IsReachable ¶ added in v0.0.11
func (b BaseConfig) IsReachable() *bool
type Callback ¶
type Callback interface {
OnMessage(message Message)
}
Callback that get called when websocket receives a message
type CallbackConfig ¶
type CallbackConfig struct {
// contains filtered or unexported fields
}
type CallbackHandler ¶ added in v0.0.7
type ChanCallback ¶ added in v0.0.7
type ChanCallback struct {
// contains filtered or unexported fields
}
func NewChanCallback ¶ added in v0.0.7
func NewChanCallback(messageChan chan Message, handler CallbackHandler, filter Filter) *ChanCallback
NewChanCallback registers a new callback that listen for the filtered events and send the message to a chan.
func (ChanCallback) OnMessage ¶ added in v0.0.7
func (c ChanCallback) OnMessage(message Message)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func CreateClient ¶
CreateClient creates a websocket client for Phoscon WSS. The Websocket functionality is still under development. Notably added and deleted notifications might not be issued under all circumstances.
func CreateClientFromConfig ¶
func CreateClientFromConfig[R any](client http.Client[R], adapter Adapter, logger godeconz.Logger) *Client
CreateClientFromConfig is an alias for CreateClient that uses the config from REST to determine the URL for websocket.
func (*Client) AddCallback ¶
func (*Client) RemoveCallback ¶
type ConfigDaylight ¶ added in v0.0.11
type ConfigDaylight struct { BaseConfig Configured bool `json:"configured"` On bool `json:"on"` Sunriseoffset int `json:"sunriseoffset"` Sunsetoffset int `json:"sunsetoffset"` }
type ConfigZHAHumidity ¶ added in v0.0.11
type ConfigZHAHumidity struct { BaseConfig Offset int `json:"offset"` }
type ConfigZHALightLevel ¶ added in v0.0.11
type ConfigZHALightLevel struct { BaseConfig Alert string `json:"alert"` Ledindication bool `json:"ledindication"` Tholddark int `json:"tholddark"` Tholdoffset int `json:"tholdoffset"` Usertest bool `json:"usertest"` Delay int `json:"delay"` Sensitivity int `json:"sensitivity"` Sensitivitymax int `json:"sensitivitymax"` }
type ConfigZHAOpenClose ¶ added in v0.0.11
type ConfigZHAOpenClose struct { BaseConfig Temperature int `json:"temperature"` }
type ConfigZHAPresence ¶ added in v0.0.11
type ConfigZHAPresence struct { BaseConfig Duration int `json:"duration"` Temperature int `json:"temperature"` }
type ConfigZHAPressure ¶ added in v0.0.11
type ConfigZHAPressure struct { BaseConfig Offset int `json:"offset"` }
type ConfigZHATemperature ¶ added in v0.0.11
type ConfigZHATemperature struct { BaseConfig Offset int `json:"offset"` }
type EventType ¶
type EventType string
const EventTypeAdded EventType = "added"
EventTypeAdded resource has been added
const EventTypeChanged EventType = "changed"
EventTypeChanged resource attributes have changed;
const EventTypeDeleted EventType = "deleted"
EventTypeDeleted resource has been deleted.
const EventTypeSceneCalled EventType = "scene-called"
EventTypeSceneCalled a scene has been recalled.
type Filter ¶
type Filter struct { EventTypes []EventType Ids []string ResourceTypes []ResourceType MessageTypes []MessageType UniqueIds []string // HasState checks if state attribute is set otherwise the message gets blocked HasState bool // HasAttr checks if attr attribute is set otherwise the message gets blocked HasAttr bool // HasConfig checks if config attribute is set otherwise the message gets blocked HasConfig bool }
Filter for different values of the message. The values of the arrays will be OR concat and the different arrays will be ANDed. Ex: 2 ids are specified and one emitType then the message will be processed when one of the id matches AND the emitType.
type Message ¶
type Message struct { // EventType the event type of the message EventType EventType `json:"e,omitempty"` // Id of the resource to which the message relates, e.g. 5 for /sensors/5. Not for scene-called events. Id string `json:"id,omitempty"` // ResourceType The resource type to which the message belongs ResourceType ResourceType `json:"r,omitempty"` // MessageType The type of the message MessageType MessageType `json:"t,omitempty"` // Depending on the websocketnotifyall setting: a map containing all or only the changed state attributes of a group, light, or sensor resource. Only for changed events. State json.RawMessage `json:"state,omitempty"` // Depending on the websocketnotifyall setting: a map containing all or only the changed config attributes of a sensor resource. Only for changed events. Config json.RawMessage `json:"config,omitempty"` // Not documented but found in the wild. Attr *Attr `json:"attr,omitempty"` // UniqueId of the resource to which the message relates, e.g. 00:0d:6f:00:10:65:8a:6e-01-1000. Only for light and sensor resources. UniqueId string `json:"uniqueid,omitempty"` // The (new) name of a resource. Only for changed events. Name string `json:"name,omitempty"` // The group id of the resource to which the message relates. Only for scene-called events. GroupId string `json:"GroupId,omitempty"` // The scene id of the resource to which the message relates. Only for scene-called events. SceneId string `json:"SceneId,omitempty"` // The full group resource. Only for added events of a group resource. Group json.RawMessage `json:"group,omitempty"` // The full light resource. Only for added events of a light resource. Light json.RawMessage `json:"light,omitempty"` // The full sensor resource. Only for added events of a sensor resource. Sensor json.RawMessage `json:"sensor,omitempty"` }
type MessageType ¶
type MessageType string
const MessageTypeEvent MessageType = "event"
MessageTypeEvent the message holds an event.
type ResourceType ¶
type ResourceType string
const ResourceTypeGroups ResourceType = "Groups"
ResourceTypeGroups message relates to a group resource;
const ResourceTypeLights ResourceType = "Lights"
ResourceTypeLights message relates to a light resource;
const ResourceTypeScenes ResourceType = "Scenes"
ResourceTypeScenes message relates to a scene under a group resource;
const ResourceTypeSensors ResourceType = "Sensors"
ResourceTypeSensors message relates to a sensor resource.
type StateBaseDevice ¶ added in v0.0.13
type StateBaseDevice struct { On bool `json:"on,omitempty"` Reachable bool `json:"reachable,omitempty"` }
func (StateBaseDevice) IsOn ¶ added in v0.0.13
func (s StateBaseDevice) IsOn() bool
func (StateBaseDevice) IsReachable ¶ added in v0.0.13
func (s StateBaseDevice) IsReachable() bool
type StateBaseLight ¶ added in v0.0.10
type StateBaseLight struct { StateBaseDevice Alert interface{} `json:"alert,omitempty"` Bri int `json:"bri,omitempty"` }
func (StateBaseLight) GetAlert ¶ added in v0.0.11
func (s StateBaseLight) GetAlert() interface{}
func (StateBaseLight) GetBrightness ¶ added in v0.0.11
func (s StateBaseLight) GetBrightness() int
type StateCallback ¶ added in v0.0.7
type StateCallback[S any] struct { // contains filtered or unexported fields }
func NewStateCallback ¶ added in v0.0.7
func NewStateCallback[S any](stateChan chan S, handler CallbackHandler, filter Filter) *StateCallback[S]
NewStateCallback registers a new callback that listen for the filtered state events and send the state to a chan.
func (StateCallback[S]) OnMessage ¶ added in v0.0.7
func (s StateCallback[S]) OnMessage(message Message)
type StateColortemperaturelight ¶ added in v0.0.7
type StateColortemperaturelight struct { StateBaseLight Colormode string `json:"colormode"` Ct int `json:"ct"` }
type StateDaylight ¶ added in v0.0.7
type StateDaylight struct { }
type StateDimmablelight ¶ added in v0.0.7
type StateDimmablelight struct {
StateBaseLight
}
type StateExtendedcolorlight ¶ added in v0.0.7
type StateExtendedcolorlight struct { // FIXME HERE ARE MISSING FIELDS StateBaseLight Colormode string `json:"colormode"` Ct int `json:"ct"` }
type StateOnOffpluginunit ¶ added in v0.0.7
type StateOnOffpluginunit struct { StateBaseDevice Alert interface{} `json:"alert"` }