# Synchronizing lights state before toggling them

**URL:** <https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722>\
**Category:** General\
**Created:** [27 July 2022 21:36 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722 "2022-07-27T21:36:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![srvmonchy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/srvmonchy/32/65323_2.png) [@srvmonchy](https://discourse.nodered.org/u/srvmonchy)\
**Post date:** [27 July 2022 21:36 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/1 "2022-07-27T21:36:41Z")

</div>

Hi there,  
Brand new on on this forum and on node red... always a first time !  
I am running node-red /w homeassistant and loving it.

I am trying to set up the long click action on a switch to toggle a group of 3 differents light. But as they can be activated by other switches I need to first synchronise their state (on or off) and then toggle them.

I start /w the device node then the call service one, but I am missing the in between action : "synchronising state"

maybe false route... let me know

Thank you for your help !!

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [27 July 2022 21:39 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/2 "2022-07-27T21:39:29Z")

</div>

What you want to do is to use the current state node - this will let you find out what the current state of each light is and then act accordingly.

I would also suggest watching this video (maybe at 1/2 speed)

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5aa300796d69492336d98fc92ed2187cf4b75095.jpeg "Node Red + Home Assistant 2022: Beginner, Advanced and EXPERT Motion Detection and Notifications") ](https://www.youtube.com/watch?v=wBUAUdLkYJM)

Craig

---

<div class="post-metadata">

**Author:** ![srvmonchy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/srvmonchy/32/65323_2.png) [@srvmonchy](https://discourse.nodered.org/u/srvmonchy)\
**Post date:** [27 July 2022 23:39 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/3 "2022-07-27T23:39:29Z")

</div>

Thanks @craigcurtin for your quick reply I watch the video at 1/4 speed, but it was on Motion Detection and Notifications... I found in his channel other very usefull video!

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [28 July 2022 00:44 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/4 "2022-07-28T00:44:26Z")

</div>

Yes it was more to show you which nodes you could use to do different things

If you look at the current state node from the home assistant webhooks palette you could then do something like

Start your flow - this would be done with

Events state - monitor for the switch press  
then into the Current state node (3 of them) each of which would check the current state of the lights  
Then into the Ultimate boolean node and onward from there.

If you look for posts from me from last week you will find a long thread where i was helping someone else do something similar in terms of finding the state of current lights etc

Craig

---

<div class="post-metadata">

**Author:** ![srvmonchy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/srvmonchy/32/65323_2.png) [@srvmonchy](https://discourse.nodered.org/u/srvmonchy)\
**Post date:** [28 July 2022 20:47 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/5 "2022-07-28T20:47:50Z")

</div>

Hi Craig,  
Thank you for your detail reply ! This is very helpfull and I will look to your other post.  
I have installed the boolean ultimate and need to get the logoc out of it.

Events state = 1 clic press on my switch  
Curent state node = if state is ON. ( one for each lights)  
Ultimate boolean is not yet clear how to uniforme the state if 1 or 2 states are different.

I will read the flow page to try to understand how the node can convert arbitrary input values to true/false.

you put me on the good way

cheers !!!

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [28 July 2022 21:47 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/6 "2022-07-28T21:47:24Z")

</div>

No worries - pretty sure i put up an example flow with the Boolean node that shows how it can act on the different states

Craig

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 September 2022 21:47 UTC](https://discourse.nodered.org/t/synchronizing-lights-state-before-toggling-them/65722/7 "2022-09-26T21:47:46Z")

</div>

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