# Control dashboard UI switch via MQTT payload

**URL:** <https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299>\
**Category:** Dashboard\
**Created:** [19 February 2021 12:17 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299 "2021-02-19T12:17:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Radaga](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@Radaga](https://discourse.nodered.org/u/Radaga)\
**Post date:** [19 February 2021 12:17 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299/1 "2021-02-19T12:17:13Z")

</div>

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.

 ![IMG_20210219_231036](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/120e677e60041e857954231f597c49284b2cb04f.jpeg)  
Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [19 February 2021 12:27 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299/2 "2021-02-19T12:27:26Z")

</div>

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

> **[node-red-contrib-ui-led](https://flows.nodered.org/node/node-red-contrib-ui-led)**
>
> A simple LED status indicator for the Node-RED Dashboard

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 February 2021 13:59 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299/3 "2021-02-19T13:59:55Z")

</div>

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](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). 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.

---

<div class="post-metadata">

**Author:** ![Radaga](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@Radaga](https://discourse.nodered.org/u/Radaga)\
**Post date:** [19 February 2021 14:02 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299/4 "2021-02-19T14:02:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Radaga](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@Radaga](https://discourse.nodered.org/u/Radaga)\
**Post date:** [19 February 2021 14:05 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299/5 "2021-02-19T14:05:24Z")

</div>

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

---

<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:** [5 March 2021 14:05 UTC](https://discourse.nodered.org/t/control-dashboard-ui-switch-via-mqtt-payload/41299/6 "2021-03-05T14:05:54Z")

</div>

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