Should UI switches reflect changes made in node-red-dashboard?

2,793 views
Skip to first unread message

Dave B

unread,
Jan 1, 2017, 3:01:59 AM1/1/17
to Node-RED
I'm not sure if I'm in the right spot but if not, can you kindly point me there?

If an input is changed from high to low either by injecting a 0 or 1 to a digital switch or via some other event which sends a high/low signal it does not show within the UI that the switch has been moved high or low.  Is this a default behavior or am I missing something?  I'm very new to node-red and perhaps I'm doing something wrong or there is a better way to have some indication in the UI what the switch status is.  I've included an image to clarify what I'm asking.


Thanks much,

Dave
Untitled.jpg

Dave B

unread,
Jan 1, 2017, 6:03:52 AM1/1/17
to Node-RED
  I should note the switch not changing states is the UI switch NOT the one in the node display.  

Isn't there a way to edit a post in google groups??


Thanks much,

Dave

Mark Setrem

unread,
Jan 1, 2017, 6:24:07 AM1/1/17
to Node-RED

You need to check to see how you've configured the switch, as if you send the switch the same payload as it is configured to send it should work.

I've just tested it with a switch set to send a boolean True or False and with two inject nodes set to the same and the dashboard displayed switch state is changing for me.  

[{"id":"da95ab78.d324","type":"ui_switch","z":"7d40efdd.f39f9","name":"","label":"switch","group":"afb06e42.bb44e","order":0,"width":0,"height":0,"passthru":false,"topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":317.5,"y":156,"wires":[["b295da6e.12d14"]]},{"id":"36f757c7.c40438","type":"inject","z":"7d40efdd.f39f9","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":158.5,"y":114,"wires":[["da95ab78.d324"]]},{"id":"5b127a7.c162004","type":"inject","z":"7d40efdd.f39f9","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"x":155.5,"y":188,"wires":[["da95ab78.d324"]]},{"id":"b295da6e.12d14","type":"debug","z":"7d40efdd.f39f9","name":"","active":true,"console":"false","complete":"false","x":477.5,"y":155,"wires":[]},{"id":"afb06e42.bb44e","type":"ui_group","z":"","name":"Test","tab":"465038ed.e7bb88","order":7,"disp":true,"width":"6"},{"id":"465038ed.e7bb88","type":"ui_tab","z":"","name":"Home","icon":"home","order":"1"}]

Colin Law

unread,
Jan 1, 2017, 6:25:59 AM1/1/17
to node...@googlegroups.com
On 1 January 2017 at 11:03, Dave B <cfb...@gmail.com> wrote:
> I should note the switch not changing states is the UI switch NOT the one
> in the node display.

What payload type and values are coming from the Schedule and what
have you specified for the switch on/off values? Make sure they match
exactly.

>
> Isn't there a way to edit a post in google groups??

No, this is a mailing list. You can't edit it once it is in my inbox.

Colin

>
>
> Thanks much,
>
> Dave
>
> On Sunday, January 1, 2017 at 2:01:59 AM UTC-6, Dave B wrote:
>>
>> I'm not sure if I'm in the right spot but if not, can you kindly point me
>> there?
>>
>> If an input is changed from high to low either by injecting a 0 or 1 to a
>> digital switch or via some other event which sends a high/low signal it does
>> not show within the UI that the switch has been moved high or low. Is this
>> a default behavior or am I missing something? I'm very new to node-red and
>> perhaps I'm doing something wrong or there is a better way to have some
>> indication in the UI what the switch status is. I've included an image to
>> clarify what I'm asking.
>>
>>
>> Thanks much,
>>
>> Dave
>
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/773fb621-11ca-4d30-8884-11360adb7ec0%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Nicholas O'Leary

unread,
Jan 1, 2017, 6:30:21 AM1/1/17
to Node-RED Mailing List
No, this is a mailing list. You can't edit it once it is in my inbox.

Just to clarify, the Google Groups UI does allow you to edit posts so when someone browses the group at https://groups.google.com/group/node-red they will see your edited post. However, as Colin says, most people receive posts via email so will not be aware of your edits.

Nick




> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/773fb621-11ca-4d30-8884-11360adb7ec0%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.

Colin Law

unread,
Jan 1, 2017, 6:38:24 AM1/1/17
to node...@googlegroups.com
On 1 January 2017 at 11:30, Nicholas O'Leary <nick....@gmail.com> wrote:
>> No, this is a mailing list. You can't edit it once it is in my inbox.
>
> Just to clarify, the Google Groups UI does allow you to edit posts so when
> someone browses the group at https://groups.google.com/group/node-red they
> will see your edited post. However, as Colin says, most people receive posts
> via email so will not be aware of your edits.

I can't see how to do that, can you describe how please?

Colin
>> > email to node-red+u...@googlegroups.com.
>> > To post to this group, send email to node...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/node-red.
>> > To view this discussion on the web, visit
>> >
>> > https://groups.google.com/d/msgid/node-red/773fb621-11ca-4d30-8884-11360adb7ec0%40googlegroups.com.
>> >
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> http://nodered.org
>>
>> Join us on Slack to continue the conversation: http://nodered.org/slack
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Node-RED" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to node-red+u...@googlegroups.com.
>> To post to this group, send an email to node...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/node-red.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msgid/node-red/CAL%3D0gLsxUVCsL%3D4L6g%2Bq_k%3D6iHe8DwmyAVkE6VrXKiqSUhcbtw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/CAF%3Dvhqfe7oPiubXKndoD0mJhKAP_fBu_0GdAkZLfavrFX0i71w%40mail.gmail.com.

Nicholas O'Leary

unread,
Jan 1, 2017, 6:40:40 AM1/1/17
to Node-RED Mailing List
Huh, I take it back. I thought there was an edit option - but I was mistaken. You can delete posts, which obviously doesn't delete them from people's inboxes, but you cannot edit.

Nick


>> > To post to this group, send email to node...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/node-red.
>> > To view this discussion on the web, visit
>> >
>> > https://groups.google.com/d/msgid/node-red/773fb621-11ca-4d30-8884-11360adb7ec0%40googlegroups.com.
>> >
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> http://nodered.org
>>
>> Join us on Slack to continue the conversation: http://nodered.org/slack
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Node-RED" group.
>> To unsubscribe from this group and stop receiving emails from it, send an

>> To post to this group, send an email to node...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/node-red.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msgid/node-red/CAL%3D0gLsxUVCsL%3D4L6g%2Bq_k%3D6iHe8DwmyAVkE6VrXKiqSUhcbtw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
>
> For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send an email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Dave B

unread,
Jan 1, 2017, 6:00:10 PM1/1/17
to Node-RED
It's a relay so on payload is 0 and off is 1.  If i manually add 1/0 injects to the below node it works fine however for some reason using the schedex (even though it is sending 0/1 it doesn't change the UI switch.  Maybe you can see if I am missing something?  (Day 2 of Pi)

[{"id":"7469e392.0d8f6c","type":"schedex","z":"ed56ea4b.5ece38","name":"","suspended":false,"lat":"","lon":"-88.177771","ontime":"16:57","ontopic":"Night LEDS ON","onpayload":"0","onoffset":0,"onrandomoffset":0,"offtime":"16:58","offtopic":"Night LEDS OFF","offpayload":"0","offoffset":0,"offrandomoffset":0,"x":200,"y":300,"wires":[["38f80032.13ad2","6a0e0de1.d73fa4","ef8ad478.68f1e8","7eb1a117.0c274","7dd13ba4.e73054"]]},{"id":"6a0e0de1.d73fa4","type":"switch","z":"ed56ea4b.5ece38","name":"Relay status message","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","outputs":2,"x":540,"y":320,"wires":[["e99c0760.3ac728"],["72ba4878.cd68a8"]]},{"id":"e99c0760.3ac728","type":"trigger","z":"ed56ea4b.5ece38","op1":"Night LEDS are ON","op2":"","op1type":"str","op2type":"nul","duration":"0","extend":false,"units":"ms","reset":"","name":"","x":760,"y":280,"wires":[[]]},{"id":"72ba4878.cd68a8","type":"trigger","z":"ed56ea4b.5ece38","op1":"Night LEDS are OFF","op2":"","op1type":"str","op2type":"nul","duration":"0","extend":false,"units":"ms","reset":"","name":"","x":760,"y":320,"wires":[[]]},{"id":"7eb1a117.0c274","type":"rpi-gpio out","z":"ed56ea4b.5ece38","name":"R1","pin":"15","set":true,"level":"1","out":"out","x":490,"y":160,"wires":[]},{"id":"9aebff27.58c4a","type":"comment","z":"ed56ea4b.5ece38","name":"Night LEDS","info":"","x":190,"y":260,"wires":[]},{"id":"38f80032.13ad2","type":"ui_chart","z":"ed56ea4b.5ece38","name":"","group":"d611ddcf.40e8d","order":1,"width":"3","height":"3","label":"Night LEDS On/Off","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","ymin":"-.25","ymax":"1.25","removeOlder":"5","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"x":670,"y":180,"wires":[[],[]]},{"id":"7dd13ba4.e73054","type":"ui_switch","z":"ed56ea4b.5ece38","name":"","label":"Night LEDS","group":"d611ddcf.40e8d","order":2,"width":"3","height":"3","passthru":true,"topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":350,"y":220,"wires":[["7eb1a117.0c274","38f80032.13ad2"]]},{"id":"d611ddcf.40e8d","type":"ui_group","z":"","name":"Relays","tab":"2a3daaab.1d0ea6","order":2,"disp":true,"width":"6"},{"id":"2a3daaab.1d0ea6","type":"ui_tab","z":"","name":"Aquarium","icon":"dashboard","order":1}]

Dave B

unread,
Jan 1, 2017, 6:03:24 PM1/1/17
to Node-RED
ok so riddle me this.  I checked the debug node out of the schedex and it does not output anything.  How can it send a payload to the relay to actually turn it on/off if it isn't sending some payload?  I assume that is why the switch isn't changing but how the heck is the relay turning on if it isn't getting a payload?


On Sunday, January 1, 2017 at 2:01:59 AM UTC-6, Dave B wrote:

Dave B

unread,
Jan 1, 2017, 6:11:20 PM1/1/17
to Node-RED
Sorry to clutter this up (I hate not being able to edit) I'm an idiot. I had the debug switch OFF it is obviously sending a payload of 0 or 1 as it should yet the UI switch still does not reflect said change.  

Dave


On Sunday, January 1, 2017 at 2:01:59 AM UTC-6, Dave B wrote:

Mark Setrem

unread,
Jan 1, 2017, 6:15:23 PM1/1/17
to Node-RED




If I look at your switch node you have this (see image) where one is a string and one is a number

To avoid issues later you need to be aware of the data type of the string. see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures


 

Dave B

unread,
Jan 1, 2017, 6:56:19 PM1/1/17
to Node-RED

Yeah I was experimenting by changing between number/payload.  I'm still trying to grasp the differences here but that'll come in time.


I’m really learning a ton here.  It turns out this particular node uses on/off.  So that leaves me with two questions.

 

1.       Is this typical?  Perhaps I missed some doc somewhere that ID'd the payload input/ouput (The info tab and readme.md for this file didn’t mention this) so I made the mistake in assuming that 0/1 would be the output but the more I think about it, this has to be a versitile thing so on/off is probably easiest.

 

2.      Aside from a change node to change 0 to on and 1 to off, is there an easy way to change the payload from on/off to 0/1?

Thanks a ton guys!!

 

Dave


On Sunday, January 1, 2017 at 2:01:59 AM UTC-6, Dave B wrote:

Colin Law

unread,
Jan 2, 2017, 2:59:52 AM1/2/17
to node...@googlegroups.com
It is not only whether it is 0/1 or on/off, but whether it is the
numbers 0 and 1 or the string "0" and "1". 0 is not the same as "0".
I suggest you decide what you want to use for such values and stick
with that throughout your whole system. I would be interested in
knowing what the consensus of opinion is as to which is preferable.

As to how to change one value to another you can use the Change node to do that.

Colin
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/2fbfeeff-24f4-4b5e-a5bc-5a4752ba25cd%40googlegroups.com.

Dave B

unread,
Jan 2, 2017, 11:33:30 AM1/2/17
to Node-RED
Thanks Colin.  I guess my next question would be how do I know if the output is a string or a number if the actual character will look the same?  All things being equal would a number and a string output of 0 be the same for all intents and purposes?

Thanks
Dave

On Sunday, January 1, 2017 at 2:01:59 AM UTC-6, Dave B wrote:

Colin Law

unread,
Jan 2, 2017, 11:40:13 AM1/2/17
to node...@googlegroups.com
In the debug display it tells you the type. If you are generating it
yourself you should be able to define it. If it is coming from another
node then the node documentation should make it clear.

Colin
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/e6a2f6af-6318-4603-a7aa-9749b4f6e2c2%40googlegroups.com.

Julian Knight

unread,
Jan 2, 2017, 4:11:03 PM1/2/17
to Node-RED
Good question Colin.

I tend to use On/Off. I think that comes mainly from the tentative early steps with sensors using things like LightwaveRF and other home automation systems. Also, it is a little more clear, I personally think, as to whether you are receiving valid data or not.0/1 or true/false are too easily misinterpreted.

On Monday, 2 January 2017 07:59:52 UTC, Colin Law wrote:
...  I would be interested in

Dave B

unread,
Jan 2, 2017, 4:13:51 PM1/2/17
to Node-RED
I do like on/off also as sometimes 0/1 don't represent on/off the same.  IE I have some relays that need a low input whereas others need a high input so 0 would be on for one but off for the other.  So my question again would be, when given a preconfigured node module (I don't know the technical term) how do you know if the output is a number or a string?

Dave

Dave B

unread,
Jan 2, 2017, 4:17:33 PM1/2/17
to Node-RED
NM, see the debug area where it states number/string.  
 Fail...


On Sunday, January 1, 2017 at 2:01:59 AM UTC-6, Dave B wrote:

Colin Law

unread,
Jan 2, 2017, 4:18:13 PM1/2/17
to node...@googlegroups.com
On 2 January 2017 at 21:13, Dave B <cfb...@gmail.com> wrote:
> I do like on/off also as sometimes 0/1 don't represent on/off the same. IE
> I have some relays that need a low input whereas others need a high input so
> 0 would be on for one but off for the other. So my question again would be,
> when given a preconfigured node module (I don't know the technical term) how
> do you know if the output is a number or a string?

If it is not clear from the documentation of the node then attach a
Debug node to it and see what it says. With the debug node set to show
(for example) msg.payload then the first line of the output tells you
the type. For example it may say something like "msg : string [32]"
meaning that it is a 32 character string.

Colin
Reply all
Reply to author
Forward
0 new messages