Don't use request for attribute changes
parent
653fb0e570
commit
630d85487c
|
@ -144,9 +144,9 @@ func handleMessages() {
|
||||||
go nats.SetKeyValueString(fmt.Sprintf("homeassistant.states.%s", message.Event.Data.EntityId), message.Event.Data.NewState.State)
|
go nats.SetKeyValueString(fmt.Sprintf("homeassistant.states.%s", message.Event.Data.EntityId), message.Event.Data.NewState.State)
|
||||||
if message.Event.Data.NewState.State == message.Event.Data.OldState.State {
|
if message.Event.Data.NewState.State == message.Event.Data.OldState.State {
|
||||||
logger.Debug("State unchanged, publishing to attributes topic")
|
logger.Debug("State unchanged, publishing to attributes topic")
|
||||||
nats.PublishRequest(fmt.Sprintf("homeassistant.attributues.%s.%s", message.Event.Data.EntityId, message.Event.Data.NewState.State), data, defaultTimeout, 2)
|
nats.Publish(fmt.Sprintf("homeassistant.attributues.%s.%s", message.Event.Data.EntityId, message.Event.Data.NewState.State), data)
|
||||||
} else {
|
} else {
|
||||||
nats.Publish(fmt.Sprintf("homeassistant.states.%s.%s", message.Event.Data.EntityId, message.Event.Data.NewState.State), data)
|
nats.PublishRequest(fmt.Sprintf("homeassistant.states.%s.%s", message.Event.Data.EntityId, message.Event.Data.NewState.State), data, defaultTimeout, 2)
|
||||||
}
|
}
|
||||||
case zhaEventId:
|
case zhaEventId:
|
||||||
data, _ := json.Marshal(message.Event.Data)
|
data, _ := json.Marshal(message.Event.Data)
|
||||||
|
|
Loading…
Reference in New Issue