# Mqtt to node red dashbord led

**URL:** <https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789>\
**Category:** Dashboard\
**Created:** [8 December 2024 21:04 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789 "2024-12-08T21:04:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhmmad](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@muhmmad](https://discourse.nodered.org/u/muhmmad)\
**Post date:** [8 December 2024 21:04 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/1 "2024-12-08T21:04:51Z")

</div>

I'm trying to send this data via mqtt  
{

```
"LED": "true"

```

}

and I'm using node-red-contrib-ui-led : ui\_led, but I can't configure the led , any help with code and steps

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 December 2024 21:54 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/2 "2024-12-08T21:54:54Z")

</div>

Welcome to the forum @muhmmad

The default setup of the LED node seems to be that a payload of false will turn it red, while a payload of true will turn it green (you can of course change the colours and trigger values).

So for example `{"payload": true}` should turn the LED green.

1. Your payload is an object `{"LED": "true"}`.
2. `"true"` is a string, it is not equal to the boolean value `true`.

Try a couple of inject nodes, injecting boolean values and wired to the LED.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7ee552b9e2cbd2b9705ea6bebe1679e8d5c50d40.png)

---

<div class="post-metadata">

**Author:** ![muhmmad](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@muhmmad](https://discourse.nodered.org/u/muhmmad)\
**Post date:** [9 December 2024 04:01 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/3 "2024-12-09T04:01:41Z")

</div>

@jbudd Thank you for your reply , I'm taking the output from the mqtt in node and connect it with function and then to the led node like the screenshot

 ![Screenshot 2024-12-09 at 5.58.57 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50a6731cdfdc4f58dfddfba0ad621ecd976d3b86.png)

also sending you the LED node settings , and I tried to send {"LED": true} it's not working , I think it's from the function code

 ![Screenshot 2024-12-09 at 6.00.04 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/389fb29470ed645ca78b6fd41e38b49f0ee54f8d.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [9 December 2024 08:50 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/4 "2024-12-09T08:50:16Z")

</div>

I think you are confusing yourself with the function code. You do not need it.

Put a debug node after your MQTT-in.  
You need to know the datatype and the value.  
In this example the datatype is `string` and the value is `on` but yours will probably be different.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/ba1f149625797f334a707563773d2d3b9dbe645b.png)

The LED node lets you specify the colour for any payload.  
Change the settings so that it matches what your MQTT-in is receiving. - here I have set it so that a string payload of `on` will be red and `off` will be blue.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/ae68e5af3b833680e78efec5bd74516262637a57.png)

---

<div class="post-metadata">

**Author:** ![muhmmad](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@muhmmad](https://discourse.nodered.org/u/muhmmad)\
**Post date:** [9 December 2024 09:10 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/5 "2024-12-09T09:10:22Z")

</div>

@jbudd the debug node says it's an object and led node doesn't read object

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [9 December 2024 09:14 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/6 "2024-12-09T09:14:12Z")

</div>

Show me the debug output.

---

<div class="post-metadata">

**Author:** ![muhmmad](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@muhmmad](https://discourse.nodered.org/u/muhmmad)\
**Post date:** [9 December 2024 09:17 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/7 "2024-12-09T09:17:30Z")

</div>

@jbudd

 ![Screenshot 2024-12-09 at 11.16.58 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/2085f4597a11bb168cbefc33473e7d01c68ce751.png)

this is mqtt explorer

 ![Screenshot 2024-12-09 at 11.19.43 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6b5539d79b999bf2be9a32a2462e5b59b649b598.jpeg)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [9 December 2024 09:27 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/8 "2024-12-09T09:27:34Z")

</div>

Use a change node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/3/d39e2ddcc493350453f30cab9f3e9edceabdcdd9.png)

---

<div class="post-metadata">

**Author:** ![muhmmad](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@muhmmad](https://discourse.nodered.org/u/muhmmad)\
**Post date:** [9 December 2024 09:31 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/9 "2024-12-09T09:31:03Z")

</div>

@jbudd My friend ,I really don't know how to thank you !!! it works , thank you very very much

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 December 2024 09:31 UTC](https://discourse.nodered.org/t/mqtt-to-node-red-dashbord-led/93789/10 "2024-12-23T09:31:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
