Dashboard node does not pass on msg.topic that is a number

I just noticed a strange behaviour, and wondering if this is indented or a bug

basically dashboard UI nodes does not pass on msg.topic that is a numeric value, only pass on string value. Very strange

I tested below with switch node and drop down node, haven't test all other ui node yet

[{"id":"d97966ec59d5c097","type":"inject","z":"ce844eb7236ba48b","name":"","props":[{"p":"payload"},{"p":"topic","v":"0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1140,"y":620,"wires":[["d53a0a4bbb1a9fe3","fb20f64378eb29b3"]]},{"id":"21915a546fa229d2","type":"debug","z":"ce844eb7236ba48b","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1500,"y":620,"wires":[]},{"id":"d53a0a4bbb1a9fe3","type":"debug","z":"ce844eb7236ba48b","name":"debug 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1340,"y":680,"wires":[]},{"id":"fb20f64378eb29b3","type":"ui_switch","z":"ce844eb7236ba48b","name":"","label":"switch","tooltip":"","group":"65cfe14d065c4d4c","order":24,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1330,"y":620,"wires":[["21915a546fa229d2"]]},{"id":"65cfe14d065c4d4c","type":"ui_group","name":"VMS Page1","tab":"1cf32eaaa813c254","order":1,"disp":true,"width":"9","collapse":false,"className":""},{"id":"1cf32eaaa813c254","type":"ui_tab","name":"VMS Form","icon":"dashboard","disabled":false,"hidden":false}]

Does it pass a number less than or greater than zero?

When you say "basically dashboard UI nodes does not pass on msg.topic that is a numeric value, only pass on string value." do you mean when you press the inject node that feeds the ui-button node or when you just flip the switch on the dashboard?

what version of NR are you running?
what version of the dashboard node are you running?

If you flip the switch on the dashboard there will be no msg.topic value generated since it is creating a new msg object.

I don't fully understand how node-red memory/data store in memory works yet, but here's a more detailed test result

Step1. inject timestamp with topic as number, topic pass through the switch node as number
Step2. inject timestamp with topic as string, topic pass through the switch node as string
Step3. toggle the string switch in ui page, either on or off, topic pass through the switch node as string
Step4. toggle the number switch in ui page, either on or off, topic does not pass

19 Nov 20:14:34 - [info] Node-RED version: v3.0.2
19 Nov 20:14:34 - [info] Node.js version: v18.12.1
19 Nov 20:14:34 - [info] Windows_NT 10.0.22621 x64 LE
19 Nov 20:14:35 - [info] Loading palette nodes
19 Nov 20:14:37 - [info] Dashboard version 3.2.0 started at /ui

[
    {
        "id": "b96bd8b5a5db8dd3",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "19d3920d92883087",
        "type": "inject",
        "z": "b96bd8b5a5db8dd3",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "v": "0",
                "vt": "num"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 120,
        "wires": [
            [
                "b97be716cfbe6cd2",
                "f5de58d57a08fa9a"
            ]
        ]
    },
    {
        "id": "9aa3e16f74a36f01",
        "type": "debug",
        "z": "b96bd8b5a5db8dd3",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 120,
        "wires": []
    },
    {
        "id": "b97be716cfbe6cd2",
        "type": "debug",
        "z": "b96bd8b5a5db8dd3",
        "name": "debug 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 180,
        "wires": []
    },
    {
        "id": "f5de58d57a08fa9a",
        "type": "ui_switch",
        "z": "b96bd8b5a5db8dd3",
        "name": "",
        "label": "Number no topic",
        "tooltip": "",
        "group": "8a2eb87d8e2bccbb",
        "order": 24,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 440,
        "y": 120,
        "wires": [
            [
                "9aa3e16f74a36f01"
            ]
        ]
    },
    {
        "id": "14a403cd2558226a",
        "type": "inject",
        "z": "b96bd8b5a5db8dd3",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "0",
        "payload": "",
        "payloadType": "date",
        "x": 230,
        "y": 260,
        "wires": [
            [
                "bbf87f5763dbfe89",
                "f7042246de796dfd"
            ]
        ]
    },
    {
        "id": "32a35a44605ffde0",
        "type": "debug",
        "z": "b96bd8b5a5db8dd3",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 640,
        "y": 260,
        "wires": []
    },
    {
        "id": "bbf87f5763dbfe89",
        "type": "debug",
        "z": "b96bd8b5a5db8dd3",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 320,
        "wires": []
    },
    {
        "id": "f7042246de796dfd",
        "type": "ui_switch",
        "z": "b96bd8b5a5db8dd3",
        "name": "",
        "label": "String with topic",
        "tooltip": "",
        "group": "8a2eb87d8e2bccbb",
        "order": 24,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 440,
        "y": 260,
        "wires": [
            [
                "32a35a44605ffde0"
            ]
        ]
    },
    {
        "id": "7ea1a085ecdfcc63",
        "type": "comment",
        "z": "b96bd8b5a5db8dd3",
        "name": "Number",
        "info": "",
        "x": 190,
        "y": 80,
        "wires": []
    },
    {
        "id": "1d500d8b29dcba08",
        "type": "comment",
        "z": "b96bd8b5a5db8dd3",
        "name": "String",
        "info": "",
        "x": 190,
        "y": 220,
        "wires": []
    },
    {
        "id": "8a2eb87d8e2bccbb",
        "type": "ui_group",
        "name": "test",
        "tab": "dbf28c5fd1b0a6a4",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "dbf28c5fd1b0a6a4",
        "type": "ui_tab",
        "name": "test",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

It is only not passing the topic if the number is zero. change it to 1 or 456 and it will be passed thru.

So the real issue is that if a msg - with a topic of numeric 0 - is passed to the switch node, flipping the switch in the dashboard does not result in a topic appearing in the msg coming out of the ui-switch node. All other positive or negative numbers do pass thru.

I did test the button node and it does pass thru 0.

Looks like you found a strange edge case :+1:

@dceejay David and comments on this?

That was my theory...

Looks like JavaScript falsey weirdness strikes again.

I wonder if someone would be kind enough to raise an issue please?

1 Like

Issue raised: topic value of numeric 0 passed to ue-switch oes not show when switch toggled · Issue #784 · node-red/node-red-dashboard · GitHub

1 Like

Thanks guys for further testing and raising the bug

Thanks for finding it !