How can i have a physical button that toggles a switch on the dashboard?


hi, i'm using NodeRed on my raspberry pi, and I have a physical button wired up to the GPIO pin and it works.

what's the easiest way to make a switch on the dashboard turn on if it's off, and vica versa, when i press the button?



You can change the state of a switch in the dashboard by sending it a message with either
msg.payload = true or msg.payload = false ( note they are boolean not strings)

The easiest way is therefore probably to use a change node to change the value you are getting from your physical switch into boolean true or false, before sending that to your dashboard switch



Thank you that worked and I also had to check te pass through when msg arrives