... is a binding for the deconz Rest and Websocket API It has exchangeable HTTP Client (default Resty) and Logger (default standard go logger)
- Alarm Systems
- Configuration
- Groups
- Lights
- Rules
- Scenes
- Schedules
- Sensors
- Button Events
- Touchlink
- Websocket
- ETag support
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.
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)
}
}