Control dashboard UI switch via MQTT payload

I have an esp32 sending data to a MQTT server and a node-red flow subscribed which then turns relays on and off. All of the controls work perfectly but I would like to have something in the UI showing if the relays are on or off. I tried using the switches in the dashboard node and I read in the help tab it sends a true/false msg payload so I changed the code on the esp32 to send a true/false instead of 0/1(used to control gpio pins). I also tried changing the code to use on/off and still nothing.
I have been coding using python and C for years now but have never touched JavaScript let alone json. This is also my first project using node-red so I'm hoping there is a code-free solution but I'm sure I'm capable if it's not possible.
I will try upload a photo of what my UI looks like now. So I would like those switches to turn on when the relevant relay turns on but I am open to any idea that would accomplish the same goal.


Thanks in advance :slight_smile:

I tend to use the ui-led widget as it's simple and easy to implement.

Welcome to the forum @Radaga.

If you want to get it going with a switch node add a debug node showing what is going into the switch from MQTT and show us how you have configured the switch.
If you look in the switch node you will see that you can specify what you want it to send, whatever you send in must exactly match that, both in value and type (string, number or boolean).
Before replying though, since you are a beginner with node-red I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Cheers mate, that was a great help and exactly what I wanted.

Yeah I realised this when I was looking in the documentation for uiLED. Thanks for your time and the playlist recommendation