Simple LED indicator on dashboard

Hi,
This is definitely a noob question, I’ve only been using Node-RED (and Dashboard) for a couple of days.

This may be as simple as I don’t know the right words to search.

I want to display a “blob” (round, rectangular…) on my dashboard to indicate On/Off, Stop/Go, etc. based on a value.

But, I don’t see anything like it in the dashboard palette and I’ve not found any “how to” help on the web.

I’m happy to go read and experiment, so, pointers are welcome.

“Hey you missed this obvious…” is also welcome. :wink:

1 Like

Here is one pointer for you :slight_smile: https://discourse.nodered.org/t/led-icon-changed/656

Thanks, I read that one before I posted. That is above my 2 day experience level.
They discuss/display code that they obviously know where to put it and make it do stuff.

If that code is what it takes, then I need something that tells me what to do with the code they show.

Sharing of examples or why not entire solutions stands on import-export of flow JSON. https://discourse.nodered.org/t/how-to-import-a-flow-into-the-editor/895

Since you are only two days in then I suggest you start by getting experience with the stuff that is easy to do. In this case rather than displaying an LED indication you could use a Text node to show On/Off. This may not look quite as you would like it but functionally I would have thought it was just as good. Once you have mastered the basic principles then you can move on to more sophisticated stuff. When learning any skill it is better to start with the basics.

Thanks for the pointers. After staring at the forum posts suggested by hotNipi I realized it was really just html put in the right place that they were showing.

Just for future readers, the following in a template node will produce round LED like display:

.led-green { margin: 0 auto; width: 24px; height: 24px; background-color: #ABFF00; border-radius: 50%; {
Label

Changing "red" in the

tag will set the desired color. Replacing "red" with "{{msg.payload}}" and then passing "red", "green", etc. as the payload will set the color.
Setting the inbound msg payload to "

Cheers.

I think the forum software hosed your cut and paste. Certainly has for me in the past. Try clicking </> button for "preformatted text" and then paste it in.

I am interested in what you have done.

I created "led like" indicators in the Dashboard by using (abusing) switch buttons and changing the colors and icon picture based on the switch state. Seemed pretty round-about and ugly way to do such a simple thing, but it works fine. I admit it looks perhaps "cooler" than a simple round colored circle LED on a cellphone web-page when using the Dasboard UI I made.

I've practically no html experience so your example might actually get me to first base if I could actually see it.

Well, in a past life a did a reasonable amount of html...but, not saying this is "good" html, just working for me. :wink:
Apparently this forum attempts to interpret pasted html...and the preformatted </> breaks as soon as it hits a new tag or blank line. :frowning:

Grr...won't let me upload them because I'm a new user. WTF.

So, replace all the [ with < and ] with> in this:

[style]
.led-green {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #ABFF00;
border-radius: 50%;
{
[/style]
[table]
[tr]
[td][div class="led-green" style="background-color:{{msg.payload}}"][/div][/td]
[td]Label[/td]
[/tr]
[/table]

If you put a line containing three backtick characters on the line before the html and another such line after it then it will be passed through unchanged, eg

<style>can safely be put here</style>
<div>and other html too</div>

Now that's intuitively obvious...not. At least not to me. :face_with_raised_eyebrow:

<style>
.led-green {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #ABFF00;
border-radius: 50%;
{
</style>
<table>
<tr>
<td><div class="led-green" style="background-color:{{msg.payload}}"></div></td>
<td>Label</td>
</tr>
</table>

Thanks.

1 Like

Hey, I found that example useful! Thanks for posting. :+1:

I copied your code and installed on my dashboard and it is perfect.

Thanks

Just a note...
I subsequently added a ui_template node and pout the style tag portion of this code there.
The style tag can then be be removed from this code and all "LEDs" will reference that style.

This way changes to the style will change all "LEDs".

Probably obvious to experienced node-red users...

Hey y'all,
Looking for a similar node to what you all have described I've published a Node-RED Dashboard UI LED node available here: https://www.npmjs.com/package/node-red-contrib-ui-led

If you give it a try let me know what you think, what you like and don't like, what works and doesn't work well. Feel free to add suggestions and bugs directly into the Github issues, or PRs if you get so far! :slight_smile:

1 Like

Hi,
is it possible that the led only works in the first tab?

Thanks

Hey @anton.wieser!
I apologize for the late reply. That is the case, looking into why here, you can follow the progress here: https://github.com/Adorkable/node-red-contrib-ui-led/issues/29