I am using Home Assistant as my zwave hub and have several red series dimmers (LZW31-SN) around the house. I have one dimmer at the top of my stairs with an automation in HA that turns off all the downstairs lights when I double-click the the off button. This has been working great but being a tinkerer I couldn’t help but notice that the light connected the the dimmer at the top of the stairs is usually already off when I want to turn off all the downstairs lights. So I edited the automation so that:
When the off button is pressed once
If the dimmer is off
Then turn off the downstairs lights
So in theory if the dimmer is on, pressing off should only turn off the dimmer and not execute the automation. However, in practice, if the dimmer is on and I press the off button once, HA sees the dimmer as off, returns true for the “device off” condition, and executes the automation to turn off the downstairs lights.
I have tested similar automations on other red series dimmers in my house where they turn off other devices when the off button is pressed once only if the dimmer itself is already off and they work as expected. The only difference is that the problematic switch in question is wired in a 3-way with an aux switch and has Aeotec Bypass because it does not have a neutral wire. Could that be the reason why HA sees the dimmer as off when in fact it was on when the automation was triggered?
I added an Else clause to the automation to turn off the downstairs lights so it now reads like this:
When the off button is pressed once
If the dimmer is off
Then turn off the downstairs lights
Else, turn off the dimmer
And now it works as it should. It should work as predicted without the Else clause though, since pressing the off button without any automation still turns off the dimmer (smart bulb mode is not enabled). So it appears to be a small quirk with either the switch itself or how it is wired in the no-neutral 3-way.
Update: it seems adding the Else clause only temporarily rectified the issue. Even with the Else clause, the automation is still triggered when pressing the off button while the switch is on, even though it should only trigger when it is off. I tried a similar automation on another red series dimmer (i.e., when off button pressed, if switch is off, do x, but if switch is on, do y) and the same thing is happening (switch is on but x is happening).
It’s a race condition. The switch reports it’s off before HA gets to the condition.
The dimmers are handled rather oddly in HA. They don’t use on and off, they use the dim level, 0 =off and 1-99 = on level. Possibly you can do something with that.
I encountered this before. I have an automation where if the living room lights are on and motion is detected in the kitchen, the kitchen lights get turned on. It wasn’t working with on/off. I ended up making “on” correspond to 15% brightness or higher. Otherwise it’s off. Here’s the template I use:
{% set brightness = states.light.living_room_lights.attributes.brightness %}
{% if brightness != None %}
{% set brightness = (brightness / 252 * 100) %}
{% set brightness = brightness | int %}
{% else %}
{% set brightness = 0 %}
{% endif %}
{{brightness >= 15}
Edit: didn’t even realize this post was from 4 months ago, whoops! Hopefully someone finds this helpful.