node-red-dashboard
node-red-dashboard copied to clipboard
A Switch widget configured to send a fixed string as the topic does not send the topic, unless a message is sent to its input.
If a Switch is configured with a fixed string as the topic then it does not send the topic unless a message is sent to its input. To replicate, import the flow below. Do not click the inject nodes. Exercise the switch in the UI and it will be seen that the topic is not sent. Now click one of the inject nodes and thereafter the configured topic will be sent when the switch is exercised. Note that the input messages have a different topic. ~~Restarting node red did not seem to be sufficient to show the problem again, I had to delete the node, Deploy, and re-import it.~~
Edit: Using Dashboard version 0.11.1, NR 3.1.3, nodejs 20.5.1
Edit: On retesting with dashboard 1.1.0, NR 3.1.5, I find that the symptom is repeatable on node red restart.
[{"id":"43d268a322a00bb8","type":"debug","z":"997da33a0beedade","name":"debug 2473","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":1020,"wires":[]},{"id":"26801ad4f7fb6aa3","type":"ui-switch","z":"997da33a0beedade","name":"","label":"string topic test switch","group":"7545fdb22e4a388c","order":0,"width":0,"height":0,"passthru":false,"topic":"some/topic","topicType":"str","style":"","className":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":570,"y":1020,"wires":[["43d268a322a00bb8"]]},{"id":"dc38f39b5ded4394","type":"inject","z":"997da33a0beedade","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"another/topic","payload":"true","payloadType":"bool","x":280,"y":1000,"wires":[["26801ad4f7fb6aa3"]]},{"id":"de7f3f046aa9dbf5","type":"inject","z":"997da33a0beedade","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"another/topic","payload":"false","payloadType":"bool","x":290,"y":1060,"wires":[["26801ad4f7fb6aa3"]]},{"id":"7545fdb22e4a388c","type":"ui-group","name":"D2 tests","page":"d7fcdd33578e5d34","width":"6","height":"1","order":-1,"showTitle":true,"className":""},{"id":"d7fcdd33578e5d34","type":"ui-page","name":"d2","ui":"ID-BASE-1","path":"/d2","layout":"flex","theme":"4bff2b59c4c518e1","order":-1,"className":""},{"id":"ID-BASE-1","type":"ui-base","name":"Dashboard","path":"/dashboard"},{"id":"4bff2b59c4c518e1","type":"ui-theme","name":"Another Theme","colors":{"surface":"#ffffff","primary":"#0094ce","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"}}]
I am also getting this problem - the Topic is not being sent properly. It also seems like it isn't receiving state information on the input side. For example, if I send an input to turn the switch on via msg.payload, the switch is not coming on.
if I send an input to turn the switch on via msg.payload, the switch is not coming on.
First, make sure you are using the latest version of the dashboard (1.0.2). If you are then check that the value you feed in exactly matches the on/off values you have specified in the node. If it still isn't working show us how you have configured the Switch and show us the payload you are feeding in.
This is still happening in 1.1.0.
In fact, there is something wrong going on with the ui_switch the very first time it is used (after a NR restart).
This is the debug the very first time it is pressed:
Upon a second click, you get this debug output:
However, the topic is not set at all...
Only way to make it work, is to inject something with a payload to true or false to "properly" initialize it.
And if I do the same test with another component (text_input), the topic is fine when setting it by "string".
Is that not exactly the problem I describe in the bug description?
@colinl : It is indeed what you said and describe. I just added my observation that there seems to be something weird also upon a fresh NR reboot.
What is the extra weirdness on NR reboot? I don't see it in your description.
It's shown in the picture of the debug output. The very first message does not have the "_client" property, while after it does. This behavior is not happening if using other widgets like ui_button (the message output keeps the same properties when sent whether it's the very first time or not).
OK.
Also, however, you say the topic is missing every time you restart node red, whereas my description says that is not the case. I will retest.
Following retest you are correct, with the latest NR and dashboard the symptom is repeatable on NR restart. I have amended the description.
The very first message does not have the "_client" property,
It seems this issue exists also when the topic is not configured with a string. I have opened a new issue for that.