From eaeca5dd08c76e8ca831d7d733858a5495591c99 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Wed, 19 Oct 2022 00:32:09 -0400 Subject: [PATCH] fix zwave js event type --- example/main/testing.go | 6 +++++- types.go | 42 ++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/example/main/testing.go b/example/main/testing.go index 0e70f4a..c228189 100644 --- a/example/main/testing.go +++ b/example/main/testing.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "log" ga "github.com/saml-dev/gome-assistant" @@ -39,7 +40,10 @@ func pantryLights(service *ga.Service, data ga.EntityData) { } func onEvent(service *ga.Service, data ga.EventData) { - service.HomeAssistant.Toggle("light.el_gato_key_lights") + // service.HomeAssistant.Toggle("light.el_gato_key_lights") + ev := ga.EventZWaveJSValueNotification{} + json.Unmarshal(data.RawEventJSON, &ev) + log.Default().Println(ev) } func cool(service *ga.Service, state *ga.State) { diff --git a/types.go b/types.go index 99af5c3..cefc6dc 100644 --- a/types.go +++ b/types.go @@ -3,23 +3,27 @@ package gomeassistant import "time" type EventZWaveJSValueNotification struct { - EventType string `yaml:"event_type"` - Data struct { - Domain string `yaml:"domain"` - NodeID int `yaml:"node_id"` - HomeID int64 `yaml:"home_id"` - Endpoint int `yaml:"endpoint"` - DeviceID string `yaml:"device_id"` - CommandClass int `yaml:"command_class"` - CommandClassName string `yaml:"command_class_name"` - Label string `yaml:"label"` - Property string `yaml:"property"` - PropertyName string `yaml:"property_name"` - PropertyKey string `yaml:"property_key"` - PropertyKeyName string `yaml:"property_key_name"` - Value string `yaml:"value"` - ValueRaw int `yaml:"value_raw"` - } `yaml:"data"` - Origin string `yaml:"origin"` - TimeFired time.Time `yaml:"time_fired"` + ID int `json:"id"` + Type string `json:"type"` + Event struct { + EventType string `json:"event_type"` + Data struct { + Domain string `json:"domain"` + NodeID int `json:"node_id"` + HomeID int64 `json:"home_id"` + Endpoint int `json:"endpoint"` + DeviceID string `json:"device_id"` + CommandClass int `json:"command_class"` + CommandClassName string `json:"command_class_name"` + Label string `json:"label"` + Property string `json:"property"` + PropertyName string `json:"property_name"` + PropertyKey string `json:"property_key"` + PropertyKeyName string `json:"property_key_name"` + Value string `json:"value"` + ValueRaw int `json:"value_raw"` + } `json:"data"` + Origin string `json:"origin"` + TimeFired time.Time `json:"time_fired"` + } `json:"event"` }