parent
8ceeed9278
commit
fc1e13ad67
|
@ -17,6 +17,7 @@
|
|||
- `homeassistant.states.{domain}.{entity}.{state}` - Home Assistant device state changes: [payload](https://www.home-assistant.io/docs/configuration/state_object/)
|
||||
- `homeassistant.attributes.{domain}.{entity}.{state}` - When a device's attributes change but the state hasn't changed: [payload](https://www.home-assistant.io/docs/configuration/state_object/)
|
||||
- `homeassistant.zha.{device IEEE}` - ZHA events: [payload](https://www.home-assistant.io/docs/configuration/state_object/)
|
||||
- `homeassistant.zwave-scene.{device ID}` - ZwaveJS scene events: [payload](https://www.home-assistant.io/integrations/zwave_js/#scene-events-value-notification)
|
||||
- `homeassistant.nfc.{tag ID}` - Home Assistant NFC tag scanned: [payload](https://www.home-assistant.io/docs/configuration/state_object/)
|
||||
- `homeassistant.timer.{timer name}.finished` - Home Assistant timer finished: payload is simply `"finished"`
|
||||
- `schedules.{schedule name}` - HATS schedule finished: payload is simply `"finished"`
|
||||
|
|
|
@ -25,6 +25,7 @@ const (
|
|||
stateChangeEventId = 1001
|
||||
zhaEventId = 1002
|
||||
nfcEventId = 1003
|
||||
zwaveEventId = 1004
|
||||
timerFinishedEventId = 1005
|
||||
)
|
||||
|
||||
|
@ -116,6 +117,10 @@ func handleMessages() {
|
|||
Type: ha.MessageType.SubscribeEvents,
|
||||
EventType: ha.MessageType.TagScanned,
|
||||
Id: nfcEventId})
|
||||
haWebsocketConn.WriteJSON(ha.SubscribeEventsMessage{
|
||||
Type: ha.MessageType.SubscribeEvents,
|
||||
EventType: ha.MessageType.ZwaveEvent,
|
||||
Id: zwaveEventId})
|
||||
haWebsocketConn.WriteJSON(ha.SubscribeEventsMessage{
|
||||
Type: ha.MessageType.SubscribeEvents,
|
||||
EventType: ha.MessageType.TimerFinished,
|
||||
|
@ -147,6 +152,9 @@ func handleMessages() {
|
|||
case nfcEventId:
|
||||
data, _ := json.Marshal(message.Event.Data)
|
||||
nats.Publish(fmt.Sprintf("homeassistant.nfc.%s", message.Event.Data.TagId), data)
|
||||
case zwaveEventId:
|
||||
data, _ := json.Marshal(message.Event.Data)
|
||||
nats.Publish(fmt.Sprintf("homeassistant.zwave-scene.%s", message.Event.Data.DeviceId), data)
|
||||
case timerFinishedEventId:
|
||||
nats.PublishString(fmt.Sprintf("homeassistant.%s.finished", message.Event.Data.EntityId), "finished")
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ var MessageType = struct {
|
|||
Result string
|
||||
Event string
|
||||
ZhaEvent string
|
||||
ZwaveEvent string
|
||||
SubscribeEvents string
|
||||
StateChanged string
|
||||
TagScanned string
|
||||
|
@ -20,6 +21,7 @@ var MessageType = struct {
|
|||
Result: "result",
|
||||
Event: "event",
|
||||
ZhaEvent: "zha_event",
|
||||
ZwaveEvent: "zwave_js_value_notification",
|
||||
SubscribeEvents: "subscribe_events",
|
||||
StateChanged: "state_changed",
|
||||
TagScanned: "tag_scanned",
|
||||
|
@ -86,6 +88,7 @@ var ExtraProps = struct {
|
|||
Transition string
|
||||
Brightness string
|
||||
BrightnessPercent string
|
||||
BrightnessPercentStep string
|
||||
HvacMode string
|
||||
Temperature string
|
||||
TargetTempHigh string
|
||||
|
@ -96,6 +99,7 @@ var ExtraProps = struct {
|
|||
Transition: "transition",
|
||||
Brightness: "brightness",
|
||||
BrightnessPercent: "brightness_pct",
|
||||
BrightnessPercentStep: "brightness_step_pct",
|
||||
HvacMode: "hvac_mode",
|
||||
Temperature: "temperature",
|
||||
TargetTempHigh: "target_temp_high",
|
||||
|
@ -124,12 +128,31 @@ type EventData struct {
|
|||
EntityId string `json:"entity_id,omitempty"`
|
||||
NewState StateData `json:"new_state,omitempty"`
|
||||
OldState StateData `json:"old_state,omitempty"`
|
||||
|
||||
// ZHA
|
||||
DeviceIeee string `json:"device_ieee,omitempty"`
|
||||
DeviceId string `json:"device_id,omitempty"`
|
||||
Command string `json:"command,omitempty"`
|
||||
Args interface{} `json:"args,omitempty"`
|
||||
Params interface{} `json:"params,omitempty"`
|
||||
|
||||
// NFC
|
||||
TagId string `json:"tag_id,omitempty"`
|
||||
|
||||
// ZwaveJS Scene
|
||||
Domain string `json:"domain,omitempty"`
|
||||
NodeID int `json:"node_id,omitempty"`
|
||||
HomeID string `json:"home_id,omitempty"`
|
||||
Endpoint int `json:"endpoint,omitempty"`
|
||||
CommandClass int `json:"command_class,omitempty"`
|
||||
CommandClassName string `json:"command_class_name,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Property string `json:"property,omitempty"`
|
||||
PropertyName string `json:"property_name,omitempty"`
|
||||
PropertyKey string `json:"property_key,omitempty"`
|
||||
PropertyKeyName string `json:"property_key_name,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
ValueRaw int `json:"value_raw,omitempty"`
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
|
|
Loading…
Reference in New Issue