Skip to content

kanimaru/godeconz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godeconz

... is a binding for the deconz Rest and Websocket API It has exchangeable HTTP Client (default Resty) and Logger (default standard go logger)

Features

  • Alarm Systems
  • Configuration
  • Groups
  • Lights
  • Rules
  • Scenes
  • Schedules
  • Sensors
  • Button Events
  • Touchlink
  • Websocket
  • ETag support

Etag Support Note

Currently, it is implemented on request level. Could be improved to be on entity level because when you request a group of lights for example you receive ETags also that aren't processed yet.

Example

Query all lights:

package main

import (
	"github.com/PerformLine/go-stockutil/log"
	"github.com/go-resty/resty/v2"
	"github.com/kanimaru/godeconz"
	"os"
)

func getEnv(key string, fallback string) string {
	if value, ok := os.LookupEnv(key); ok {
		return value
	}
	if len(fallback) == 0 {
		log.Fatalf("Missing %q", key)
	}
	return fallback
}

func main() {
	setting := godeconz.Settings{
		Address:      getEnv("DECONZ_ADDRESS", ""),
		HttpProtocol: getEnv("DECONZ_PROTO", "http"),
		ApiKey:       getEnv("DECONZ_API_KEY", ""),
	}

	httpAdapter := godeconz.CreateAdapterHttpClientResty(resty.New(), Logger{}, false)
	deconzClient := godeconz.CreateClient(httpAdapter, setting)

	var container map[string]godeconz.LightResponseState
	_, err := deconzClient.GetAllLights(&container)
	if err != nil {
		log.Fatalf("Can't query lights", err)
	}

	for _, light := range container {
		log.Noticef("Name: %v", light.Name)
	}
}

Resources

https://dresden-elektronik.github.io/deconz-rest-doc/

About

Binding for Deconz REST and Websocket API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages