How can I toggle a group of lights (that don't go out of sync)

Hi Guys, as the title states, I'm trying to do something very simple, and it's ultimately what my goal is. I created a flow that is very simple for just 2 lights, this would be a pain if I was trying to do this for 3 lights or more. However, I can't even get it working right for 2 lights.

Here's an example of the "sync problem":

I have a button, that toggles a "group.lights", this works well if both lights are in the same state. But if they're not, then one turns on and the other turns off and vice versa.

I created a flow that checks if the first light is OFF, then check if the 2nd is OFF, then turn both ON.
if 1st is OFF but 2nd is ON then turn 2nd OFF.
if 1st is ON and 2nd is ON then turn both OFF
if 1st is ON and 2nd is OFF then turn 1st OFF

The Problem with this flow is that the 1st light never turns OFF.

I'm sure it's something I'm not doing right in node Red, My Flow isn't flowing in the right direction.
See the picture below, (you can see that the "ON" payload gets passed through the OFF, but I just want it to go through the ON instead"

Here are my node:

[{"id":"e4d94fad.c7645","type":"api-call-service","z":"c075f350.79367","name":"Living Room Lamp (Hue Group) turn_on","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_lamp_group","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1720,"y":200,"wires":[[]]},{"id":"53d54713.e7d588","type":"api-call-service","z":"c075f350.79367","name":"light.hue_mf_livingroom_tv turn_on","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.mf_livingroom_tv_hue","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1700,"y":140,"wires":[[]]},{"id":"6b895fc9.ceb7b","type":"api-current-state","z":"c075f350.79367","name":"light.living_room_lamp_group OFF?","server":"cd7bc65d.3014a8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_lamp_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1340,"y":200,"wires":[["53d54713.e7d588","e4d94fad.c7645"],["ec7b937a.82b8f"]]},{"id":"129b10ac.0a1c8f","type":"api-call-service","z":"c075f350.79367","name":"light.hue_mf_livingroom_tv turn_off","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.mf_livingroom_tv_hue","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1720,"y":280,"wires":[[]]},{"id":"ec7b937a.82b8f","type":"api-call-service","z":"c075f350.79367","name":"Living Room Lamp (Hue Group) turn_off","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.living_room_lamp_group","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1740,"y":340,"wires":[[]]},{"id":"2333401.9c194c","type":"api-current-state","z":"c075f350.79367","name":"light.mf_livingroom_tv_hue OFF?","server":"cd7bc65d.3014a8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.mf_livingroom_tv_hue","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":920,"y":220,"wires":[["6b895fc9.ceb7b"],["631eec24.a6ee44"]]},{"id":"631eec24.a6ee44","type":"api-current-state","z":"c075f350.79367","name":"light.living_room_lamp_group OFF?","server":"cd7bc65d.3014a8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_lamp_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1360,"y":280,"wires":[["129b10ac.0a1c8f"],["129b10ac.0a1c8f","ec7b937a.82b8f"]]},{"id":"cd7bc65d.3014a8","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

so ultimately, I want to know how to solve this problem in a more elegant way (ie. to accommodate more lights) but I also want to know why my flow isn't working the way I'm expecting it to.

Thanks!

Dan

I would use links like this:

[{"id":"1a0e34a1.6f491b","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"98cb60b8.519ae8","type":"link in","z":"1a0e34a1.6f491b","name":"Light 1","links":["df52c0ce.14044","db6f5598.b29f58","3df49130.d27666"],"x":930,"y":240,"wires":[["7cb591fb.9abba"]],"l":true},{"id":"7cb591fb.9abba","type":"debug","z":"1a0e34a1.6f491b","name":"light 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":240,"wires":[]},{"id":"c1328f43.0ea7b","type":"link in","z":"1a0e34a1.6f491b","name":"Light 2","links":["f60d0d93.6119d8","2a0b30cc.44ee68","a154c502.690178"],"x":930,"y":280,"wires":[["3184548d.356b54"]],"l":true},{"id":"3184548d.356b54","type":"debug","z":"1a0e34a1.6f491b","name":"light 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":280,"wires":[]},{"id":"debf6245.17cb58","type":"link in","z":"1a0e34a1.6f491b","name":"Light 3","links":["b761dd1e.d3b4f8","d5127897.6c2ef","c931478f.a0bf78"],"x":930,"y":320,"wires":[["c8541d36.143a38"]],"l":true},{"id":"c8541d36.143a38","type":"debug","z":"1a0e34a1.6f491b","name":"light 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":320,"wires":[]},{"id":"29f51b95.ca90cc","type":"link in","z":"1a0e34a1.6f491b","name":"Light 4","links":["bd2f9fd.0f0666","48e079c9.ce5438","256f1135.61d006"],"x":930,"y":360,"wires":[["86ff230.76992e"]],"l":true},{"id":"86ff230.76992e","type":"debug","z":"1a0e34a1.6f491b","name":"light 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":360,"wires":[]},{"id":"e9fae90c.9f23d8","type":"inject","z":"1a0e34a1.6f491b","name":"Group 1 ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":130,"y":100,"wires":[["682b7fcc.1a92f"]]},{"id":"df52c0ce.14044","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 1","links":["98cb60b8.519ae8"],"x":720,"y":60,"wires":[],"l":true},{"id":"f60d0d93.6119d8","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 2","links":["c1328f43.0ea7b"],"x":720,"y":100,"wires":[],"l":true},{"id":"b761dd1e.d3b4f8","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 3","links":["debf6245.17cb58"],"x":720,"y":140,"wires":[],"l":true},{"id":"bd2f9fd.0f0666","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 4","links":["29f51b95.ca90cc"],"x":720,"y":180,"wires":[],"l":true},{"id":"3df49130.d27666","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 1","links":["98cb60b8.519ae8"],"x":720,"y":480,"wires":[],"l":true},{"id":"a154c502.690178","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 2","links":["c1328f43.0ea7b"],"x":720,"y":300,"wires":[],"l":true},{"id":"c931478f.a0bf78","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 3","links":["debf6245.17cb58"],"x":720,"y":580,"wires":[],"l":true},{"id":"256f1135.61d006","type":"link out","z":"1a0e34a1.6f491b","name":"to Light 4","links":["29f51b95.ca90cc"],"x":720,"y":380,"wires":[],"l":true},{"id":"e53585a6.47399","type":"link in","z":"1a0e34a1.6f491b","name":"Group 1","links":["682b7fcc.1a92f"],"x":540,"y":120,"wires":[["df52c0ce.14044","f60d0d93.6119d8","b761dd1e.d3b4f8","bd2f9fd.0f0666"]],"l":true},{"id":"5e5d9bdf.c6a7fc","type":"link in","z":"1a0e34a1.6f491b","name":"Group 2","links":["80f7637b.49bd1"],"x":540,"y":340,"wires":[["a154c502.690178","256f1135.61d006"]],"l":true},{"id":"99bf178e.c55078","type":"link in","z":"1a0e34a1.6f491b","name":"Group 3","links":["fc0d344a.57b3b"],"x":540,"y":540,"wires":[["3df49130.d27666","c931478f.a0bf78"]],"l":true},{"id":"b9d9047.3aaaff8","type":"inject","z":"1a0e34a1.6f491b","name":"Group 1 OFF","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":130,"y":140,"wires":[["682b7fcc.1a92f"]]},{"id":"682b7fcc.1a92f","type":"link out","z":"1a0e34a1.6f491b","name":"to Group 1","links":["e53585a6.47399"],"x":330,"y":120,"wires":[],"l":true},{"id":"4f8dbffc.71881","type":"inject","z":"1a0e34a1.6f491b","name":"Group 2 ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":130,"y":320,"wires":[["80f7637b.49bd1"]]},{"id":"d4c6ab0e.24eb78","type":"inject","z":"1a0e34a1.6f491b","name":"Group 2 OFF","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":130,"y":360,"wires":[["80f7637b.49bd1"]]},{"id":"80f7637b.49bd1","type":"link out","z":"1a0e34a1.6f491b","name":"to Group 2","links":["5e5d9bdf.c6a7fc"],"x":330,"y":340,"wires":[],"l":true},{"id":"27d57e47.b4ef12","type":"inject","z":"1a0e34a1.6f491b","name":"Group 3 ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":130,"y":520,"wires":[["fc0d344a.57b3b"]]},{"id":"daa723eb.e7cf3","type":"inject","z":"1a0e34a1.6f491b","name":"Group 3 OFF","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":130,"y":560,"wires":[["fc0d344a.57b3b"]]},{"id":"fc0d344a.57b3b","type":"link out","z":"1a0e34a1.6f491b","name":"to Group 3","links":["99bf178e.c55078"],"x":330,"y":540,"wires":[],"l":true}]
1 Like

As @zenofmud said they key is to step away from the toggle and send explicit instructions.

Hey @zenofmud, thanks for this reply. Can you explain what you're calling groups? Maybe it's all the links, but i'm not getting it.

So what's missing from my original flow is the action taken to trigger this.

I have an aqara button that I'm using as a toggle:
I want to use a single press to turn on, single press to turn off.

In your first post you said you used groups. I was trying to show a way to do it

When the button is pressed, what does it send to NR?

As to my use of groups, I think I mis-interperated your issue. You want to link lights togther. In your example, you only have two lights so a simple truth table can be used.

L1 L2 Result
0 0 all on
0 1 all off
1 0 all off
1 1 all off

But what happns if Light 2 is turned off on on? Does it effect light 1? How will NR know if a light is turned on or off?

What will be the case if you expand this in the future, how will light 3 effect lights 1 and 2? Will lights be grouped by room or floor or both? As youcansee, theere is lots to think about

Hi @zenofmud, let's never mind the groups for now, as they don't work. (if light 1 in ON and light 2 is OFF if I toggle the group (group of those 2 lights) the "toggle" is out of sync.

Let me use a different example to paint a better picture:

I have a lamp on my nightstand, and my wife has her own.
we each have an aquara button.
My button's single press will toggle my light and her button's single press will toggle her light.
We have a 3rd button that's near the door, so that when you enter the room, you single press it and I want this to toggle both our lights.

This work well enough... but if her lights is ON and mine is OFF, pressing this 3rd button will just turn her's ON and turn mine ON.

the Button can do double press, which is assigned to turning off all the lights in the room. this is how I'm currently "syncing the lights".. but it's not really elegant.

Right now, I'm introducing a button in the living room, I just want it to turn on both my lamp and the led strip behind the TV. I want this button's toggle to work 100% of the time though.

My original logic in my first post makes sense to me, but I'm not sure why it's not following my bottom flow (the bottom "light.living_room_lamp_group OFF)

what happens if her light is OFF and yours is ON and someone presses it?

You need to lay out ALL the combinations and rules for what will happen in order to be able to code the logic.

As for the living room (hmmm could this be a group??) is there just one button or does the lamp have a button too? If there is just one button, then the button acts like an on/off switch and should send that command to both lights.

the living room only has 1 button.. but it's not the only way to turn lights on. you can use google, siri, alexa voice commands or home kit or home assistant app.

I believe I have already found all the possible combinations (with 2 lights, there's only 4)

I created a flow that checks if the first light is OFF, then check if the 2nd is OFF, then turn both ON.
if 1st is OFF but 2nd is ON then turn 2nd OFF.
if 1st is ON and 2nd is ON then turn both OFF
if 1st is ON and 2nd is OFF then turn 1st OFF

as my picture is showing:

if that first light is ON, I want the flow to continue to the lower part... but it's sending the ON command through the OFF flow, and then it shows ON with a red Stop.
This is the part I'm trying to resolve right now.

another way of looking at this is

  • on a button press, check state of L1 and L2
  • if L1 AND L2 are OFF turn them ON - save state of buttons
    • else turn both lights OFF - save state of buttons

So you need to save the state of the 2 lmps no matter how you turn them on or off.

How do you do that?
I've never heard of this...

On my phone now with a sleeping baby and typing it’s my thumb. I’ll answer more in a while

Ok, Let me see if I understand. You have several ways to turn on/off light 1 and light 2. In addition you have a "button"

In my example, the sections "decices controling Light 1/2" are the "several ways to turn off the lights". The inject labled 'toggle' represents the button. The two dashboard LED nodes represent the lights.

The inject nodes representing the 'other devices' only effect the light they are controlling. The 'button' will effect both lights. The `function' node contains the simplified loic of controling the lights.

[{"id":"a9144c2c.fb20f8","type":"ui_led","z":"723c5b66.a55bd4","group":"48a9824c.666e34","order":2,"width":0,"height":0,"label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"yellow","value":"ON","valueType":"str"},{"color":"gray","value":"OFF","valueType":"str"}],"allowColorForValueInMessage":false,"name":"Light 1","x":710,"y":340,"wires":[]},{"id":"d6f3331b.259b58","type":"change","z":"723c5b66.a55bd4","name":"","rules":[{"t":"set","p":"l1_state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":280,"wires":[["a9144c2c.fb20f8"]]},{"id":"e66cfe17.ddfbc8","type":"inject","z":"723c5b66.a55bd4","name":"toggle","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"pushed","payloadType":"str","x":110,"y":220,"wires":[["d36e6926.a424e8"]]},{"id":"1ffefe83.bc3249","type":"inject","z":"723c5b66.a55bd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":130,"y":520,"wires":[["d93deb0d.fecf58"]]},{"id":"6b88917e.bcaac8","type":"inject","z":"723c5b66.a55bd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":130,"y":560,"wires":[["d93deb0d.fecf58"]]},{"id":"29274409.ba2c6c","type":"comment","z":"723c5b66.a55bd4","name":"Button","info":"","x":110,"y":180,"wires":[]},{"id":"6348a5d5.1eaddc","type":"comment","z":"723c5b66.a55bd4","name":"devices controling Light 1","info":"","x":170,"y":480,"wires":[]},{"id":"b8b0e58d.7fa82","type":"change","z":"723c5b66.a55bd4","name":"","rules":[{"t":"set","p":"l2_state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":480,"wires":[["16937b2e.bd6985"]]},{"id":"c1bcba89.1d4fe","type":"inject","z":"723c5b66.a55bd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":100,"wires":[["f7a8cdfc.04f48"]]},{"id":"f7a8cdfc.04f48","type":"change","z":"723c5b66.a55bd4","name":"set states OFF","rules":[{"t":"set","p":"l1_state","pt":"flow","to":"OFF","tot":"str"},{"t":"set","p":"l2_state","pt":"flow","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":100,"wires":[[]]},{"id":"aba7221f.8d62e","type":"inject","z":"723c5b66.a55bd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":130,"y":380,"wires":[["288b694e.658676"]]},{"id":"34a86c2.a254294","type":"inject","z":"723c5b66.a55bd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":130,"y":420,"wires":[["288b694e.658676"]]},{"id":"6783344b.d0229c","type":"comment","z":"723c5b66.a55bd4","name":"devices controling Light 1","info":"","x":170,"y":340,"wires":[]},{"id":"16937b2e.bd6985","type":"ui_led","z":"723c5b66.a55bd4","group":"48a9824c.666e34","order":2,"width":0,"height":0,"label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"yellow","value":"ON","valueType":"str"},{"color":"gray","value":"OFF","valueType":"str"}],"allowColorForValueInMessage":false,"name":"Light 2","x":710,"y":540,"wires":[]},{"id":"d36e6926.a424e8","type":"function","z":"723c5b66.a55bd4","name":"","func":"var state_l1 = flow.get('l1_state')\nvar state_l2 = flow.get('l2_state')\n\nif (state_l1 == \"OFF\" & state_l2 == \"OFF\") {\n    msg.payload = \"ON\"\n} else {\n    msg.payload = \"OFF\"\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":220,"wires":[["8ca90810.143ec8","7d31f445.b6d414"]]},{"id":"8ca90810.143ec8","type":"link out","z":"723c5b66.a55bd4","name":"to Set State_l1","links":["2afb676a.861748"],"x":420,"y":200,"wires":[],"l":true},{"id":"2afb676a.861748","type":"link in","z":"723c5b66.a55bd4","name":"Set State_l1","links":["8ca90810.143ec8","288b694e.658676"],"x":730,"y":220,"wires":[["d6f3331b.259b58"]],"l":true},{"id":"288b694e.658676","type":"link out","z":"723c5b66.a55bd4","name":"to Set State_l1","links":["2afb676a.861748"],"x":420,"y":400,"wires":[],"l":true},{"id":"cae707eb.43efa","type":"link in","z":"723c5b66.a55bd4","name":"Set State_l2","links":["7d31f445.b6d414","d93deb0d.fecf58"],"x":730,"y":420,"wires":[["b8b0e58d.7fa82"]],"l":true},{"id":"7d31f445.b6d414","type":"link out","z":"723c5b66.a55bd4","name":"to Set State_l2","links":["cae707eb.43efa"],"x":420,"y":240,"wires":[],"l":true},{"id":"d93deb0d.fecf58","type":"link out","z":"723c5b66.a55bd4","name":"to Set State_l2","links":["cae707eb.43efa"],"x":420,"y":540,"wires":[],"l":true},{"id":"1ccbce89.aa5641","type":"comment","z":"723c5b66.a55bd4","name":"Initilize states to OFF","info":"","x":440,"y":60,"wires":[]},{"id":"48a9824c.666e34","type":"ui_group","name":"Default","tab":"7e36321d.94ebec","order":1,"disp":true,"width":"6","collapse":false},{"id":"7e36321d.94ebec","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

1 Like

Hi, Thanks for taking the time to help me with this.
I imported your diagram, and I have a few remarks.

  1. I didn't have the ui_led palette installed... I installed "node-red-contrib-ui-led (v. 0.4.4.4) which looks like your picture above, but I never got the LEDs to actually change colors (they're actually white like in your pic... which is wrong right? they should be yellow or grey?)

  2. the UI-LED is a unique thing, in a real-life scenario, I would be using a Call Service Node right? and with that, I need to specify "toggle, on or off"
    image

If I chose turn_on light, then regardless of which button I press, both the ON and the OFF button will turn on my light.

and if I select the toggle option for both my lights, my out of sync issue persists. if 1 light is ON and you hit the toggle button, it will turn on 1 light, and turn off the one that's on.

The clue here is in the name node-red-contrib-ui-led and the statement I made

so if you went to http://your-ip:1880/ui you should seen things like this:
Screen Shot 2021-01-15 at 12.00.15 PM
depending on which inject you pressed. I guess I should have used button nodes instead of the inject nodes.

I'm not sure what nodes you are using since you haven't told us. But don't see the need for 'toggle' because you are saving the state of the lights. You will just have to add a step the check to 'on' and change it to turn_off and vice versa.

You will have to play with the combo to make sure it is working.

so I figured it out.
I either found a bug, or I don't understand something.

First: here's my working code:

[{"id":"efcc11ce.bf0d3","type":"switch","z":"c075f350.79367","name":"Button 4 (Living Room)","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"binary_sensor.xioami_button_4","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":300,"y":320,"wires":[["501bc577.b12b6c"]]},{"id":"501bc577.b12b6c","type":"switch","z":"c075f350.79367","name":"Click Type (Single, Double, Long)","property":"payload.event.click_type","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"},{"t":"eq","v":"double","vt":"str"},{"t":"eq","v":"long_click_press","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":600,"y":320,"wires":[["117318a6.bc7e47"],[],[]]},{"id":"d50c7745.24a458","type":"server-events","z":"c075f350.79367","name":"","server":"cd7bc65d.3014a8","event_type":"xiaomi_aqara.click","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":130,"y":200,"wires":[["efcc11ce.bf0d3"]]},{"id":"2333401.9c194c","type":"api-current-state","z":"c075f350.79367","name":"light.mf_livingroom_tv_hue ON?","server":"cd7bc65d.3014a8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.mf_livingroom_tv_hue","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1030,"y":300,"wires":[["8ce1e5a2.c878c8"]]},{"id":"8ce1e5a2.c878c8","type":"switch","z":"c075f350.79367","name":"ON? or OFF?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1300,"y":300,"wires":[["503476aa.484ee8"],["ffb98b0d.89cfd8"]]},{"id":"503476aa.484ee8","type":"api-current-state","z":"c075f350.79367","name":"light.living_room_lamp_group ON?","server":"cd7bc65d.3014a8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_lamp_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1580,"y":280,"wires":[["294905a4.9ecb2a"]]},{"id":"294905a4.9ecb2a","type":"switch","z":"c075f350.79367","name":"ON? or OFF?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1860,"y":280,"wires":[["303d3c68.a9f094","39788beb.1f6b64"],["d95589eb.34b258"]]},{"id":"ffb98b0d.89cfd8","type":"api-current-state","z":"c075f350.79367","name":"light.living_room_lamp_group ON?","server":"cd7bc65d.3014a8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.living_room_lamp_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1580,"y":340,"wires":[["fc69a055.3621d"]]},{"id":"fc69a055.3621d","type":"switch","z":"c075f350.79367","name":"ON? or OFF?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1860,"y":340,"wires":[["7b549222.f6ba0c"],["5a1de9f0.df2858","3984aa32.61fdf6"]]},{"id":"303d3c68.a9f094","type":"api-call-service","z":"c075f350.79367","name":"light.hue_mf_livingroom_tv turn_off","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.mf_livingroom_tv_hue","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2160,"y":200,"wires":[[]]},{"id":"39788beb.1f6b64","type":"api-call-service","z":"c075f350.79367","name":"Living Room Lamp (Hue Group) turn_off","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.living_room_lamp_group","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2180,"y":240,"wires":[[]]},{"id":"d95589eb.34b258","type":"api-call-service","z":"c075f350.79367","name":"Living Room Lamp (Hue Group) turn_on","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_lamp_group","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2180,"y":300,"wires":[[]]},{"id":"7b549222.f6ba0c","type":"api-call-service","z":"c075f350.79367","name":"light.hue_mf_livingroom_tv turn_on","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.mf_livingroom_tv_hue","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2180,"y":360,"wires":[[]]},{"id":"5a1de9f0.df2858","type":"api-call-service","z":"c075f350.79367","name":"Living Room Lamp (Hue Group) turn_on","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_lamp_group","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2140,"y":420,"wires":[[]]},{"id":"3984aa32.61fdf6","type":"api-call-service","z":"c075f350.79367","name":"light.hue_mf_livingroom_tv turn_on","server":"cd7bc65d.3014a8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.mf_livingroom_tv_hue","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2140,"y":480,"wires":[[]]},{"id":"117318a6.bc7e47","type":"api-current-state","z":"c075f350.79367","name":"light.mf_livingroom_tv_hue ON?","server":"cd7bc65d.3014a8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.mf_livingroom_tv_hue","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":950,"y":140,"wires":[["c4c5718b.06bb"]]},{"id":"c4c5718b.06bb","type":"switch","z":"c075f350.79367","name":"ON? or OFF?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1180,"y":140,"wires":[[],["2333401.9c194c"]]},{"id":"cd7bc65d.3014a8","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

What I noticed, is that whenever I use this combination of nodes to find out what type of button pressed I pressed (single, double, or long)

the next node (that's supposed to find out what the current state of my light) will always show OFF

But the rest of the nodes states will show correctly.

so to counter this, I just doubled the nodes asking for the state of the lights. I figured that the first answer will always be OFF, but then afterwards it will show the correct answer.

This is a very hacky solution! But I'm positive that this is the root cause of all my issues because I've always tried to do these types of lights sync with these buttons.

it's just very odd that it always shows off after the Click Type... but at this point, I don't care.

1 Like

And just to conclude,

I basically made a flow for each scenario.

This isn't complicated with 2 lights... but in my Master Bed Room, I'm doing something similar with my 2 bed side tables and depending on time of day, the main ceiling light will either turn on or off with the other 2 lights.
Trying to sync 3 lights.. is just 9 possibilities instead of 4.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.