AND - how it works?

Hello, starting, would need some infos pls!

[
    {
        "id": "092520097a3dcc4c",
        "type": "victron-input-system",
        "z": "7978e0ce1be8e6fb",
        "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": 160,
        "y": 60,
        "wires": [
            [
                "8d3e188d3bb213c2",
                "8f7751900ce13e11"
            ]
        ]
    },
    {
        "id": "8f7751900ce13e11",
        "type": "limit-monitor",
        "z": "7978e0ce1be8e6fb",
        "name": "lower limit",
        "topic": "",
        "limit": "65",
        "kind": "1",
        "delay": "0",
        "hysteresis": "0",
        "x": 430,
        "y": 80,
        "wires": [
            [
                "826d727d6717c7fa",
                "be8c435f27d8a2db"
            ]
        ]
    },
    {
        "id": "8d3e188d3bb213c2",
        "type": "limit-monitor",
        "z": "7978e0ce1be8e6fb",
        "name": "upper limit",
        "topic": "",
        "limit": "60",
        "kind": "2",
        "delay": "0",
        "hysteresis": "0",
        "x": 430,
        "y": 40,
        "wires": [
            [
                "826d727d6717c7fa"
            ]
        ]
    },
    {
        "id": "826d727d6717c7fa",
        "type": "and",
        "z": "7978e0ce1be8e6fb",
        "name": "",
        "topic": "",
        "property": "payload",
        "minData": "1",
        "filter": false,
        "x": 590,
        "y": 60,
        "wires": [
            [
                "0137ea2a0adbd59d",
                "37b45ff69e780207"
            ]
        ]
    },
    {
        "id": "37b45ff69e780207",
        "type": "debug",
        "z": "7978e0ce1be8e6fb",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 760,
        "y": 40,
        "wires": []
    },
    {
        "id": "be8c435f27d8a2db",
        "type": "debug",
        "z": "7978e0ce1be8e6fb",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 120,
        "wires": []
    }
]

What node have you installed that gives you the And gate? Possibly node-red-contrib-something,

1 Like

Hello and welcome to the Node-RED forum.

Just checking... are your nodes 'Home Assistant' nodes (as I don't recognise the colour/shape of them) ?
If they are - then I doubt if anyone will be able to help as most people on this forum don't use HA.

1 Like

this node-red is installed on a Victron Cerbo GX device
which pallet should I install to have node-red logics?

maybe I installed the wrong one?
Bildschirmfoto 2024-02-19 um 09.55.00

I have not used that node, but it looks ok. Have you remembered to make sure that the two inputs have different topics as described in the help text? If you have then add another debug showing what is coming out of the upper limit node and show us what you see in the debug pane showing the inputs and outputs.

I'd not heard of that platform until today.
Looks like that version of Node-RED has a mixture of styles of nodes.
It will be interesting to hear what you discover using @Colin suggestion.

still I am not familiar with the coding on nodes, maybe the topic is set wrong? tried different thins on A, or "A" or (A)... nothing does the job
the value changes, I do not get a debug out of the upper node (where the value is ok)
is that the problem, that they do not feed simultainously true or false?


I've just imported your flow on one of my Raspberry Pi platforms.
This is what I get... lots of unknown nodes (so maybe going to be difficult to help you).

I am asking for standard behavior, use other nodes that work for you.
I just want to check a value to be in a range, the end should be a relais is activated/deactivated

For that you can use a Switch node (not ui_switch) that directs the message to different outputs dependent on the value.
Send it to output 1 if less then your lower limit, output 2 if greater than your upper limit and Otherwise to output 3. Then the in range messages will appear on output 3.

1 Like

Can you explain a bit about the desired "logic"?
I can see you have battery voltage as an input and a test for an upper and lower value.

So in words can you say something like...
"When the battery voltage is 60V or above do this..."
"When the battery voltage is 40V or below do this..."

The flow you posted has a sort of hysteresis effect - is that what you intended?

Not sure what you are trying to do with the AND gate.

is used in between, or does it need to go through 3 outputs?
getting the value out, would need true/false?

simple comparism, if the value is inside a range -> out true to acrivate a relais, if not deactivate

I would not have said to send it to three outputs if that was not necessary. Then in the outputs you can use Change nodes to set the relay values.

As a beginner I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

1 Like

I think this is what @Colin is suggesting...
filter

Here's my flow - you can 'copy' it and 'import' it into Node-RED.

[{"id":"a6d89fd07304fbc4","type":"inject","z":"1774ba78f53ce4da","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"60","payloadType":"num","x":290,"y":820,"wires":[["af09aaf230403cbf"]]},{"id":"af09aaf230403cbf","type":"switch","z":"1774ba78f53ce4da","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"60","vt":"num"},{"t":"lte","v":"40","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":450,"y":880,"wires":[["e4611d2839ba3057"],["cc71a1ca97d548fc"],["637f3df30e0bb242"]]},{"id":"6bd8322efbe8a4ef","type":"comment","z":"1774ba78f53ce4da","name":"Upper = 60, Lower = 40","info":"","x":500,"y":800,"wires":[]},{"id":"e4611d2839ba3057","type":"debug","z":"1774ba78f53ce4da","name":"High","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":840,"wires":[]},{"id":"7b6fb2795e5c12f9","type":"inject","z":"1774ba78f53ce4da","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":290,"y":940,"wires":[["af09aaf230403cbf"]]},{"id":"8271b696f0de1cfe","type":"inject","z":"1774ba78f53ce4da","name":"50","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":290,"y":880,"wires":[["af09aaf230403cbf"]]},{"id":"cc71a1ca97d548fc","type":"debug","z":"1774ba78f53ce4da","name":"Low","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":880,"wires":[]},{"id":"637f3df30e0bb242","type":"debug","z":"1774ba78f53ce4da","name":"In range","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":920,"wires":[]}]
1 Like

thx!! I understand, the "in range" shows the correct value, how do I get a true/false?

Try this using a 'function' node.
filter_3

[{"id":"a6d89fd07304fbc4","type":"inject","z":"1774ba78f53ce4da","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"60","payloadType":"num","x":290,"y":820,"wires":[["af09aaf230403cbf","40cf7ea0d27d6bc0"]]},{"id":"af09aaf230403cbf","type":"switch","z":"1774ba78f53ce4da","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"60","vt":"num"},{"t":"lte","v":"40","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":450,"y":880,"wires":[["e4611d2839ba3057"],["cc71a1ca97d548fc"],["637f3df30e0bb242"]]},{"id":"6bd8322efbe8a4ef","type":"comment","z":"1774ba78f53ce4da","name":"Upper = 60, Lower = 40","info":"","x":500,"y":800,"wires":[]},{"id":"e4611d2839ba3057","type":"debug","z":"1774ba78f53ce4da","name":"High","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":840,"wires":[]},{"id":"7b6fb2795e5c12f9","type":"inject","z":"1774ba78f53ce4da","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":290,"y":940,"wires":[["af09aaf230403cbf","40cf7ea0d27d6bc0"]]},{"id":"8271b696f0de1cfe","type":"inject","z":"1774ba78f53ce4da","name":"50","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":290,"y":880,"wires":[["af09aaf230403cbf","40cf7ea0d27d6bc0"]]},{"id":"cc71a1ca97d548fc","type":"debug","z":"1774ba78f53ce4da","name":"Low","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":880,"wires":[]},{"id":"637f3df30e0bb242","type":"debug","z":"1774ba78f53ce4da","name":"In range","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":920,"wires":[]},{"id":"40cf7ea0d27d6bc0","type":"function","z":"1774ba78f53ce4da","name":"function 8","func":"if (msg.payload >= 60 || msg.payload <= 40) {\n    node.status({fill:\"red\",shape:\"dot\",text:\"Out of range\"});\n    msg.payload = false;\n}\nelse {\n    node.status({fill:\"green\",shape:\"dot\",text:\"In range\"});\n    msg.payload = true;\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":1040,"wires":[["89102cc53f5dc444"]]},{"id":"89102cc53f5dc444","type":"debug","z":"1774ba78f53ce4da","name":"debug 416","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":1040,"wires":[]}]
1 Like

yes that works, but I am not familiar with Java, still need to learn it of course...
so I would need a std. node to change the "in range" to a true/false signal

Use change nodes, set payload to true or false. (high/low = false, in range = true for example)

Please note:
It is Java-Script NOT Java - two completely different languages. Make sure you learn the right one (ha, ha).

Please node:
The flow I posted above will output 'true' or 'false' - check the output on the 'To my relay' debug node.
debug_node

1 Like

sry, do not get the point in editing the change node, there is comming a value or not from the switch node

the function generates true/false, but would like to do the job without java-script