zwave-js / zwave-js-ui

Full featured Z-Wave Control Panel UI and MQTT gateway. Built using Nodejs, and Vue/Vuetify
https://zwave-js.github.io/zwave-js-ui
MIT License
970 stars 204 forks source link

[bug] Sending ON to Multilevel Switch sets value to max instead of Previous State #1132

Closed sovapatr closed 3 years ago

sovapatr commented 3 years ago

Version

Checklist:

Build/Run method

zwavejs2mqtt: 3.5.0.42d15cb zwave-js: 7.2.4

Describe the bug

Sending an ON event to a multilevel switch (Inovelli LZW31-SN) is setting the switch to 99 instead of the last state.

To Reproduce

Steps to reproduce the behavior: zwave/dimmer_1/38/0/targetValue/set 50 zwave/dimmer_1/38/0/targetValue/set off zwave/dimmer_1/38/0/targetValue/set on

Expected behavior

I expect that the device would return to 50% when turned on, but instead a value of 99 is sent to the device.

Additional context

I believe the issue is:

    //Gateway.js
    // on/off becomes 100%/0%
    if (typeof payload === 'boolean' && valueId.type === 'number') {
      payload = payload ? valueId.max : valueId.min
    }

If I manually build and change that file to:

    //Gateway.js
    // on/off becomes 100%/0%
    if (typeof payload === 'boolean' && valueId.type === 'number') {
      payload = payload ? 0xff : valueId.min
    }

It works as I would expect. I'm not familiar enough with other zwave switches to know if inovelli is alone in sending a 255 to the Multilevel Switch channel turns the switch back to the previous state or if it is a standard method. If it is an edge case a way to manually define the "on" event would be helpful.

robertsLando commented 3 years ago

@sovapatr Would you like to send a PR with that change? It seems good to me :)