# Examples of Colour change button and switch

**URL:** <https://discourse.nodered.org/t/examples-of-colour-change-button-and-switch/3650>\
**Category:** FAQs\
**Created:** [3 October 2018 08:24 UTC](https://discourse.nodered.org/t/examples-of-colour-change-button-and-switch/3650 "2018-10-03T08:24:07Z")\
**Posts on this page:** 1\
**Showing post:** 30

<div class="post-metadata">

**Author:** ![SilverApe](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@SilverApe](https://discourse.nodered.org/u/SilverApe)\
**Post date:** [17 December 2019 13:37 UTC](https://discourse.nodered.org/t/examples-of-colour-change-button-and-switch/3650/30 "2019-12-17T13:37:43Z")

</div>

Almost works! When I us my home automation app the state of the button changes, great! When I press the button in the NR dashboard I can only turn it off. When I try to turn it on again it changes to the faded green and does not turn to green. The light stays off.

This is how my switch works, maybe this will make things clearer.

```auto
[{"id":"e0bdc90f.9b5bc8","type":"ui_switch","z":"de809454.b77458","name":"Woonkamer spot","label":"Woonkamer spot","tooltip":"","group":"2c6d1750.5266c8","order":1,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"homie/homey-topic/woonkamer-spot/onoff/set","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-2x fa-lightbulb-o","oncolor":"#FFE400","offvalue":"false","offvalueType":"bool","officon":"fa-2x fa-lightbulb-o","offcolor":"#686441","x":670,"y":200,"wires":[["67b8512d.07884"]]},{"id":"67b8512d.07884","type":"mqtt out","z":"de809454.b77458","name":"MQTT Light transmit","topic":"homie/homey-topic/woonkamer-spot/onoff/set","qos":"","retain":"","broker":"49dffeeb.596af","x":900,"y":200,"wires":[]},{"id":"ae04b460.4d45d8","type":"mqtt in","z":"de809454.b77458","name":"MQTT receiver","topic":"homie/homey-topic/woonkamer-spot/onoff","qos":"2","datatype":"auto","broker":"49dffeeb.596af","x":200,"y":200,"wires":[["d0f75779.4d5af8"]]},{"id":"d0f75779.4d5af8","type":"function","z":"de809454.b77458","name":"Convert string to Boolean","func":"\nif(msg.payload === \"true\"){ msg.payload = true; }else{ msg.payload = false; } return msg;","outputs":1,"noerr":0,"x":430,"y":200,"wires":[["e0bdc90f.9b5bc8"]]},{"id":"2c6d1750.5266c8","type":"ui_group","z":"","name":"Lampen","tab":"11324097.cc662f","order":1,"disp":false,"width":"5","collapse":false},{"id":"49dffeeb.596af","type":"mqtt-broker","z":"","name":"Homey MQTT","broker":"192.168.1.22","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"11324097.cc662f","type":"ui_tab","z":"","name":"Dash","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

_[View the full topic](https://discourse.nodered.org/t/examples-of-colour-change-button-and-switch/3650)._
