Create toggle switch


Hi there,

I am currently playing around with HomeMatic, NodeRed and some HUE lights.

What I would like to implement is a toggle switch so that I can turn a HUE light on and off by pressing the same button.

The HomeMAtic Switch is integrated via RedMatic, Hue via HueMagic.

The HomeMatic Switch is delivering a boolean "true" every time I press the button.

I can get the status of the HueLight by reading out the msg.payload.on value - this is either true or false.

What I don't seem to get working is to read out the status and dependent on the outcome change the output from the HomeMatic switch to false to then turn off the light.

In simple terms I guess I am looking for an implementation of an if statement that checks the status of the hue light but here I start to get lost :slight_smile:

Thanks so much in advance for any help



I'm not sure if I fully understand what you are trying to do.
But there are some examples in the cookbook which might help, such as


Many thanks for the links - the first one seems interesting. Will def give it a try and reply back.

Sorry if my description was not clear enough.

I habe a light which is either true (on) or false (off). This needs to be checked.
I then have a light switch which will always send true.
Dependent on the current state of the light I want the switch to trigger the opposite.

Check Light Status --> Light:OFF --> Press_Switch:True --> Light:On
Check Light Status --> LightOn --> Press_Switch:True --> Light Off

Hope this makes it a bit clearer.


YES! First link helped. Thanks a lot!