Why is switch not detecting msg.number is not empty

Trying to detect presence of msg.number but this little test flow isn't working the way I think it should

can someone point out my error please?

[
    {
        "id": "c13f5e288b728ce1",
        "type": "debug",
        "z": "721af101b88d7036",
        "name": "debug 91",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 110,
        "wires": []
    },
    {
        "id": "2c83eb1b4f9b6232",
        "type": "switch",
        "z": "721af101b88d7036",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "hive boost ",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 320,
        "y": 110,
        "wires": [
            [
                "108cbb6ccd74a2ed",
                "cf738b0d0f6105aa"
            ]
        ]
    },
    {
        "id": "108cbb6ccd74a2ed",
        "type": "switch",
        "z": "721af101b88d7036",
        "name": "",
        "property": "number",
        "propertyType": "msg",
        "rules": [
            {
                "t": "nempty"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 490,
        "y": 110,
        "wires": [
            [
                "c13f5e288b728ce1"
            ]
        ]
    },
    {
        "id": "cf738b0d0f6105aa",
        "type": "debug",
        "z": "721af101b88d7036",
        "name": "debug 92",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 500,
        "y": 160,
        "wires": []
    },
    {
        "id": "dda9c034355ef2c4",
        "type": "inject",
        "z": "721af101b88d7036",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "number",
                "v": "19",
                "vt": "num"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "hive boost one nine minutes",
        "payloadType": "str",
        "x": 140,
        "y": 110,
        "wires": [
            [
                "2c83eb1b4f9b6232"
            ]
        ]
    },
    {
        "id": "7310cd17f2232891",
        "type": "inject",
        "z": "721af101b88d7036",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "hive boost on",
        "payloadType": "str",
        "x": 160,
        "y": 160,
        "wires": [
            [
                "2c83eb1b4f9b6232"
            ]
        ]
    }
]

From the node help:

The is empty and is not empty rules can be used to test the length of Strings, Arrays and Buffers, or the number of properties an Object has. Neither rule will pass if the property being tested has a boolean , null or undefined value.

1 Like

Or are you wanting to detect that the property itself is present?

Aah - that would explain why it doesn't work :frowning:

I only want the message to pass if it contains the msg.number property

This might be better?

Screenshot 2023-10-06 at 17.12.46

3 Likes

Yep - that does the job :slight_smile:

1 Like

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