# Flows for virtual switch

**URL:** <https://community.homey.app/t/flows-for-virtual-switch/28928>\
**Category:** Questions & Help\
**Tags:** zigbee, devices, flow\
**Created:** [April 25, 2020, 5:50am UTC](https://community.homey.app/t/flows-for-virtual-switch/28928 "2020-04-25T05:50:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elyoussoufit](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/elyoussoufit/32/22374_2.png) [@elyoussoufit](https://community.homey.app/u/elyoussoufit)\
**Post date:** [April 25, 2020, 5:50am UTC](https://community.homey.app/t/flows-for-virtual-switch/28928/1 "2020-04-25T05:50:11Z")

</div>

Hi all,  
I want to create 2 virtual switches to control separately the 2 lights managed by my aqara wall switch ( 2 gang).  
It’s quite tricky i think as the flows created should avoid generating an infinite loop, in order to get the switch state returned in homey when the switch is set on/off manually.  
Any one who acheived this? Maybe through variables?  
thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [April 25, 2020, 6:10am UTC](https://community.homey.app/t/flows-for-virtual-switch/28928/2 "2020-04-25T06:10:47Z")

</div>

> [@elyoussoufit](#):
>
> It’s quite tricky i think as the flows created should avoid generating an infinite loop

I wrote some lines about how I deal with complex flows [“how to structure your flows”](https://community.homey.app/t/how-to-structure-your-flows/25109)

What I do in the case you describe: do not create virtual switches. Create virtual pushbuttons. These do not have a status so you don’t need to return the status them.

So:  
When virtual pushbutton is pressed  
AND light status is ON  
THEN

When virtual pushbutton is pressed  
ANd light status is OFF  
THEN

PS: yes you can build the second flow i to the first flow in the ELSE section.  
Please read the “how to structure your flows” to understand why I do not do it…

---

<div class="post-metadata">

**Author:** ![elyoussoufit](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/elyoussoufit/32/22374_2.png) [@elyoussoufit](https://community.homey.app/u/elyoussoufit)\
**Post date:** [April 25, 2020, 3:14pm UTC](https://community.homey.app/t/flows-for-virtual-switch/28928/3 "2020-04-25T15:14:21Z")

</div>

Thanks for your reply 🙂  
but my target is having the status of the light ☹ so the push button won’t do the job  
Thanks again

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [April 25, 2020, 9:14pm UTC](https://community.homey.app/t/flows-for-virtual-switch/28928/4 "2020-04-25T21:14:26Z")

</div>

Ahh OK did not get that.  
Does the aqarara wall switch not show its status in homey?

Oif you want to have a virtual switch showing the satus its nit too hard I think

WHEN aqara switch is turned ON  
THEN set virtual switch to ON

WHEN aqara switch is turned OFF  
THEN set virtual switch to OFF

do not really see a risk on loops.
