Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachingSensorProvider ¶
type CachingSensorProvider struct {
// contains filtered or unexported fields
}
CachingSensorProvider is a sensor.Provider that retrieves sensor info from the dCONZ REST API and caches results It is the default sensor.Provider
func NewCachingSensorProvider ¶
func NewCachingSensorProvider(api API, updateInterval time.Duration) (*CachingSensorProvider, error)
NewCachingSensorProvider returns a CachingSensorProvider The CachingSensorProvider is a singleton.
type EventError ¶
type EventError struct {
// contains filtered or unexported fields
}
EventError represents an error during the retrieval or decoding of events It wraps another error Users can specify if the error is recoverable
func NewEventError ¶
func NewEventError(err error, recoverable bool) EventError
NewEventError creates a new EventError that wraps another error
func (EventError) Recoverable ¶
func (e EventError) Recoverable() bool
Recoverable returns true if the error is not critical and execution should go on
type SensorEvent ¶
SensorEvent is an Event triggered by a Sensor
func (*SensorEvent) Timeseries ¶
func (s *SensorEvent) Timeseries() (map[string]string, map[string]interface{}, error)
Timeseries returns tags and fields for use in InfluxDB
type Timeserieser ¶
Timeserieser returns time series data
type WebsocketEventReader ¶
type WebsocketEventReader struct { WebsocketAddr string SensorProvider sensor.Provider // contains filtered or unexported fields }
WebsocketEventReader uses an EventReader (for example WsReader) to provide a channel of SensorEvent The WebsocketEventReader handles connection losses and reconnection attempts of the underlying EventReader
func NewWebsocketEventReader ¶
func NewWebsocketEventReader(api API, si sensor.Provider) (*WebsocketEventReader, error)
NewWebsocketEventReader creates a new WebsocketEventReader that continuously reads events from the deCONZ websocket It uses the API to discover the websocket address The structure of the JSON messages from the websocket depend on the resource/sensor type. Thus, the WsReader requires a sensor.Provider to properly unmarshal those messages.
func (*WebsocketEventReader) Shutdown ¶
func (r *WebsocketEventReader) Shutdown(ctx ctx.Context)
Shutdown closes the reader, closing the connection to deCONZ The method blocks until all background tasks are terminated or the given Context is aborted
func (*WebsocketEventReader) Start ¶
func (r *WebsocketEventReader) Start(ctx ctx.Context) (<-chan *SensorEvent, error)
Start starts a go routine that reads events from the associated EventReader It returns the channel to retrieve events from
type WsEvent ¶
type WsEvent struct { // type should always be 'event' Type string `json:"t"` Event string `json:"e"` ResourceName string `json:"r"` ID int `json:"id,string"` // TODO intermediate type // only for e = 'changed' RawState json.RawMessage `json:"state"` // only for e = 'changed' StateDef interface{} }
WsEvent is a message received over the deCONZ websocket We are only interested in e = 'change' events of resource type r = 'sensor'. Thus we don't implement all fields. See https://dresden-elektronik.github.io/deconz-rest-doc/endpoints/websocket/#message-fields
func (WsEvent) ResourceID ¶
ResourceID returns the unique id of the resource which was affected by the event