So This works as expected:
var level=global.get("cb1temp") - 2.0;
But this does not:
var level=global.get("cb1temp") + 2.0;
The only difference is that the first one correctly subtracts 2.0
from the global variable cb1temp
whereas the second one adds 0.2
(regardless of the value, 2.0 in this case....)
Am I missing something fundamental in the syntax?
I really wanted to use a global variable number in a switch node where each output was plus or minus a single variable, but think that needs j:
query string that is beyond my capability at the min....
Thanks
Here's the debug output:
Notice the set temp is 11.0
, the low number is correct at 9
, whilst the high number is 11.02
.
And here's the Function node for the high number.
Here's my flow if it helps.
[{"id":"46a21413.f5194c","type":"server-state-changed","z":"ad006b4a.4c1a08","g":"59f5633d.67713c","name":"CoolBox 1 Temp","server":"32f2c474.d2eeec","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.cb1_temp","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":1040,"y":1184,"wires":[["c0092ed4.e226f"]]},{"id":"c0092ed4.e226f","type":"function","z":"ad006b4a.4c1a08","g":"59f5633d.67713c","name":"Set GlobalVar CB1 - cb1temp","func":"var level=msg.payload;\nglobal.set(\"cb1temp\", level);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1336,"y":1184,"wires":[["70d86437.e413fc","b1cb9902.6678b8"]]},{"id":"70d86437.e413fc","type":"function","z":"ad006b4a.4c1a08","g":"59f5633d.67713c","name":"Set low level","func":"var level=global.get(\"cb1temp\") - 2.0;\nglobal.set(\"cb1templo\", level);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1558,"y":1184,"wires":[[]]},{"id":"b1cb9902.6678b8","type":"function","z":"ad006b4a.4c1a08","g":"59f5633d.67713c","name":"Set high level","func":"var level=global.get(\"cb1temp\") + 2.0;\nglobal.set(\"cb1temphi\", level);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1568,"y":1216,"wires":[[]]},{"id":"32f2c474.d2eeec","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]