Node-red-contrib-boolean-logic

Hi,

after a lot googleing and searching in this forum (without success), I decided to open a new topic.
I have no experience in programming :wink:

Acutally I canĀ“t get the node-red-contrib-boolean-logic "AND" running.
Here is my current flow:

[
    {
        "id": "a06e8018b1704b0f",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": ""
    },
    {
        "id": "963717d20a3edc72",
        "type": "inject",
        "z": "a06e8018b1704b0f",
        "name": "trigger",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 450,
        "y": 300,
        "wires": [
            [
                "2aba1c1629e748b5"
            ]
        ]
    },
    {
        "id": "d087b46150f1879c",
        "type": "inject",
        "z": "a06e8018b1704b0f",
        "name": "trigger",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 450,
        "y": 340,
        "wires": [
            [
                "f019ed65ead5e776"
            ]
        ]
    },
    {
        "id": "2aba1c1629e748b5",
        "type": "trigger",
        "z": "a06e8018b1704b0f",
        "name": "true5s",
        "op1": "true",
        "op2": "false",
        "op1type": "bool",
        "op2type": "bool",
        "duration": "5000",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "false",
        "bytopic": "all",
        "topic": "on_off:true",
        "outputs": 1,
        "x": 590,
        "y": 300,
        "wires": [
            [
                "a9a6089bf5593a78",
                "6f37650026621006"
            ]
        ]
    },
    {
        "id": "f019ed65ead5e776",
        "type": "trigger",
        "z": "a06e8018b1704b0f",
        "name": "true5s",
        "op1": "true",
        "op2": "false",
        "op1type": "bool",
        "op2type": "bool",
        "duration": "5000",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "false",
        "bytopic": "all",
        "topic": "on_off:true",
        "outputs": 1,
        "x": 590,
        "y": 340,
        "wires": [
            [
                "a9a6089bf5593a78",
                "6f37650026621006"
            ]
        ]
    },
    {
        "id": "a9a6089bf5593a78",
        "type": "debug",
        "z": "a06e8018b1704b0f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 260,
        "wires": []
    },
    {
        "id": "dfc1b2830593df69",
        "type": "debug",
        "z": "a06e8018b1704b0f",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 320,
        "wires": []
    },
    {
        "id": "6f37650026621006",
        "type": "BooleanLogic",
        "z": "a06e8018b1704b0f",
        "name": "",
        "operation": "AND",
        "inputCount": 2,
        "topic": "result",
        "x": 750,
        "y": 320,
        "wires": [
            [
                "dfc1b2830593df69"
            ]
        ]
    }
]

Would be great if someone could give me a hint...

The AND logic node uses msg.topic to distinguish between the two inputs.

If you add msg.topic to your two inject nodes, using two different topics, it should work.
Alternatively, you could add msg.topic using change nodes.

I finally got it, thanks!
But I only can inject msg.topic via the inject nodes.

Is it easy to convert a bool value (which is sent via MQTT) into a msr.topic in order to use it as a trigger for AND?

If the data arrives via mqtt it will already have msg.topic. As long as the two inputs don't have the same topic (eg sensors/door and sensors/window) you shouldn't need to do anything.
But you can use a change mode to set msg.topic

Ok, I try to seperate the massage in another way tomorrow.

Are you trying to do an AND of two values that are in the same message?

Sorry for not answering!
I figured it out by using the change node: I changed payload to topic. not pretty but it works :slight_smile:

[
    {
        "id": "aac0bf696ba6908d",
        "type": "change",
        "z": "d6aef09d.37155",
        "name": "topic + true",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "topic",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1230,
        "y": 1540,
        "wires": [
            [
                "10f7766c5fdf8ea8"
            ]
        ]
    }
]

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