deconz

package
v0.0.0-...-33fd162 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DeconzDiscoveryEndpoint = "https://dresden-light.appspot.com/discover"

DeconzDiscoveryEndpoint is the url used when auto discovering a deconz gateway

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Config Config
	// contains filtered or unexported fields
}

API represents the deCONZ rest api

func (*API) EventReader

func (a *API) EventReader() (*event.Reader, error)

EventReader returns a event.Reader with a default cached type store

func (*API) SensorEventReader

func (a *API) SensorEventReader(r *event.Reader) *SensorEventReader

SensorEventReader takes an event reader and returns an sensor event reader

func (*API) Sensors

func (a *API) Sensors() (*Sensors, error)

Sensors returns a map of sensors

type APIKey

type APIKey string

APIKey is our apikey type

func Pair

func Pair(u url.URL) (APIKey, error)

Pair tries to pair with deconz and returns a pairing with an API key

type CachedSensorStore

type CachedSensorStore struct {
	SensorGetter
	// contains filtered or unexported fields
}

CachedSensorStore is a cached typestore which provides LookupType for event passing it will be our default store

func (*CachedSensorStore) LookupSensor

func (c *CachedSensorStore) LookupSensor(i int) (*Sensor, error)

LookupSensor returns a sensor for an sensor id

func (*CachedSensorStore) LookupType

func (c *CachedSensorStore) LookupType(i int) (string, error)

LookupType lookups deCONZ event types though a cache TODO: if we where unable to lookup an ID we should try to refetch the cache - there could have been an sensor added we dont know about

type Config

type Config struct {
	Addr   string
	APIKey string
	// contains filtered or unexported fields
}

Config represents a Deconz gateway

type Discovery

type Discovery struct {
	ID                string
	Name              string
	MacAddress        string
	PublicIPAddress   string
	InternalIPAddress string
	InternalPort      uint
}

Discovery is a discovered deconz gateway [{"macaddress": "00212EFFFF017FBD", "name": "deCONZ-GW", "internalipaddress": "192.168.1.90", "publicipaddress": "85.191.222.130", "internalport": 8080, "id": "00212EFFFF017FBD"}]

type DiscoveryResponse

type DiscoveryResponse []Discovery

DiscoveryResponse is a slice of discovered gateways

func Discover

func Discover() (DiscoveryResponse, error)

Discover discovers deconz gateways

type EventReader

type EventReader interface {
	ReadEvent() (*event.Event, error)
	Dial() error
	Close() error
}

EventReader interface

type Sensor

type Sensor struct {
	Type string
	Name string
}

Sensor is a deCONZ sensor, not that we only implement fields needed for event parsing to work

type SensorEvent

type SensorEvent struct {
	*Sensor
	*event.Event
}

SensorEvent is a sensor and a event embedded

func (*SensorEvent) Timeseries

func (s *SensorEvent) Timeseries() (map[string]string, map[string]interface{}, error)

Timeseries returns tags and fields for use in influxdb

type SensorEventReader

type SensorEventReader struct {
	// contains filtered or unexported fields
}

SensorEventReader reads events from an event.reader and returns SensorEvents

func (*SensorEventReader) Start

func (r *SensorEventReader) Start(out chan *SensorEvent) error

starts a thread reading events into the given channel returns immediately

func (*SensorEventReader) StopReadEvents

func (r *SensorEventReader) StopReadEvents()

Close closes the reader, closing the connection to deconz and terminating the goroutine

type SensorGetter

type SensorGetter interface {
	Sensors() (*Sensors, error)
}

SensorGetter defines how we like to ask for sensors

type SensorLookup

type SensorLookup interface {
	LookupSensor(int) (*Sensor, error)
}

SensorLookup represents an interface for sensor lookup

type Sensors

type Sensors map[int]Sensor

Sensors is a map of sensors indexed by their id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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