node-red/node-red-dashboard

topic value of numeric 0 passed to ue-switch oes not show when switch toggled

Closed this issue · 1 comments

What are the steps to reproduce?

Import the following flow:
h[{"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":1,"width":0,"height":0,"passthru":false,"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":2,"width":0,"height":0,"passthru":false,"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","order":1,"disabled":false,"hidden":false}]

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

What happens?

If a msg, with a topic of a numeric sero (0) is passed to the switch node and the switch is flipped in the dashboard, no topic is returned from the ui-switch node. Other number postive or negative will result in a topic showing in the msg out of the ui-switch node.

What do you expect to happen?

Zero should be handled and passed out in the msg from the ui-switch node

Please tell us about your environment:

  • Node-RED-Dashboard version: v3.2.0
  • Node-RED version: v3.0.2
  • node.js version: v14.16.0
  • npm version: v6.14.11
  • Platform/OS: MacOS (user reported it on Windows_NT)
  • Browser: Safari

As Steve guessed - it is the usual simple javascript falsey test tripping up the beforeSend function
Need to check other ui nodes as well.