fix zwave js event type

This commit is contained in:
Sam Lewis
2022-10-19 00:32:09 -04:00
parent 83789184f0
commit eaeca5dd08
2 changed files with 28 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"encoding/json"
"log" "log"
ga "github.com/saml-dev/gome-assistant" 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) { 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) { func cool(service *ga.Service, state *ga.State) {

View File

@@ -3,23 +3,27 @@ package gomeassistant
import "time" import "time"
type EventZWaveJSValueNotification struct { type EventZWaveJSValueNotification struct {
EventType string `yaml:"event_type"` ID int `json:"id"`
Data struct { Type string `json:"type"`
Domain string `yaml:"domain"` Event struct {
NodeID int `yaml:"node_id"` EventType string `json:"event_type"`
HomeID int64 `yaml:"home_id"` Data struct {
Endpoint int `yaml:"endpoint"` Domain string `json:"domain"`
DeviceID string `yaml:"device_id"` NodeID int `json:"node_id"`
CommandClass int `yaml:"command_class"` HomeID int64 `json:"home_id"`
CommandClassName string `yaml:"command_class_name"` Endpoint int `json:"endpoint"`
Label string `yaml:"label"` DeviceID string `json:"device_id"`
Property string `yaml:"property"` CommandClass int `json:"command_class"`
PropertyName string `yaml:"property_name"` CommandClassName string `json:"command_class_name"`
PropertyKey string `yaml:"property_key"` Label string `json:"label"`
PropertyKeyName string `yaml:"property_key_name"` Property string `json:"property"`
Value string `yaml:"value"` PropertyName string `json:"property_name"`
ValueRaw int `yaml:"value_raw"` PropertyKey string `json:"property_key"`
} `yaml:"data"` PropertyKeyName string `json:"property_key_name"`
Origin string `yaml:"origin"` Value string `json:"value"`
TimeFired time.Time `yaml:"time_fired"` ValueRaw int `json:"value_raw"`
} `json:"data"`
Origin string `json:"origin"`
TimeFired time.Time `json:"time_fired"`
} `json:"event"`
} }