Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT: currentValue of slow switch_multilevel jumps to target value before reporting real values #3793

Closed
3 tasks done
zargony opened this issue Jul 2, 2024 · 9 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@zargony
Copy link

zargony commented Jul 2, 2024

Checklist

  • I am not using Home Assistant. Or: a developer has told me to come here.
  • I have checked the troubleshooting section and my problem is not described there.
  • I have read the changelog and my problem is not mentioned there.

Deploy method

Docker

Z-Wave JS UI version

9.14.4.40080a1

ZwaveJS version

12.12.1

Describe the bug

When setting targetValue of a device with switch_multilevel command class, currentValue is set to target value even before the device reports an updated real current value. I observe this behavior with (relatively slow) window blinds (Fibaro Roller Shutter 2 FGRM-222). I assume that zwave-js-ui might set currentValue to targetValue to provide faster responses. While this works e.g. with lights, it gives strange effects with slowly moving devices like window blinds.

E.g. if currentValue is 99 and setting targetValue to 70, you can observe currentValue:

  • currentValue: 99
  • set targetValue to 70
  • (with no visible delay) currentValue: 70
  • (~5s delay) currentValue: 84
  • (~5s delay) currentValue: 70

This causes strange effects when software tries to derive the direction of movement by looking at currentValue, e.g. when using MQTT values to feed Node-RED's HomeKit integration with a window blind position, it sees currentValue changing from 70 to 84 and shows an opening animation even though the blinds are closing.

zwave-js-ui log (unrelated lines about http requests, lastActive and power level reporting stripped):

2024-07-02 11:16:38.275 INFO MQTT: Message received on zwave/rollo_buero/switch_multilevel/endpoint_0/targetValue/set: '70'
2024-07-02 11:16:38.278 INFO Z-WAVE: Writing 70 to 4-38-0-targetValue
2024-07-02 11:16:38.386 INFO Z-WAVE: [Node 004] Value updated: 38-0-targetValue 99 => 70
2024-07-02 11:16:38.382 DEBUG MQTT: Publishing to zwave/rollo_buero/switch_multilevel/endpoint_0/targetValue: { time: 1684293578956, value: 70 } with options { qos: 1, retain: true }
2024-07-02 11:16:38.393 DEBUG MQTT: Publishing to zwave/rollo_buero/switch_multilevel/endpoint_0/currentValue: { time: 1719911798390, value: 70 } with options { qos: 1, retain: true }
2024-07-02 11:16:38.396 INFO Z-WAVE: [Node 004] Value updated: 38-0-currentValue 99 => 70
2024-07-02 11:16:43.513 DEBUG MQTT: Publishing to zwave/rollo_buero/switch_multilevel/endpoint_0/currentValue: { time: 1719911803510, value: 84 } with options { qos: 1, retain: true }
2024-07-02 11:16:43.516 INFO Z-WAVE: [Node 004] Value updated: 38-0-currentValue 70 => 84
2024-07-02 11:16:50.987 DEBUG MQTT: Publishing to zwave/rollo_buero/switch_multilevel/endpoint_0/currentValue: { time: 1719911810983, value: 70 } with options { qos: 1, retain: true }
2024-07-02 11:16:50.991 INFO Z-WAVE: [Node 004] Value updated: 38-0-currentValue 84 => 70

Actually, this log looks like the device is reporting 99=>70, so I'm unsure about the root cause. I initially suspected zwave-js-ui to do this (because why should a device report an estimated value while it knows the real current value).

To Reproduce

  • Using an mqtt client, locate and watch currentValue of a slowly moving device with switch_multilevel command class
  • Set a new targetValue via MQTT or web ui
  • Watch currentValue jump to the new target value immediately, then jumping back to the real current value while the device keeps reporting the current position until the target position is reached.

Expected behavior

I'd expect the currentValue to report the current value only, not the expected target value.

Additional context

I'm using Settings -> Gateway (probably unrelated to the issue, but explains the log):

  • Topic type: Named topics
  • Payload type: JSON Time-Value
  • Ignore Location: on
@zargony zargony added the bug Something isn't working label Jul 2, 2024
@kpine
Copy link
Contributor

kpine commented Jul 2, 2024

That's the intended behavior. See driver option disableOptimisticValueUpdate.

AFAIK there's no simple way to disable that, you have to use ZUI's hidden settings.

@robertsLando
Copy link
Member

@AlCalzone wondering if it could make sense to add a dedicated ui option for this? Is it usual this to create problems?

@zargony
Copy link
Author

zargony commented Jul 4, 2024

I see. Thanks for clarification. So the driver is always sending optimistic value updates unless you set this option, which disables it for all devices, I assume. For most devices, optimistic value updates are probably a good idea, e.g. with any switch_binary and fast moving switch_multilevel like lights. However with slowly moving devices like window blinds, garage doors and gates, this can cause strange effects like described above.

Having a UI option for this would be nice indeed. However I think it'd be most useful on a per-device basis. Optimistic value updates should be the default of course, but being able to disable it for a device makes a lot sense imho (even better if it would be disabled automatically for devices known to move slowly, like rollershutters)

@robertsLando
Copy link
Member

About this I need to ask to @AlCalzone as I don't think that's possible yet

@AlCalzone
Copy link
Member

See zwave-js/node-zwave-js#3892

@robertsLando
Copy link
Member

@zargony if you agree I would close this one and let you follow updates in linked issue? Or would you like to make the flag available on UI anyway?

@zargony
Copy link
Author

zargony commented Jul 5, 2024

I'm fine with tracking the upstream issue. Thanks again for the help! Depending on how zwave-js/node-zwave-js#3892 turns out, it would probable be nice to have a flag available in UI anyway. Either to switch it on/off if the driver keeps it a manual setting, or to override the automatic choice of the driver. But we can look into this in a separate issue (feature request) once such a setting is available if you prefer.

Copy link
Contributor

github-actions bot commented Oct 4, 2024

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

@github-actions github-actions bot added the Stale label Oct 4, 2024
Copy link
Contributor

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants