# Issue with toggle action in light flow

**URL:** <https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040>\
**Category:** Flows\
**Created:** [September 1, 2021, 9:42am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040 "2021-09-01T09:42:34Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 1, 2021, 9:42am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/1 "2021-09-01T09:42:34Z")

</div>

well, so I got a toggle action, triggered by pressing a button, that switches several lights (zigbee, lifx) on or off. But then I also got a motion sensor which turns on one pair of lights (lifx).  
Now, if I press the button to switch on all lights it switches off the pair that has been switched on before.  
I was wondering if there’s something like a flow card with “Do nothing” or how else I can avoid this behavior.  
I also created an extra flow that tells if “button pressed” and “light is On” then “Switch On” but this looks not very elegant. I’m pretty sure I’m missing something…

An ideas how to improve this.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [September 1, 2021, 10:19am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/2 "2021-09-01T10:19:45Z")

</div>

The more elegant solution is: “button pressed” and “light is **OFF** ”, then “switch on”. Explanation: If the light is already on then nothing is done (“Do nothing”).  
But I think that is the way to go.

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 1, 2021, 10:20am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/3 "2021-09-01T10:20:26Z")

</div>

aha, thanks i’ll try this one

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [September 1, 2021, 10:36am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/4 "2021-09-01T10:36:17Z")

</div>

Note: The flow only works to turn on lights. If single lights are already on, they will stay on.  
To turn off all lights, additional flows and a variable are needed if this is to be done with only one button.

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 1, 2021, 1:09pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/5 "2021-09-01T13:09:42Z")

</div>

I’m using the toggle action for it and it works/ed except if some lights were already on  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/a/ba04c9bcc681442050e882b153a600170de2bfc5.png)

---

<div class="post-metadata">

**Author:** ![Edwin\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/edwin_d/32/136417_2.png) [@Edwin\_D](https://community.homey.app/u/Edwin_D)\
**Post date:** [September 1, 2021, 6:24pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/6 "2021-09-01T18:24:17Z")

</div>

The not so helpful but true answer would be: avoid toggle buttons. Separate on and off buttons have the great advantage that the user can reveal his/her true intent to Homey. Turn on the other lights as well as the lifx, or turn everything off.

If you insist on using togglebuttons, it depends on what you want to happen. One way may be to not toggle the lifx if the motion sensor is armed (detects motion).

If toggle button is pressed and no motion is detected then toggle the lifx

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [September 2, 2021, 10:07am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/7 "2021-09-02T10:07:24Z")

</div>

> [@thobu](#):
>
> I’m using the toggle action for it and it works/ed except if some lights were already on

I’m a little bit confused, because you said that you made an extra flow.  
As @Edwin_D already said, to toggle the lamps will definitely not work. If you push the button to toggle ALL lights (this is the action card you use), lights are on will go off and lights are off will go on. That’s it. That’s the meaning of the action card.

Maybe this is a solution:

**Flow 1**  
When…  
– On/off button was pressed  
And…  
– Variable “Lights on/off” is NO  
Then…  
– Set variable “Lights on/off” to YES  
Else…  
– Set variable “Lights on/off” to NO

**Flow 2**  
When…  
– Variable “Lights on/off” has changed  
And…  
– Variable “Lights on/off” is YES  
Then…  
– Switch on all lamps  
Else…  
– Switch off all lamps

But of course, it depends a little bit of your goal.

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 2, 2021, 12:13pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/8 "2021-09-02T12:13:21Z")

</div>

thanks for the input, let me revisit this after work

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 3, 2021, 1:48pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/9 "2021-09-03T13:48:50Z")

</div>

So, I’m reading this suggestion but can’t get my head around what the benefit of using a variable is.

My use case is that I’d like to use a toggle button (Ikea remote) for a bigger number of bulbs and sometimes a group of lights is ON due to a motion sensor and I want them to stay ON in this case. So, ideally, I can tell a flow to keep those ON that are already ON.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [September 3, 2021, 2:18pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/10 "2021-09-03T14:18:40Z")

</div>

The variable is used to switch **ALL** lamps on, independent of if lamps have already been switched on. The toggle function you are using would turn off lamps that are already on. And that is not what you want. And if you push the Ikea remote again, **ALL** lamps will be switched off.  
Btw, I suggest to try the flows instead of just reading it.

You can also use the variable to “disable/stop” the flows that automatically turn off the lights after a certain time (when the motion alarm has gone off). But you’re not providing much details, sorry.

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 3, 2021, 2:56pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/11 "2021-09-03T14:56:22Z")

</div>

thanks, I’m away from Home(y) atm - will check later

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 4, 2021, 6:23pm UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/12 "2021-09-04T18:23:32Z")

</div>

Finally I tried it, and it works! Only the final step “Switching off” doesn’t work. It stays with “Switch on all lamps”.

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [September 5, 2021, 5:49am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/13 "2021-09-05T05:49:57Z")

</div>

Please share your flows to have a look on it.

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 5, 2021, 7:55am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/14 "2021-09-05T07:55:37Z")

</div>

had the wrong variable in use, it works now.  
I’m just not sure if other flows which turn on all lights are affected. I got a few flows which change the light color and dim state and switch on all lights…

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [September 5, 2021, 9:00am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/15 "2021-09-05T09:00:05Z")

</div>

I don’t know either, because I don’t know how you build your flows… 🤷🏼‍♂️

---

<div class="post-metadata">

**Author:** ![thobu](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thobu/32/18357_2.png) [@thobu](https://community.homey.app/u/thobu)\
**Post date:** [September 5, 2021, 9:12am UTC](https://community.homey.app/t/issue-with-toggle-action-in-light-flow/51040/16 "2021-09-05T09:12:50Z")

</div>

I still don’t understand your recipe 100%, before I didn’t even know there’s “Else”. I will spend some time and then see if I can build on it. Thanks very much for the enlightenment anyway 🙂
