OpenZWave / Zwave2Mqtt

Fully configurable Zwave to MQTT gateway and Control Panel using NodeJS and Vue
MIT License
354 stars 93 forks source link

Turning off switch briefly reports it as back on in homeassistant, before showing off [question] #838

Open vvuk opened 3 years ago

vvuk commented 3 years ago

I've got a Zooz ZEN15 power switch for a high-wattage device. When I turn the device off via homeassistant, the device's state flicks back to on.. and only some seconds later goes back off. If I look at the zwave2mqtt logs I see this:

z2m:Mqtt Message received on zwave2mqtt/5/37/1/0/set +1m
z2m:Zwave zwave node 5: changed: 50-1-2:Electric - W:4.692 -> 0 +2s
z2m:Zwave zwave node 5: changed: 50-1-256:Exporting:false -> false +1ms
z2m:Zwave zwave node 5: changed: 50-1-2:Electric - W:0 -> 0 +23ms
z2m:Zwave zwave node 5: changed: 50-1-256:Exporting:false -> false +4ms
z2m:Zwave Notification from node 5: Notification - TimeOut (1) +9s
z2m:Zwave zwave node 5: changed: 37-1-0:Switch:true -> false +692ms
z2m:Zwave zwave node 5: changed: 37-1-0:Switch:false -> false +23ms

I'm guessing what's happening is hass sends the mqtt message to set the device to off. Homeassistant then refreshes the state of the device, and sees that it's still on -- or that the persistent state is still on (I need to go actually look at the physical switch to see how quickly the device responds). Some seconds later, there's a zwave timeout, and then the switch finally responds with the new state. Note that the power draw went to 0 watts within 2 seconds, so I think the switch actually responds fairly quickly; just the state doesn't get communicated.

I'm fairly new to doing zwave through mqtt -- I'm not even quite sure where to begin here. Any suggestions would be appreciated. Thanks!

idlezombie commented 3 years ago

Have you set the qos in z2m?

I saw similar behavior in hass with my aeotec dual nanos, they all started behaving a lot better after setting z2m config for mqtt to retain and qos 2.

https://assetwolf.com/learn/mqtt-qos-understanding-quality-of-service#:~:text=Quality%20of%20Service%20%28QoS%29%20in%20MQTT%20messaging%20is,at%20these%20in%20more%20detail%20in%20a%20moment.

robertsLando commented 3 years ago

I would suggest to set the qos to 0 and enable retain flag

vvuk commented 3 years ago

QoS is set to 0 and retain is enabled. I saw in the z-wave log that there are some timeouts from this device; will dig into that too.

robertsLando commented 3 years ago

@vvuk Also keep an eye to: https://github.com/zwave-js/zwavejs2mqtt. It's very close to a first release