Make light switch toggles more responsive on zwave-js

I have several z-wave dimmer switches, and I have always found it mildly frustrating that when I toggle one of them on, the switch in the UI doesn’t immediately stay on. My assumption has been that the dimmer doesn’t report its new value right away to my z-wave hub. The behavior is this - I toggle the switch on in the UI; it immediately turns off (although the light itself goes on); and after some significant delay, the switch in the UI goes back on to reflect the actual state of the light.

Even worse, if I ask an Echo device to turn one of my lights on, Alexa reports that my device is not responding (even though the light does turn on).

Here’s my solution - a simple automation that asks zwave-js to immediately refresh the light’s value as soon as it is turned on. It’s so simple that I’m surprised this isn’t default behavior. I would love to know if I’m actually missing something, and a configuration tweak would take care of this.

Here’s the automation:

alias: Light on update
description: ''
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: light
      service: turn_on
condition: []
action:
  - service: zwave_js.refresh_value
    target:
      entity_id: '{{ trigger.event.data.service_data.entity_id }}'
    data:
      refresh_all_values: false
mode: single

The only downside I’ve found is that this also triggers on non-z-wave lights, which creates an error in your log. No biggie, but I can’t find a way around it.

1 Like

It seems to me that your issue should really be fixed in zwave-js. Open an issue.

In the meantime…

The only way around this that I can think of is to create a group containing all your zwave lights, group.your_zwave_lights and check to see in a template condition if trigger.event.data.service_data.entity_id is in the group.

condition:
  condition: template
  value_template: "{{ trigger.event.data.service_data.entity_id in expand('group.your_zwave_lights') | map(attribute='entity_id') | list }}

@tom_l It’s always been a problem for me; it’s just somewhat worse under zwave-js (and the Echo problem is new).

I don’t think your suggestion works, because I don’t think an automation condition can reference a trigger (the automation isn’t triggered until the condition is evaluated, I believe). In any event, I believe this is why I had problems trying to do what you suggest. However, I was able to do the same thing with the condition as part of automation actions.

In my case, all of my z-wave devices (and none of my others) have “current_value” in their id. So I modified my automation as follows; this works quite well, without any errors:

alias: Light on update
description: ''
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: light
      service: turn_on
condition: []
action:
  - condition: template
    value_template: >-
      {{ trigger.event.data.service_data.entity_id |
      regex_search('(current_value)') }}
  - service: zwave_js.refresh_value
    target:
      entity_id: '{{ trigger.event.data.service_data.entity_id }}'
    data:
      refresh_all_values: false
mode: single

:man_facepalming:

:+1:

As part of some of my template switch turn on / off actions I call a service to update the sensor used in the state template (see the switches here).

It would seem that zwavejs should be able to do something similar. If a service is called to change the light state, publish that new state promptly.

I will file a bug report. I believe it has to go HA-Core first before I can report it on zwave-js.

1 Like

So it looks like there is no easy way around this in zwave-js - see https://github.com/home-assistant/core/issues/47388

It was suggested that an automation like this might be the best solution. So there it is.

1 Like