# Switch node to toggle light switch on/off

**URL:** <https://discourse.nodered.org/t/switch-node-to-toggle-light-switch-on-off/83657>\
**Category:** General\
**Created:** [13 December 2023 06:08 UTC](https://discourse.nodered.org/t/switch-node-to-toggle-light-switch-on-off/83657 "2023-12-13T06:08:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [13 December 2023 06:33 UTC](https://discourse.nodered.org/t/switch-node-to-toggle-light-switch-on-off/83657/3 "2023-12-13T06:33:23Z")

</div>

Here's a link to a thread about buttons you might find useful...

> [@One Button toggle to turn light on and off](https://discourse.nodered.org/t/one-button-toggle-to-turn-light-on-and-off/62050/2):
>
> You will need to store the previous state so that you can send the opposite state. Use context for this. e.g. [chrome\_dR7B1kkz48] [{"id":"83746a428adcbc17","type":"inject","z":"7eecf5f1d763605a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":810,"y":432,"wires":[["056008d289d9ada1"]]},{"id":"056008d289d9ada1","type":"function","z":"7eecf5f1d763605a","name":"toggle on/off","fu…

Here's the link to the tutorial I wrote for my IoT students about implementing different types of buttons...  
[http://www.resources-area.co.uk/node-red-flows/having\_fun\_with\_buttons.pdf](http://www.resources-area.co.uk/node-red-flows/having_fun_with_buttons.pdf)

---

_[View the full topic](https://discourse.nodered.org/t/switch-node-to-toggle-light-switch-on-off/83657)._
