s1r-J / node-red-contrib-loop-processing

Node-RED nodes to help flow looping.
https://www.npmjs.com/package/node-red-contrib-loop-processing
Apache License 2.0
12 stars 21 forks source link

Comparing identical values returns false #4

Closed thucar closed 5 years ago

thucar commented 5 years ago

I'm storing a value in a flow variable. Then when a new value comes in, I compare it with the stored value. If they differ, I execute a while loop and correct the value until they match. However, for the While loop returns TRUE with this expression msg.payload != flow.tiltAngle even though both values are identical numeric values (-40 in this case).

What am I missing here?

thucar commented 5 years ago

Well, turns out you can not use flow or global variables. Workaround is to store the flow variable inside the msg object and then compare them along these lines: msg.payload != msg.tiltAngle

s1r-J commented 5 years ago

@thucar Thank you for your reporting.

I can reproduce this phenomenon. I planed to use flow variable, so I will try to fix codes.

s1r-J commented 5 years ago

@thucar I misunderstood this module. If you want to use flow context in condition expression field, you are required to write it as follows.

msg.payload != flow.get('tiltAngle');

This is like a function node.

Cloud you try it, please?