lorenwest / node-red-contrib-state

Node-RED shared logical state with persistence, notification, and history
MIT License
7 stars 6 forks source link

state updated altough state did not change value #5

Closed wzbfyb closed 4 years ago

wzbfyb commented 4 years ago

Hi,

I noticed that on one use case, the state is updated although the value stays the same. Thus also the getState node fires. I mitigate this by adding a switch after the getState to compare value with prev, but it's strange!

grafik

I have not debugged it yet, but I think the reason is that I typed it boolean with "on"/"off" as keywords

grafik

but the payload I save from MQTT is actually "ON"/"OFF". it seems to work, but your comparison here: if (newState === node.value) {return}

may thinks that "OFF" != "off":

clicking on the ON inject always fires a state change, although the typed value of your node does not change: grafik

If I leave the state type as String, the case of ON and OFF is preserved and the node does NOT fire again. So it is an issue with boolean type only.

lorenwest commented 4 years ago

Thank you for that thorough explanation. You are correct that the node should not fire based on the input not matching the output, it should fire based on an actual change in the output.

Fixed and published today in node-red-contrib-state@1.5.1

Let me know if this resolves this issue.

wzbfyb commented 4 years ago

thanks a lot, will give it a try. it is not on npm yet, still 1.5.0 on my palette

LG

Am 02.09.2020 um 02:37 schrieb Loren West notifications@github.com:

Thank you for that thorough explanation. You are correct that a boolean node should not fire based on the input not matching the output, it should fire based on an actual change in the output.

Fixed and published today in node-red-contrib-state@1.5.1

Let me know if this resolves this issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lorenwest/node-red-contrib-state/issues/5#issuecomment-685208280, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANT4DUKM5TZJIZIIPHIR2JDSDWHVNANCNFSM4QRIPZ5Q.

lorenwest commented 4 years ago

Node-RED has a problem identifying new NPM versions. Try this in a terminal window:

npm info node-red-contrib-state version

You may need to go to your node-red directory that contains node_modules and do an npm install node-red-contrib-state instead of the pallette.

wzbfyb commented 4 years ago

that worked, thanks. and it now works as expected, thanks a lot!

Am 03.09.2020 um 18:26 schrieb Loren West notifications@github.com:

Node-RED has a problem identifying new NPM versions. Try this in a terminal window:

npm info node-red-contrib-state version You may need to go to your node-red directory that contains node_modules and do an npm install node-red-contrib-state instead of the pallette.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lorenwest/node-red-contrib-state/issues/5#issuecomment-686607365, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANT4DUKR6TTEGNSKXJ5IL7LSD67VBANCNFSM4QRIPZ5Q.