Mqtt to node red dashbord led

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

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

@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

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

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.

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.

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

Show me the debug output.

@jbudd

this is mqtt explorer

Use a change node

1 Like

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