# Toggle switch initial value?

**URL:** <https://discourse.nodered.org/t/toggle-switch-initial-value/16997>\
**Category:** General\
**Created:** [22 October 2019 08:02 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997 "2019-10-22T08:02:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruraldev](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ruraldev/32/13365_2.png) [@ruraldev](https://discourse.nodered.org/u/ruraldev)\
**Post date:** [22 October 2019 08:02 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997/1 "2019-10-22T08:02:34Z")

</div>

I've got a toggle switch which triggers a MQTT node to control a heater, it works fine but the initial value is always shown as OFF even if the heater is ON.

I'm feeding the msg.payload value of "ON" into the toggle switch and I've tried using an input value of both msg.payload and {{msg.payload}} but it doesn't appear to make any difference.

Hope someone can help, it's probably something very obvious I am missing.

Node code:  
[{"id":"9a574584.75e57","type":"ui\_switch","z":"212aea8.56fb016","name":"","label":"Toggle upstairs heater","tooltip":"","group":"249cb4f3.de0cdc","order":4,"width":4,"height":1,"passthru":false,"decouple":"false","topic":"cmnd/sonoff\_garage\_upstairs/power","style":"","onvalue":"On","onvalueType":"str","onicon":"","oncolor":"","offvalue":"Off","offvalueType":"str","officon":"","offcolor":"","x":620,"y":548,"wires":[["e5e9f696.80fbc","f024e819.9aea68"]],"inputLabels":["msg.payload"]},{"id":"249cb4f3.de0cdc","type":"ui\_group","z":"","name":"Garage","tab":"e47a88e5.385c7","order":2,"disp":true,"width":"8","collapse":false},{"id":"e47a88e5.385c7","type":"ui\_tab","z":"","name":"Main","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

---

<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:** [22 October 2019 08:10 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997/2 "2019-10-22T08:10:54Z")

</div>

The input must exactly match the output... - you have set the output to "On" , but said you are sending msg.payload of "ON"

---

<div class="post-metadata">

**Author:** ![ruraldev](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ruraldev/32/13365_2.png) [@ruraldev](https://discourse.nodered.org/u/ruraldev)\
**Post date:** [22 October 2019 08:26 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997/3 "2019-10-22T08:26:37Z")

</div>

I changed everything to uppercase and debug shows all uppercase but still the switch initially shows off when the heater is ON, I've got a text node which shows the correct state (in uppercase as well)

If it helps under the node it shows lowercase on or off which doesn't match with the debug

---

<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:** [22 October 2019 09:05 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997/4 "2019-10-22T09:05:16Z")

</div>

You need to select thsi to allow messages through....

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

---

<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:** [22 October 2019 09:52 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997/5 "2019-10-22T09:52:24Z")

</div>

Alternatively, if you don't want to pass the message through (which can create an mqtt loop) but want the switch to show the current MQTT state then leave Pass Through clear and select Show State of Input.

---

<div class="post-metadata">

**Author:** ![ruraldev](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ruraldev/32/13365_2.png) [@ruraldev](https://discourse.nodered.org/u/ruraldev)\
**Post date:** [22 October 2019 10:42 UTC](https://discourse.nodered.org/t/toggle-switch-initial-value/16997/6 "2019-10-22T10:42:36Z")

</div>

When I did "show state of input" the toggle switch didn't work, however the other solution worked fine so problem solved.

Thanks to both you and dceejay
