Switch a switch based on a character string

Hi

I want to switch a swich when the payload contains a specific character string. I tested different swich settings without success.

[
    {
        "id": "9bb8f01a65ff63ce",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f78742dbb56d0dd1",
        "type": "inject",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 595,
        "y": 320,
        "wires": [
            [
                "3c9a49b2a8d9d58f"
            ]
        ],
        "l": false
    },
    {
        "id": "3bc5aba81ae84f65",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 17",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1045,
        "y": 320,
        "wires": [],
        "l": false
    },
    {
        "id": "58c0f24d71127886",
        "type": "tcp in",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "server": "server",
        "host": "",
        "port": "3000",
        "datamode": "stream",
        "datatype": "utf8",
        "newline": "",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 920,
        "y": 320,
        "wires": [
            [
                "3bc5aba81ae84f65",
                "5812218f1738eafb"
            ]
        ]
    },
    {
        "id": "3c9a49b2a8d9d58f",
        "type": "tcp out",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "host": "localhost",
        "port": "3000",
        "beserver": "client",
        "base64": false,
        "end": false,
        "tls": "",
        "x": 740,
        "y": 320,
        "wires": []
    },
    {
        "id": "5812218f1738eafb",
        "type": "api-call-service",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "server": "f0bc01401120af29",
        "version": 5,
        "debugenabled": false,
        "domain": "input_text",
        "service": "set_value",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_text.etat_sonnette_portillon"
        ],
        "data": "{\"value\":msg.payload}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 860,
        "y": 460,
        "wires": [
            [
                "ca2ebf3e25e2f34f",
                "4bcbcf6f4fad09b1"
            ]
        ]
    },
    {
        "id": "ca2ebf3e25e2f34f",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 18",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1035,
        "y": 460,
        "wires": [],
        "l": false
    },
    {
        "id": "4bcbcf6f4fad09b1",
        "type": "switch",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "\"Visiteurportillon\"",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 890,
        "y": 640,
        "wires": [
            [
                "c2bc8752fb7f8a6f"
            ],
            []
        ]
    },
    {
        "id": "c2bc8752fb7f8a6f",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 19",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1050,
        "y": 640,
        "wires": []
    },
    {
        "id": "f0bc01401120af29",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]

Try removing the quotes, the quotes you see in the debug sidebar are just to show you it is a string.

How to remove quotes?
When I test from the videophone (by pressing the bell button) or from a hyperterminal, I do not put quotation marks.

The quotes you have set in the switch node "Visiteurportillon" should be Visiteurportillon
you also have a new line so prior to the switch i would trim the payload. Or add the delimiter in the tcp in node, which is probably \r or \n.

I did a lot of testing and the one with the quotes is the last one. I already tested without the quotes and without the new line I don't get anything back in node debug 19

Then trim the newline shown in the debug
e.g

[{"id":"f78742dbb56d0dd1","type":"inject","z":"9bb8f01a65ff63ce","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"Visiteurportillon\\n\"","payloadType":"json","x":675,"y":520,"wires":[["ca2ebf3e25e2f34f","08df1bd4d0f96fbd"]],"l":false},{"id":"ca2ebf3e25e2f34f","type":"debug","z":"9bb8f01a65ff63ce","name":"debug 18","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1035,"y":460,"wires":[],"l":false},{"id":"08df1bd4d0f96fbd","type":"change","z":"9bb8f01a65ff63ce","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$trim($$.payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":560,"wires":[["4bcbcf6f4fad09b1"]]},{"id":"4bcbcf6f4fad09b1","type":"switch","z":"9bb8f01a65ff63ce","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Visiteurportillon","vt":"str"},{"t":"eq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":640,"wires":[["c2bc8752fb7f8a6f"],[]]},{"id":"c2bc8752fb7f8a6f","type":"debug","z":"9bb8f01a65ff63ce","name":"debug 19","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1050,"y":640,"wires":[]}]

Or remove newline at source. Which the tcp or HA node are adding

I modified the flow but I don't know which node used at the switch output to link with Home Assistant (to trigger automation)

[
    {
        "id": "9bb8f01a65ff63ce",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f78742dbb56d0dd1",
        "type": "inject",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 595,
        "y": 320,
        "wires": [
            [
                "3c9a49b2a8d9d58f"
            ]
        ],
        "l": false
    },
    {
        "id": "3bc5aba81ae84f65",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 17",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1045,
        "y": 320,
        "wires": [],
        "l": false
    },
    {
        "id": "58c0f24d71127886",
        "type": "tcp in",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "server": "server",
        "host": "",
        "port": "3000",
        "datamode": "stream",
        "datatype": "utf8",
        "newline": "",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 920,
        "y": 320,
        "wires": [
            [
                "3bc5aba81ae84f65",
                "5812218f1738eafb"
            ]
        ]
    },
    {
        "id": "3c9a49b2a8d9d58f",
        "type": "tcp out",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "host": "localhost",
        "port": "3000",
        "beserver": "client",
        "base64": false,
        "end": false,
        "tls": "",
        "x": 740,
        "y": 320,
        "wires": []
    },
    {
        "id": "5812218f1738eafb",
        "type": "api-call-service",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "server": "f0bc01401120af29",
        "version": 5,
        "debugenabled": false,
        "domain": "input_text",
        "service": "set_value",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_text.etat_sonnette_portillon"
        ],
        "data": "{\"value\":msg.payload}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 840,
        "y": 440,
        "wires": [
            [
                "ca2ebf3e25e2f34f",
                "a3a5d4410252af26"
            ]
        ]
    },
    {
        "id": "ca2ebf3e25e2f34f",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 18",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1035,
        "y": 440,
        "wires": [],
        "l": false
    },
    {
        "id": "a3a5d4410252af26",
        "type": "change",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$trim($$.payload)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 540,
        "wires": [
            [
                "7348d868a174d4d9"
            ]
        ]
    },
    {
        "id": "7348d868a174d4d9",
        "type": "switch",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Visiteurportillon",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1040,
        "y": 540,
        "wires": [
            [
                "9c8424c2a3de3eed"
            ],
            []
        ]
    },
    {
        "id": "9c8424c2a3de3eed",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 20",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1220,
        "y": 540,
        "wires": []
    },
    {
        "id": "f0bc01401120af29",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]

Not a HA user, some here might know. But HA forum has a node-red section, where you may find more help.

I finally modified the flow this way and I retrieve the information in the input_text.etat_sonnette_portillon entity in Home Assistant.

Thanks a lot for the help.

[
    {
        "id": "9bb8f01a65ff63ce",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f78742dbb56d0dd1",
        "type": "inject",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 595,
        "y": 320,
        "wires": [
            [
                "3c9a49b2a8d9d58f"
            ]
        ],
        "l": false
    },
    {
        "id": "3bc5aba81ae84f65",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 17",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1045,
        "y": 320,
        "wires": [],
        "l": false
    },
    {
        "id": "58c0f24d71127886",
        "type": "tcp in",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "server": "server",
        "host": "",
        "port": "3000",
        "datamode": "stream",
        "datatype": "utf8",
        "newline": "",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 920,
        "y": 320,
        "wires": [
            [
                "3bc5aba81ae84f65",
                "a3a5d4410252af26"
            ]
        ]
    },
    {
        "id": "3c9a49b2a8d9d58f",
        "type": "tcp out",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "host": "localhost",
        "port": "3000",
        "beserver": "client",
        "base64": false,
        "end": false,
        "tls": "",
        "x": 740,
        "y": 320,
        "wires": []
    },
    {
        "id": "5812218f1738eafb",
        "type": "api-call-service",
        "z": "9bb8f01a65ff63ce",
        "name": "Etat sonnette portillon",
        "server": "f0bc01401120af29",
        "version": 5,
        "debugenabled": false,
        "domain": "input_text",
        "service": "set_value",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "input_text.etat_sonnette_portillon"
        ],
        "data": "{\"value\":msg.payload}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 840,
        "y": 560,
        "wires": [
            [
                "ca2ebf3e25e2f34f"
            ]
        ]
    },
    {
        "id": "ca2ebf3e25e2f34f",
        "type": "debug",
        "z": "9bb8f01a65ff63ce",
        "name": "debug 18",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1065,
        "y": 560,
        "wires": [],
        "l": false
    },
    {
        "id": "a3a5d4410252af26",
        "type": "change",
        "z": "9bb8f01a65ff63ce",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$trim($$.payload)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 590,
        "y": 560,
        "wires": [
            [
                "5812218f1738eafb"
            ]
        ]
    },
    {
        "id": "f0bc01401120af29",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]