Zwave2js2mqtt taking too long to turn on light

I see a 5s delay when I try to turn on any Z-wave light (mostly Leviton switches or plug in module). No such delay when turning off the light. I am using the zwave2js2mqtt addon. Per the logs I see the following
Light turned on
2021-12-03 11:18:11.981 INFO ZWAVE: Node 6: value updated: 38-0-targetValue 0 => 255
2021-12-03 11:18:17.031 INFO ZWAVE: Node 6: value updated: 38-0-targetValue 255 => 99 (I think this is the delay)
2021-12-03 11:18:17.035 INFO ZWAVE: Node 6: value updated: 38-0-duration 2s => 2s
2021-12-03 11:18:17.038 INFO ZWAVE: Node 6: value updated: 38-0-currentValue 0 => 99

Light turned off
2021-12-03 11:18:19.233 INFO ZWAVE: Node 6: value updated: 38-0-currentValue 99 => 0
2021-12-03 11:18:19.236 INFO ZWAVE: Node 6: value updated: 38-0-targetValue 99 => 0
2021-12-03 11:18:24.288 INFO ZWAVE: Node 6: value updated: 38-0-targetValue 0 => 0

Any ideas on how to resolve this? This is causing my voice commands (alexa) to timeout even though the light actually does turn on.

Regards
Amit

As you’ve said, the light turns on so there’s no delay. What is delayed is the manual refresh of the device state by the driver, which occurs ~5 seconds later. The problem is, your device does not report its new state automatically. This is common enough that the driver refreshes the state automatically. In order to support a variety of devices, it waits 5 seconds. Some lights can take more than 2 seconds to transition depending on their ramp rate (like my GE dimmers).

Unless something is changed in HA, for now if you want to avoid the delay, the easiest way is to just turn on the light with a specific brightness (the state is reported immediately). The more invasive solution is to replace the switches with products that report their state automatically.

Not sure it is a switch problem. Everything was working fine till last week. I decided to redo my HA installation this week and this problem showed up.

What does “redo” mean?

Everything you’ve described so far is normal behavior for many light switch devices using Z-Wave JS.

I reinstalled HA from scratch last week and problem showed up.

Sorry, not sure what to say then. The behavior your logs show is perfectly normal.

Here’s one of my switches:

2021-12-03 15:57:48.219 INFO ZWAVE: Node 2: value updated: 38-0-targetValue 0 => 255
2021-12-03 15:57:53.269 INFO ZWAVE: Node 2: value updated: 38-0-currentValue 0 => 25
2021-12-03 15:58:09.855 INFO ZWAVE: Node 2: value updated: 38-0-currentValue 25 => 0
2021-12-03 15:58:09.859 INFO ZWAVE: Node 2: value updated: 38-0-targetValue 255 => 0
2021-12-03 15:58:14.904 INFO ZWAVE: Node 2: value updated: 38-0-currentValue 0 => 0

The 5 second delay to refresh the value is hard-coded in the driver.

If you set an explicit brightness percent, the update is instant because the driver returns an optimistic (fake) value before it’s refreshed.

2021-12-03 16:03:54.694 INFO ZWAVE: Node 2: value updated: 38-0-currentValue 0 => 50
2021-12-03 16:03:54.698 INFO ZWAVE: Node 2: value updated: 38-0-targetValue 0 => 50
2021-12-03 16:03:59.758 INFO ZWAVE: Node 2: value updated: 38-0-currentValue 50 => 50
2021-12-03 16:04:03.574 INFO ZWAVE: Node 2: value updated: 38-0-currentValue 50 => 0
2021-12-03 16:04:03.576 INFO ZWAVE: Node 2: value updated: 38-0-targetValue 50 => 0

Another question, what addon are you using, and what is the version?

Using zwave2js2mqtt version 0.31

Notice a difference between your log and mine. In your log there is a 5s delay between target value and current value. My log has 2 target values 5s apart (one for 0->255 and another 0->99)

That’s because my switch uses an older version of the command class (38). targetValue has a dual purpose, it’s used by HA to set the brightness level, but some switches also will report the value they are being changed to. When a report comes in that contains that value, the targetValue will adjust. All three values, targetValue, duration and currentValue are from the same report.

The latest version of zwave-js has had some issues. You might try to upgrade to 0.31.1 of the addon, which was just released.