# Problem with MQTT and switch update

**URL:** https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865
**Category:** General
**Created:** [28 August 2019 18:36 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865 "2019-08-28T18:36:08Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [28 August 2019 18:36 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/1 "2019-08-28T18:36:08Z")

</div>

Hey everybody,

I have a problem with changing the state of my switch. Some words about the setup: I am using a smart plug controlled via MQTT to switch a plug. This works so far:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d9bcbf1578408440330b1bbeeaa560771813fb10.png)  
The problem: I am also switching the plug using my Alexa. If this happens, the switch is in the wrong position, obviously ... So I connect the MQTT-input "couchlicht" to the switch "couchlich".  
What happens: Alexa can't switch, because it is forced... What I mean: Plug:OFF, say Alexa to turn it on, turns on, but turns OFF again immediately - or even worse: turns OFF and ON \>10 times per second ...  
So I tried to change the option of the switch to  
Pass though `msg` if payload matches new state FALSE  
Switch icon shows state of the input  
In this case, the state of the switch is updated sometime, sometimes it sticks to OFF, don't know why ...  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/873d0eba8b4bc692b26d0cb08079667dd0d36d3c.png)  
Also I can't switch in the dashboard anymore. With "... shows state of the output" it's vice versa.  
So how can I update the switch properly?  
Hope you can help me!

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [28 August 2019 18:45 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/2 "2019-08-28T18:45:11Z")

</div>

which version of the dashboard do you have ? - there were some recent fixes to this node.

---

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [28 August 2019 18:48 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/3 "2019-08-28T18:48:02Z")

</div>

2.16.0 - is this the problem?

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 August 2019 22:07 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/4 "2019-08-28T22:07:59Z")

</div>

What may help is rather than using the `switch` as both input and indication, use two `switch` nodes.  
There is also is/was a thing about the `switch` node having two _modes_.  
In one it indicates what is sent to it and the other it is a source for the output.

(@dceejay will be able to give you a better run down than I can.)

Then, with two `switch` nodes, one can be used simply as an indicator and one as an input.  
That is a way around the problem you describe. Though not very nice, I know.

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [29 August 2019 10:27 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/5 "2019-08-29T10:27:10Z")

</div>

That worked until version 2.14 but with version 2.16 one solution is to do it this way:

![switch216](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/29b42f3638190395e0a3fe83a12171825791bf1c.png)

![switch%20setting216](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0d5c24bbb47e9d3ec3ae041b2f89f0b237aed062.png)

```auto
[{"id":"4861d5bb.68746c","type":"ui_switch","z":"1d3866f1.0e8e09","name":"","label":"control","tooltip":"","group":"8bcf4352.7afe4","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":350,"y":220,"wires":[["bdf40b8e.65fbd8","97b60c95.049bf"]]},{"id":"6592697e.812898","type":"inject","z":"1d3866f1.0e8e09","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":240,"wires":[["4861d5bb.68746c"]]},{"id":"f5144e2e.25a0a","type":"inject","z":"1d3866f1.0e8e09","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":200,"wires":[["4861d5bb.68746c"]]},{"id":"bdf40b8e.65fbd8","type":"debug","z":"1d3866f1.0e8e09","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":220,"wires":[]},{"id":"97b60c95.049bf","type":"link out","z":"1d3866f1.0e8e09","name":"","links":["5ea10aea.6790d4"],"x":475,"y":160,"wires":[]},{"id":"5ea10aea.6790d4","type":"link in","z":"1d3866f1.0e8e09","name":"","links":["97b60c95.049bf"],"x":235,"y":160,"wires":[["4861d5bb.68746c"]]},{"id":"8bcf4352.7afe4","type":"ui_group","z":"","name":"Control","tab":"1ef6b756.7d01a9","order":3,"disp":true,"width":"6","collapse":false},{"id":"1ef6b756.7d01a9","type":"ui_tab","z":"","name":"Greenhouse","icon":"dashboard","order":5}]

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [29 August 2019 10:58 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/6 "2019-08-29T10:58:32Z")

</div>

If it works, good.

Thumbs up.

---

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [22 September 2019 11:48 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/7 "2019-09-22T11:48:06Z")

</div>

Hey,

thanks for the reply. Unfortunately this does not work, since when switching by Alexa, the state of the switch does not change ...

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/56981e61fde546fadae9797464fd5d4033fa5228.png)  
Any ideas?

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [22 September 2019 12:34 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/8 "2019-09-22T12:34:06Z")

</div>

Just to catch up:

The `switch` node......

Do you have the button set to pass input to output?

If you don't, that may be a problem.

(If you want post those node's flow)  
6 nodes isn't too much.

---

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [22 September 2019 14:04 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/9 "2019-09-22T14:04:29Z")

</div>

If I pass the input through, I have the problem that the state of the switch is changed very of then every second, which results in an on/off/on/off/.. - loop and the light is switched on an off all the time...

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [22 September 2019 14:51 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/10 "2019-09-22T14:51:33Z")

</div>

Did you try the example I uploaded? does it work?

---

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [22 September 2019 15:03 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/11 "2019-09-22T15:03:40Z")

</div>

Unforunately not. As you see in my comment above, MQTT is "OFF", but the switch stays "ON" on both sides...

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [22 September 2019 15:08 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/12 "2019-09-22T15:08:43Z")

</div>

Not sure I understand you, but in my example I send `true` or `false` not on or off.

---

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [22 September 2019 15:28 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/13 "2019-09-22T15:28:43Z")

</div>

Well okay ... I changed the ON/OFF to true/false ... But that is obviosly not the problem, since it is still not working.  
If the state of the lamp (MQTT) ist changed externaly (e.g. via Alexa), the button does not change, although the MQTT sends an input

Here are the nodes:  
`[{"id":"9f23ef6d.eac848","type":"mqtt in","z":"86e742aa.4f6e","name":"couchlicht","topic":"stat/couchlicht/POWER","qos":"0","datatype":"auto","broker":"787a048.474047c","x":260,"y":40,"wires":[["bbed3b5c.101e9","d3254fdf.63399"]]},{"id":"50bf574b.ec736","type":"mqtt out","z":"86e742aa.4f6e","name":"Couchlicht","topic":"cmnd/couchlicht/POWER","qos":"","retain":"","broker":"787a048.474047c","x":510,"y":140,"wires":[]},{"id":"bbed3b5c.101e9","type":"debug","z":"86e742aa.4f6e","name":"mqttCouchlichState","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":40,"wires":[]},{"id":"1cbfe08f.4e2137","type":"debug","z":"86e742aa.4f6e","name":"CouchlichtSwitch","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":200,"wires":[]},{"id":"1a2ee7e9.2fa3e","type":"ui_switch","z":"86e742aa.4f6e","name":"","label":"Couchlicht","tooltip":"","group":"9e7276e6.5d1f4","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":270,"y":140,"wires":[["50bf574b.ec736","1cbfe08f.4e2137","e64cc813.63c35"]]},{"id":"4df591d7.ec4c88","type":"inject","z":"86e742aa.4f6e","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":160,"wires":[["1a2ee7e9.2fa3e"]]},{"id":"8bc902bf.8c9678","type":"inject","z":"86e742aa.4f6e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":120,"wires":[["1a2ee7e9.2fa3e"]]},{"id":"d3254fdf.63399","type":"change","z":"86e742aa.4f6e","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"true","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":100,"wires":[["233a75a5.4367d2","1a2ee7e9.2fa3e"]]},{"id":"233a75a5.4367d2","type":"debug","z":"86e742aa.4f6e","name":"mqttCouchlichState","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":100,"wires":[]},{"id":"e64cc813.63c35","type":"link out","z":"86e742aa.4f6e","name":"","links":["e3ddbc39.5b98f8"],"x":340,"y":200,"wires":[]},{"id":"e3ddbc39.5b98f8","type":"link in","z":"86e742aa.4f6e","name":"","links":["e64cc813.63c35"],"x":220,"y":200,"wires":[["1a2ee7e9.2fa3e"]]},{"id":"787a048.474047c","type":"mqtt-broker","z":"","name":"mqttserver","broker":"10.0.0.17","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9e7276e6.5d1f4","type":"ui_group","z":"","name":"Wohnzimmer","tab":"5e73d01b.c77cd","disp":true,"width":6,"collapse":false},{"id":"5e73d01b.c77cd","type":"ui_tab","z":"","name":"Licht","icon":"dashboard","disabled":false,"hidden":false}]`

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [22 September 2019 15:38 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/14 "2019-09-22T15:38:55Z")

</div>

change the setting in your change node (Boolean not String):

 ![change](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8b7dd50bd7445abd3ea649aa31822056ffdc4681.png)

---

<div class="post-metadata">

### Author: ![HeyJonny](https://avatars.discourse-cdn.com/v4/letter/h/35a633/32.png) [@HeyJonny](https://discourse.nodered.org/u/HeyJonny)
#### Post date: [22 September 2019 15:46 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/15 "2019-09-22T15:46:14Z")

</div>

That has done the trick!! Thanks very much, now this actually quite little thing which cost me hours is finally working!!  
Thaaaank you!

That's the working example:

```auto
[{"id":"9f23ef6d.eac848","type":"mqtt in","z":"86e742aa.4f6e","name":"couchlicht","topic":"stat/couchlicht/POWER","qos":"0","datatype":"auto","broker":"787a048.474047c","x":260,"y":40,"wires":[["bbed3b5c.101e9","d3254fdf.63399"]]},{"id":"50bf574b.ec736","type":"mqtt out","z":"86e742aa.4f6e","name":"Couchlicht","topic":"cmnd/couchlicht/POWER","qos":"","retain":"","broker":"787a048.474047c","x":510,"y":140,"wires":[]},{"id":"bbed3b5c.101e9","type":"debug","z":"86e742aa.4f6e","name":"mqttCouchlichState","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":40,"wires":[]},{"id":"1cbfe08f.4e2137","type":"debug","z":"86e742aa.4f6e","name":"CouchlichtSwitch","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":200,"wires":[]},{"id":"1a2ee7e9.2fa3e","type":"ui_switch","z":"86e742aa.4f6e","name":"","label":"Couchlicht","tooltip":"","group":"9e7276e6.5d1f4","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":270,"y":140,"wires":[["50bf574b.ec736","1cbfe08f.4e2137","e64cc813.63c35"]]},{"id":"233a75a5.4367d2","type":"debug","z":"86e742aa.4f6e","name":"mqttCouchlichState","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":530,"y":100,"wires":[]},{"id":"e64cc813.63c35","type":"link out","z":"86e742aa.4f6e","name":"","links":["e3ddbc39.5b98f8"],"x":340,"y":200,"wires":[]},{"id":"e3ddbc39.5b98f8","type":"link in","z":"86e742aa.4f6e","name":"","links":["e64cc813.63c35"],"x":220,"y":200,"wires":[["1a2ee7e9.2fa3e"]]},{"id":"d3254fdf.63399","type":"change","z":"86e742aa.4f6e","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":100,"wires":[["233a75a5.4367d2","1a2ee7e9.2fa3e"]]},{"id":"787a048.474047c","type":"mqtt-broker","z":"","name":"mqttserver","broker":"10.0.0.17","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9e7276e6.5d1f4","type":"ui_group","z":"","name":"Wohnzimmer","tab":"5e73d01b.c77cd","disp":true,"width":6,"collapse":false},{"id":"5e73d01b.c77cd","type":"ui_tab","z":"","name":"Licht","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)
#### Post date: [22 September 2019 15:51 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/16 "2019-09-22T15:51:50Z")

</div>

You can simplify your flow if you change the setting in the ui-switch:

```auto
[{"id":"375931c3.7f0abe","type":"mqtt in","z":"7c6a9ec3.f1512","name":"couchlicht","topic":"stat/couchlicht/POWER","qos":"0","datatype":"auto","broker":"462b3048.b7db9","x":340,"y":1640,"wires":[["9f153f65.aa6d7","a7067cfc.45d86"]]},{"id":"1ae8d926.67e2d7","type":"mqtt out","z":"7c6a9ec3.f1512","name":"Couchlicht","topic":"cmnd/couchlicht/POWER","qos":"","retain":"","broker":"462b3048.b7db9","x":590,"y":1740,"wires":[]},{"id":"9f153f65.aa6d7","type":"debug","z":"7c6a9ec3.f1512","name":"mqttCouchlichState","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":610,"y":1640,"wires":[]},{"id":"45e54180.ebe4f","type":"debug","z":"7c6a9ec3.f1512","name":"CouchlichtSwitch","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":610,"y":1800,"wires":[]},{"id":"a7067cfc.45d86","type":"ui_switch","z":"7c6a9ec3.f1512","name":"","label":"Couchlicht","tooltip":"","group":"6972a237.54e1bc","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","x":350,"y":1740,"wires":[["1ae8d926.67e2d7","45e54180.ebe4f","e7219679.fa6af8"]]},{"id":"7cd7413c.eb42f","type":"debug","z":"7c6a9ec3.f1512","name":"mqttCouchlichState","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":610,"y":1700,"wires":[]},{"id":"e7219679.fa6af8","type":"link out","z":"7c6a9ec3.f1512","name":"","links":["f56dc2dd.4142f"],"x":420,"y":1800,"wires":[]},{"id":"f56dc2dd.4142f","type":"link in","z":"7c6a9ec3.f1512","name":"","links":["e7219679.fa6af8"],"x":300,"y":1800,"wires":[["a7067cfc.45d86"]]},{"id":"2fb810fb.7b25e","type":"inject","z":"7c6a9ec3.f1512","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1720,"wires":[["a7067cfc.45d86"]]},{"id":"5f112009.2db7c","type":"inject","z":"7c6a9ec3.f1512","name":"","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1760,"wires":[["a7067cfc.45d86"]]},{"id":"462b3048.b7db9","type":"mqtt-broker","z":"","name":"mqttserver","broker":"10.0.0.17","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"6972a237.54e1bc","type":"ui_group","z":"","name":"Wohnzimmer","tab":"bf70c920.9328f8","disp":true,"width":6,"collapse":false},{"id":"bf70c920.9328f8","type":"ui_tab","z":"","name":"Licht","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![LeelooAuto](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@LeelooAuto](https://discourse.nodered.org/u/LeelooAuto)
#### Post date: [9 April 2020 22:05 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/17 "2020-04-09T22:05:20Z")

</div>

Hi @cflurin and @HeyJonny,

I'm trying to use this same function but not having any luck with getting my MQTT output node to trigger when using my MQTT in or Inject nodes. Only the Dashboard Switch is working. Do the Link In and Link Out nodes still function as shown in the examples above or has something changed?

Any help would be appreciated

```auto
[{"id":"5c02cb03.784ce4","type":"debug","z":"d3418782.7a96e8","name":"payload out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":669,"y":375,"wires":[]},{"id":"f014ae2b.f7bf6","type":"mqtt out","z":"d3418782.7a96e8","name":"Wall Lights","topic":"backyard/wall_lights/stat","qos":"","retain":"","broker":"fe86ba0d.da2868","x":669,"y":275,"wires":[]},{"id":"a933323f.87d1b","type":"mqtt in","z":"d3418782.7a96e8","name":"Wall Lights","topic":"backyard/wall_lights/cmnd","qos":"0","datatype":"auto","broker":"fe86ba0d.da2868","x":199,"y":275,"wires":[["9b7bfe81.38803","fb17c9e6.b5b148"]]},{"id":"13dc3b53.e7d615","type":"rpi-gpio out","z":"d3418782.7a96e8","name":"Wall Lights (31)","pin":"31","set":"","level":"0","freq":"","out":"out","x":939,"y":175,"wires":[]},{"id":"9b7bfe81.38803","type":"debug","z":"d3418782.7a96e8","name":"payload in","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":429,"y":375,"wires":[]},{"id":"fb17c9e6.b5b148","type":"ui_switch","z":"d3418782.7a96e8","name":"","label":"Wall Lights","tooltip":"","group":"cd54934d.ff379","order":2,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":430,"y":275,"wires":[["f014ae2b.f7bf6","5c02cb03.784ce4","b95d337d.02e3d","d533ddfc.eba7f"]]},{"id":"b95d337d.02e3d","type":"change","z":"d3418782.7a96e8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":679,"y":175,"wires":[["13dc3b53.e7d615","176bbbff.0e1a74"]]},{"id":"bac3ec4b.86fe5","type":"inject","z":"d3418782.7a96e8","name":"ON","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":209,"y":75,"wires":[["fb17c9e6.b5b148"]]},{"id":"2e861fd4.9e5b2","type":"inject","z":"d3418782.7a96e8","name":"OFF","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":209,"y":175,"wires":[["fb17c9e6.b5b148"]]},{"id":"176bbbff.0e1a74","type":"debug","z":"d3418782.7a96e8","name":"payload change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":939,"y":275,"wires":[]},{"id":"7e91aa4d.70c154","type":"link in","z":"d3418782.7a96e8","name":"","links":["d533ddfc.eba7f"],"x":375,"y":175,"wires":[["fb17c9e6.b5b148"]]},{"id":"d533ddfc.eba7f","type":"link out","z":"d3418782.7a96e8","name":"","links":["7e91aa4d.70c154"],"x":484,"y":175,"wires":[]},{"id":"fe86ba0d.da2868","type":"mqtt-broker","z":"","name":"AutomationMQTT","broker":"192.168.1.5","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"cd54934d.ff379","type":"ui_group","z":"","name":"Lights","tab":"c3f2c080.1789d","disp":true,"width":"6","collapse":false},{"id":"c3f2c080.1789d","type":"ui_tab","z":"","name":"Backyard","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![LeelooAuto](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@LeelooAuto](https://discourse.nodered.org/u/LeelooAuto)
#### Post date: [9 April 2020 22:37 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/18 "2020-04-09T22:37:58Z")

</div>

So I think I'm misunderstanding the switch node and that the flows in the examples above are really only concerned with the switch status and not actually triggering any other out nodes.

Assuming I'll need to separate flow or change to my current flow to actually switch my rpi GPIO out for when the inject or MQTT in are triggered.

---

<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: [10 April 2020 07:42 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/19 "2020-04-10T07:42:57Z")

</div>

Welcome to the forum @LeelooAuto, I started looking at this but I am not clear what the problem you are having is, and haven't got time to start wading through an old thread to see what it is all about, so can I suggest that you start a new thread, explain exactly what you are trying to do and what you have tried and we can go from there.  
Thanks.

---

<div class="post-metadata">

### Author: ![mattrix](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mattrix](https://discourse.nodered.org/u/mattrix)
#### Post date: [26 November 2020 08:01 UTC](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865/20 "2020-11-26T08:01:41Z")

</div>

Hello,  
My turn to have same problemon similar config (RaspPi via MQTT Mosquitto)

I have simple flow with a switch and button.  
But when i switch off the light with physical switch, it does not update the state of nodered switch in nodered dashboard. (am allset in boolean)

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

Any idea welcome..

[Next page](https://discourse.nodered.org/t/problem-with-mqtt-and-switch-update/14865.md?page=2)
