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.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.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.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.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"`
|
- `homeassistant.timer.{timer name}.finished` - Home Assistant timer finished: payload is simply `"finished"`
|
||||||
- `schedules.{schedule name}` - HATS schedule finished: payload is simply `"finished"`
|
- `schedules.{schedule name}` - HATS schedule finished: payload is simply `"finished"`
|
||||||
|
|
|
@ -25,6 +25,7 @@ const (
|
||||||
stateChangeEventId = 1001
|
stateChangeEventId = 1001
|
||||||
zhaEventId = 1002
|
zhaEventId = 1002
|
||||||
nfcEventId = 1003
|
nfcEventId = 1003
|
||||||
|
zwaveEventId = 1004
|
||||||
timerFinishedEventId = 1005
|
timerFinishedEventId = 1005
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -116,6 +117,10 @@ func handleMessages() {
|
||||||
Type: ha.MessageType.SubscribeEvents,
|
Type: ha.MessageType.SubscribeEvents,
|
||||||
EventType: ha.MessageType.TagScanned,
|
EventType: ha.MessageType.TagScanned,
|
||||||
Id: nfcEventId})
|
Id: nfcEventId})
|
||||||
|
haWebsocketConn.WriteJSON(ha.SubscribeEventsMessage{
|
||||||
|
Type: ha.MessageType.SubscribeEvents,
|
||||||
|
EventType: ha.MessageType.ZwaveEvent,
|
||||||
|
Id: zwaveEventId})
|
||||||
haWebsocketConn.WriteJSON(ha.SubscribeEventsMessage{
|
haWebsocketConn.WriteJSON(ha.SubscribeEventsMessage{
|
||||||
Type: ha.MessageType.SubscribeEvents,
|
Type: ha.MessageType.SubscribeEvents,
|
||||||
EventType: ha.MessageType.TimerFinished,
|
EventType: ha.MessageType.TimerFinished,
|
||||||
|
@ -147,6 +152,9 @@ func handleMessages() {
|
||||||
case nfcEventId:
|
case nfcEventId:
|
||||||
data, _ := json.Marshal(message.Event.Data)
|
data, _ := json.Marshal(message.Event.Data)
|
||||||
nats.Publish(fmt.Sprintf("homeassistant.nfc.%s", message.Event.Data.TagId), 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:
|
case timerFinishedEventId:
|
||||||
nats.PublishString(fmt.Sprintf("homeassistant.%s.finished", message.Event.Data.EntityId), "finished")
|
nats.PublishString(fmt.Sprintf("homeassistant.%s.finished", message.Event.Data.EntityId), "finished")
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ var MessageType = struct {
|
||||||
Result string
|
Result string
|
||||||
Event string
|
Event string
|
||||||
ZhaEvent string
|
ZhaEvent string
|
||||||
|
ZwaveEvent string
|
||||||
SubscribeEvents string
|
SubscribeEvents string
|
||||||
StateChanged string
|
StateChanged string
|
||||||
TagScanned string
|
TagScanned string
|
||||||
|
@ -20,6 +21,7 @@ var MessageType = struct {
|
||||||
Result: "result",
|
Result: "result",
|
||||||
Event: "event",
|
Event: "event",
|
||||||
ZhaEvent: "zha_event",
|
ZhaEvent: "zha_event",
|
||||||
|
ZwaveEvent: "zwave_js_value_notification",
|
||||||
SubscribeEvents: "subscribe_events",
|
SubscribeEvents: "subscribe_events",
|
||||||
StateChanged: "state_changed",
|
StateChanged: "state_changed",
|
||||||
TagScanned: "tag_scanned",
|
TagScanned: "tag_scanned",
|
||||||
|
@ -83,25 +85,27 @@ var Services = struct {
|
||||||
|
|
||||||
// Extra props that can be sent when calling a Home Assistant service
|
// Extra props that can be sent when calling a Home Assistant service
|
||||||
var ExtraProps = struct {
|
var ExtraProps = struct {
|
||||||
Transition string
|
Transition string
|
||||||
Brightness string
|
Brightness string
|
||||||
BrightnessPercent string
|
BrightnessPercent string
|
||||||
HvacMode string
|
BrightnessPercentStep string
|
||||||
Temperature string
|
HvacMode string
|
||||||
TargetTempHigh string
|
Temperature string
|
||||||
TargetTempLow string
|
TargetTempHigh string
|
||||||
Duration string
|
TargetTempLow string
|
||||||
Value string
|
Duration string
|
||||||
|
Value string
|
||||||
}{
|
}{
|
||||||
Transition: "transition",
|
Transition: "transition",
|
||||||
Brightness: "brightness",
|
Brightness: "brightness",
|
||||||
BrightnessPercent: "brightness_pct",
|
BrightnessPercent: "brightness_pct",
|
||||||
HvacMode: "hvac_mode",
|
BrightnessPercentStep: "brightness_step_pct",
|
||||||
Temperature: "temperature",
|
HvacMode: "hvac_mode",
|
||||||
TargetTempHigh: "target_temp_high",
|
Temperature: "temperature",
|
||||||
TargetTempLow: "target_temp_low",
|
TargetTempHigh: "target_temp_high",
|
||||||
Duration: "duration",
|
TargetTempLow: "target_temp_low",
|
||||||
Value: "value",
|
Duration: "duration",
|
||||||
|
Value: "value",
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResultContext struct {
|
type ResultContext struct {
|
||||||
|
@ -121,15 +125,34 @@ type StateData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventData struct {
|
type EventData struct {
|
||||||
EntityId string `json:"entity_id,omitempty"`
|
EntityId string `json:"entity_id,omitempty"`
|
||||||
NewState StateData `json:"new_state,omitempty"`
|
NewState StateData `json:"new_state,omitempty"`
|
||||||
OldState StateData `json:"old_state,omitempty"`
|
OldState StateData `json:"old_state,omitempty"`
|
||||||
|
|
||||||
|
// ZHA
|
||||||
DeviceIeee string `json:"device_ieee,omitempty"`
|
DeviceIeee string `json:"device_ieee,omitempty"`
|
||||||
DeviceId string `json:"device_id,omitempty"`
|
DeviceId string `json:"device_id,omitempty"`
|
||||||
Command string `json:"command,omitempty"`
|
Command string `json:"command,omitempty"`
|
||||||
Args interface{} `json:"args,omitempty"`
|
Args interface{} `json:"args,omitempty"`
|
||||||
Params interface{} `json:"params,omitempty"`
|
Params interface{} `json:"params,omitempty"`
|
||||||
TagId string `json:"tag_id,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 {
|
type Event struct {
|
||||||
|
|
Loading…
Reference in New Issue