AND - how it works?

I would recommend to watch all the videos in this playlist to get an understanding how node-red works - takes 45 mins but it will clear up a lot of concepts that you are currently struggling with.

1 Like

could you pls show me the inside of the "set msg.payload to true", thx

already watching the videos

set_to_true

1 Like

The dropdown next to "to the value" allows you to set several different datatypes.
For boolean there is also a dropdown at the right to choose true or false.

It takes a while to start to grasp how Node-red does things but it quickly gets easier.

Ask again if you still cannot work it out after watching the videos. Note that @bakman2's post was just to give you an idea, the values set in the change node must be whatever you need for the three conditions.

msg.payload (value) to boolean
just to be sure, a value above 0,00001 will be true, 0 = false ? no it doesnt.

Not sure what the value 0.00001 has to do with Boolean values.

Boolean values represent the two truth values: true or false. In programming, these values are often used in conditional statements, logical operations, and decision-making processes.
Boolean values can only be one of two states - true or false. True represents a condition that is considered as "yes" or "correct," while false represents a condition that is "no" or "incorrect."

So in the flow above the test for... "Is the battery voltage equal to or above 60 - results in "yes" or "no" or "True" or "False".

I think a simple explanation of "data-types", including Boolean, is covered in the videos.

just watched the videos, some new infos, some I will never use, also a bit difficult becouse it is not my motherlanguage.

verry interesting on watching the options node red delivers, but nothing detailed for me solve my problem.

So what problem do you have remaining?

Just looked on the website at some of the example-flows for your Victron Cerbo GX.
If you scroll down, towards the end of the web-page, there is an example of how to operate a relay.

It shows to drive a relay, a "logic" level is used (NOT Boolean).
driving_relay
The settings inside the UI-Switch node - note the payload type is numeric and the use of msg.topic
UI_switch

1 Like
[{"id":"3aa1e2ee83a6814b","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"8cb30f11bbe52e11","type":"junction","z":"3aa1e2ee83a6814b","x":340,"y":200,"wires":[["8d3e188d3bb213c2","8f7751900ce13e11"]]},{"id":"d0235022e8e3ac29","type":"junction","z":"3aa1e2ee83a6814b","x":260,"y":380,"wires":[["8cb30f11bbe52e11"]]},{"id":"5f1c92dcce75788f","type":"junction","z":"3aa1e2ee83a6814b","x":660,"y":260,"wires":[["5102d56c371856d8"]]},{"id":"092520097a3dcc4c","type":"victron-input-system","z":"3aa1e2ee83a6814b","service":"com.victronenergy.system/0","path":"/Dc/Battery/Voltage","serviceObj":{"service":"com.victronenergy.system/0","name":"Venus system"},"pathObj":{"path":"/Dc/Battery/Voltage","type":"float","name":"Battery voltage (V)"},"name":"","onlyChanges":false,"x":170,"y":200,"wires":[["8cb30f11bbe52e11"]]},{"id":"bad4236f5c9f4a03","type":"comment","z":"3aa1e2ee83a6814b","name":"@victronenergy/node-red-contrib-victron","info":"","x":180,"y":60,"wires":[]},{"id":"8f7751900ce13e11","type":"limit-monitor","z":"3aa1e2ee83a6814b","name":"lower limit","topic":"","limit":"65","kind":"2","delay":"0","hysteresis":"0","x":430,"y":260,"wires":[["5ce2c0e6eab53336"]]},{"id":"8d3e188d3bb213c2","type":"limit-monitor","z":"3aa1e2ee83a6814b","name":"upper limit","topic":"","limit":"60","kind":"1","delay":"0","hysteresis":"0","x":430,"y":140,"wires":[["5ce2c0e6eab53336"]]},{"id":"cbdd1df00741ce9f","type":"comment","z":"3aa1e2ee83a6814b","name":"node-red-contrib-limit-monitor","info":"","x":490,"y":60,"wires":[]},{"id":"5d3929129c3b1b83","type":"comment","z":"3aa1e2ee83a6814b","name":"@mschaeffler/node-red-logic","info":"","x":760,"y":60,"wires":[]},{"id":"481908949239c018","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"66","payloadType":"num","x":150,"y":320,"wires":[["d0235022e8e3ac29"]]},{"id":"4bffd9320f455288","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"59","payloadType":"num","x":150,"y":440,"wires":[["d0235022e8e3ac29"]]},{"id":"24543ba8698a2033","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"62","payloadType":"num","x":150,"y":380,"wires":[["d0235022e8e3ac29"]]},{"id":"b4cb27612ef4ca81","type":"comment","z":"3aa1e2ee83a6814b","name":"upper limit 60","info":"","x":430,"y":100,"wires":[]},{"id":"27f5ec899d40ec4a","type":"comment","z":"3aa1e2ee83a6814b","name":"lower limit 65","info":"","x":430,"y":220,"wires":[]},{"id":"cb8e593b1a940cb8","type":"and","z":"3aa1e2ee83a6814b","name":"","topic":"","property":"payload","minData":"2","filter":false,"x":690,"y":380,"wires":[[]]},{"id":"fc9f21ef0ddbfa3e","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"1","payload":"true","payloadType":"bool","x":430,"y":360,"wires":[["cb8e593b1a940cb8"]]},{"id":"c3677d41a0dfbebf","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"1","payload":"false","payloadType":"bool","x":430,"y":400,"wires":[["cb8e593b1a940cb8"]]},{"id":"6445cfcc37c44c6f","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"2","payload":"true","payloadType":"bool","x":430,"y":460,"wires":[["cb8e593b1a940cb8"]]},{"id":"4f3ae1026891d662","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"2","payload":"false","payloadType":"bool","x":430,"y":500,"wires":[["cb8e593b1a940cb8"]]},{"id":"5ce2c0e6eab53336","type":"or","z":"3aa1e2ee83a6814b","name":"","topic":"","property":"payload","minData":"1","filter":false,"x":570,"y":200,"wires":[["ae8066c3ca3603f6","5f1c92dcce75788f"]]},{"id":"ae8066c3ca3603f6","type":"not","z":"3aa1e2ee83a6814b","name":"","property":"payload","showState":true,"filter":false,"x":710,"y":200,"wires":[["06e111f1cf97f8c0"]]},{"id":"06e111f1cf97f8c0","type":"debug","z":"3aa1e2ee83a6814b","name":"debug 1","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":860,"y":200,"wires":[]},{"id":"5102d56c371856d8","type":"debug","z":"3aa1e2ee83a6814b","name":"debug 2","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":860,"y":260,"wires":[]}]

Maybe this can be used?

1 Like

OR and NOT have the disadvantage that it must go through the combinations before it works correctly.

Here is a new version.

[{"id":"801010e6b3685e8c","type":"change","z":"3aa1e2ee83a6814b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":740,"wires":[["61a40aa56fb468e9"]]},{"id":"a15ccf60701e2fc5","type":"switch","z":"3aa1e2ee83a6814b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"65","vt":"str"},{"t":"lt","v":"60","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":350,"y":760,"wires":[["801010e6b3685e8c"],["801010e6b3685e8c"],["153f9e7c7d1efb73"]]},{"id":"61a40aa56fb468e9","type":"debug","z":"3aa1e2ee83a6814b","name":"debug 418","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":760,"wires":[]},{"id":"153f9e7c7d1efb73","type":"change","z":"3aa1e2ee83a6814b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":780,"wires":[["61a40aa56fb468e9"]]},{"id":"ee50ab62820198de","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"66","payloadType":"num","x":130,"y":700,"wires":[["f92b643bb36afe53"]]},{"id":"280db08726887f51","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"59","payloadType":"num","x":130,"y":820,"wires":[["f92b643bb36afe53"]]},{"id":"31837a601c20afeb","type":"inject","z":"3aa1e2ee83a6814b","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"62","payloadType":"num","x":130,"y":760,"wires":[["f92b643bb36afe53"]]},{"id":"37be05a0c0af4489","type":"debug","z":"3aa1e2ee83a6814b","name":"debug 419","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":370,"y":800,"wires":[]},{"id":"f92b643bb36afe53","type":"junction","z":"3aa1e2ee83a6814b","x":240,"y":760,"wires":[["a15ccf60701e2fc5","37be05a0c0af4489"]]}]
1 Like
  • I was blocked by the forum as new by 24h.... sry

I do know what booleans and the rest are
I ask for the node settings to get boolean out, your change node, does only change the output to a boolean yes, this is not what I am looking for. your function node does it correct. true and false output.

still looking to standard nodes to get a true/false out of my value in range or not. This is all.
the next step is to summery (OR) more conditions on setting the Relais.

  • the samples did help me a lot, now it is working

@Frida's last suggestion should do what you want, being exactly what I suggested earlier. A Switch node to determine in range or not and then Change nodes to set the payload as you want. Have you tried it yet?

A change node using JSONata will output true/false, If you want it in one node like the function node.
e.g.

[{"id":"a6d89fd07304fbc4","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"60","payloadType":"num","x":390,"y":5140,"wires":[["6a0e9665632f90ca"]]},{"id":"6a0e9665632f90ca","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload < 60 and $$.payload > 40","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":5260,"wires":[["89102cc53f5dc444"]]},{"id":"7b6fb2795e5c12f9","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":390,"y":5260,"wires":[["6a0e9665632f90ca"]]},{"id":"8271b696f0de1cfe","type":"inject","z":"d1395164b4eec73e","name":"50","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":390,"y":5200,"wires":[["6a0e9665632f90ca"]]},{"id":"89102cc53f5dc444","type":"debug","z":"d1395164b4eec73e","name":"debug 416","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":5360,"wires":[]}]

have tried it, works, all fine now
THX to all!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.