Why does the AND not work

Good evening,
I have two Boolean values. Both of these are true. The AND element always shows unknown and gives nothing out. Where is my mistake?

[
    {
        "id": "3d846a3cec7a7d97",
        "type": "change",
        "z": "da4995d901bb5abd",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "CLOSED",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OPEN",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 580,
        "y": 180,
        "wires": [
            [
                "418f6185c0335945"
            ]
        ]
    }
]

Hi Andy,

Can't import your posted code, it will import only a change node, the other nodes are missing.

You have only posted one Change node so it's difficult to advise. But in that node you change OPEN to true and CLOSED to true.

So I suggest you check for similar typos elsewhere.

Edit: I can see the word "false" up there in your post but it doesn't show false when I import it.

[
    {
        "id": "da4995d901bb5abd",
        "type": "tab",
        "label": "Flow 11",
        "disabled": false,
        "info": ""
    },
    {
        "id": "cd2329869f578bf5",
        "type": "openhab2-in",
        "z": "da4995d901bb5abd",
        "name": "",
        "controller": "2341e6d1c1f117f5",
        "itemname": "FensterDurchgangszimmerlinks_OpenClose",
        "x": 290,
        "y": 120,
        "wires": [
            [
                "d1e942d83e070aef"
            ],
            []
        ]
    },
    {
        "id": "d1e942d83e070aef",
        "type": "change",
        "z": "da4995d901bb5abd",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "CLOSED",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OPEN",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 620,
        "y": 120,
        "wires": [
            [
                "418f6185c0335945"
            ]
        ]
    },
    {
        "id": "35d8f708c4eab8a5",
        "type": "openhab2-in",
        "z": "da4995d901bb5abd",
        "name": "",
        "controller": "2341e6d1c1f117f5",
        "itemname": "FensterDurchgangszimmerrechts_OpenClose",
        "x": 270,
        "y": 200,
        "wires": [
            [
                "3d846a3cec7a7d97"
            ],
            []
        ]
    },
    {
        "id": "3d846a3cec7a7d97",
        "type": "change",
        "z": "da4995d901bb5abd",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "CLOSED",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OPEN",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 580,
        "y": 180,
        "wires": [
            [
                "418f6185c0335945"
            ]
        ]
    },
    {
        "id": "418f6185c0335945",
        "type": "BooleanLogic",
        "z": "da4995d901bb5abd",
        "name": "",
        "operation": "AND",
        "inputCount": "2",
        "topic": "result",
        "x": 860,
        "y": 160,
        "wires": [
            [
                "01f457d68cf6d103"
            ]
        ]
    },
    {
        "id": "01f457d68cf6d103",
        "type": "debug",
        "z": "da4995d901bb5abd",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1070,
        "y": 200,
        "wires": []
    },
    {
        "id": "2341e6d1c1f117f5",
        "type": "openhab2-controller",
        "name": "Ziegler",
        "protocol": "http",
        "host": "192.168.178.YYY",
        "port": "8080",
        "path": "",
        "username": "oh.NODERED.xyzz",
        "password": ""
    }
]
[
    {
        "id": "da4995d901bb5abd",
        "type": "tab",
        "label": "Flow 11",
        "disabled": false,
        "info": ""
    },
    {
        "id": "cd2329869f578bf5",
        "type": "openhab2-in",
        "z": "da4995d901bb5abd",
        "name": "",
        "controller": "2341e6d1c1f117f5",
        "itemname": "FensterDurchgangszimmerlinks_OpenClose",
        "x": 290,
        "y": 120,
        "wires": [
            [
                "d1e942d83e070aef"
            ],
            []
        ]
    },
    {
        "id": "d1e942d83e070aef",
        "type": "change",
        "z": "da4995d901bb5abd",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "CLOSED",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OPEN",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 620,
        "y": 120,
        "wires": [
            [
                "418f6185c0335945"
            ]
        ]
    },
    {
        "id": "35d8f708c4eab8a5",
        "type": "openhab2-in",
        "z": "da4995d901bb5abd",
        "name": "",
        "controller": "2341e6d1c1f117f5",
        "itemname": "FensterDurchgangszimmerrechts_OpenClose",
        "x": 270,
        "y": 200,
        "wires": [
            [
                "3d846a3cec7a7d97"
            ],
            []
        ]
    },
    {
        "id": "3d846a3cec7a7d97",
        "type": "change",
        "z": "da4995d901bb5abd",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "CLOSED",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OPEN",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 580,
        "y": 180,
        "wires": [
            [
                "418f6185c0335945"
            ]
        ]
    },
    {
        "id": "418f6185c0335945",
        "type": "BooleanLogic",
        "z": "da4995d901bb5abd",
        "name": "",
        "operation": "AND",
        "inputCount": "2",
        "topic": "result",
        "x": 860,
        "y": 160,
        "wires": [
            [
                "01f457d68cf6d103"
            ]
        ]
    },
    {
        "id": "01f457d68cf6d103",
        "type": "debug",
        "z": "da4995d901bb5abd",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1070,
        "y": 200,
        "wires": []
    },
    {
        "id": "2341e6d1c1f117f5",
        "type": "openhab2-controller",
        "name": "Ziegler",
        "protocol": "http",
        "host": "192.168.178.XX",
        "port": "8080",
        "path": "",
        "username": "xxxxxxx",
        "password": ""
    }
]

Sorry, that won't import either, click the "Preformatted text" button then paste over the highlighted line.
Done...

Hi, in order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json

1 Like

Do your inputs have msg.topic set?
Try setting two different topics in the change nodes.

The importing false as true is a problem at my end, it imports OK on another computer.

Andy

You have a couple issues in your change nodes. You have:
Screen Shot 2021-10-18 at 2.40.25 PM
and you are replacing the values you search for. That means that if you sent in the string "CLOSED and OPEN" you would end up with "true and true" so unless both inputs were exactly same thing, the result will always be FALSE. If you sent "valve 2 is open" and "valve 4 is open" you would still get a FALSE becasue the replace would return the messages "valve 2 is true" and "xvalve 4 is true" and they don't match.

Put a debug node on the output of every node (and name them) and run your test so you can see what data is coming thru and how it will react.

@zenofmud, could there be a problem in Node-Red's import function?
If you look at the code @AndyWB first posted in this thread, it clearly shows Change string OPEN to boolean false.


What does the data coming into the two change nodes look like?

@jbudd Nope, the import imports it correctly but the search replaces only the value searched for not the entire msg.payload and the end result is a string containing the words 'true' or 'false' with what ever text was originally in the incoming msg.payload. This is why it is important to look at the data going into and out of a node when you don't get the results you expect.

That is the content of the object. I have no idea what I have to do so that I actually only get true or false.
grafik

{"_msgid":"d128fce2e164cd82","payload":true,"item":"FensterDurchgangszimmerlinks_OpenClose","event":"StateEvent"}

What node is that coming from?
Is that the incoming data?
What comes from the other node?
What is in msg.topic?What comes out of the two change nodes?

I don't think it does. I've posted about it on the 2.1.0beta.2 thread

Well then wwe need to know what version of Node-RED @AndyWB is running.
(@jbudd good spot!)

@AndyWB did you try setting msg.topic in your change nodes?

@jbudd I just checked and it imports fine in v2.0.6 so that is another 2.1.0 beta bug. Like I said good spot!

For info;

1 Like

I work with 2.0.6: Maintenance Release
I hope this will help you, to help me