deconz

package
v0.0.0-...-461edb3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 10 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) DeviceEventReader

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

DeviceEventReader takes an event reader and returns an sensor event reader

func (*API) Devices

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

Devices returns a map of devices

func (*API) EventReader

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

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

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 CachedDeviceStore

type CachedDeviceStore struct {
	DeviceGetter
	// contains filtered or unexported fields
}

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

func (*CachedDeviceStore) LookupDevice

func (c *CachedDeviceStore) LookupDevice(id string) (*Device, error)

LookupDevice returns a device for an device id

func (*CachedDeviceStore) LookupType

func (c *CachedDeviceStore) LookupType(id string) (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 device added we dont know about

func (*CachedDeviceStore) SupportsResource

func (c *CachedDeviceStore) SupportsResource(restype string) bool

SupportsResource returns true if this Store supports the resource type

type Config

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

Config represents a Deconz gateway

type Device

type Device struct {
	Type     string
	Name     string
	DeviceID string `json:"uniqueid"`
}

Device is a device like a Light, Sensor(Motion, Contact, Switch)

type DeviceEvent

type DeviceEvent struct {
	*Device
	*event.Event
}

DeviceEvent is a sensor and a event embedded

type DeviceEventReader

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

DeviceEventReader reads events from an event.reader and returns DeviceEvents

func (*DeviceEventReader) Start

func (r *DeviceEventReader) Start(out chan *DeviceEvent) error

Start starts a thread reading events into the given channel returns immediately

func (*DeviceEventReader) StopReadEvents

func (r *DeviceEventReader) StopReadEvents()

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

type DeviceGetter

type DeviceGetter interface {
	Devices() (*Devices, error)
}

DeviceGetter defines how we like to ask for devices

type DeviceLookup

type DeviceLookup interface {
	LookupDevice(string) (*Device, error)
	SupportsResource(string) bool
}

DeviceLookup represents an interface for device lookup

type Devices

type Devices map[string]Device // UniqueID -> Device

Devices is a map of devices indexed by their id

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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