# Help requested with Virtual Switch

**URL:** <https://community.homey.app/t/help-requested-with-virtual-switch/65453>\
**Category:** Questions & Help\
**Tags:** advancedflow\
**Created:** [July 3, 2022, 8:58am UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453 "2022-07-03T08:58:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jo\_San](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jo_san/32/3732_2.png) [@Jo\_San](https://community.homey.app/u/Jo_San)\
**Post date:** [July 3, 2022, 8:58am UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453/1 "2022-07-03T08:58:22Z")

</div>

I am trying to create something with a Virtual Switch. All my previous attempts with virtual devices failed as I don’t seem to understand the concept entirely, but this morning I wanted to try something again.

What I try to accomplish:

- I have a boolean value that I want to be able to set via a Virtual Switch as well as just via flow cards or directly in the Better Logic app;
- The Switch should always resemble the state of the Boolean, so if the boolean is changed elsewhere (not using the virtual switch) it should change the state of the virtual switch;

I created a simple Advanced Flow for that, but (logically) that results in an infinite loop of switching on and off.

I am pretty sure I am overlooking an easy way to do this. Any thoughts on it?

 ![Schermafbeelding 2022-07-03 om 10.57.26](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/1/9151201320eb2b2f6f4e1ce003e6c58081e4d06d.jpeg)

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [July 3, 2022, 11:50am UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453/2 "2022-07-03T11:50:20Z")

</div>

Just add another check of the _current_ status before you set the value. (for all 4 scenerios)  
IF turned on AND variable is `true` THEN set variable `false`

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [July 3, 2022, 11:57am UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453/3 "2022-07-03T11:57:51Z")

</div>

I guess in this case the Issue is in Better Logic triggering on updating without a Change

---

<div class="post-metadata">

**Author:** ![Jo\_San](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jo_san/32/3732_2.png) [@Jo\_San](https://community.homey.app/u/Jo_San)\
**Post date:** [July 3, 2022, 12:03pm UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453/4 "2022-07-03T12:03:36Z")

</div>

Indeed. The question is if that trigger should happen on any “set” of the value, even if it is the same, or only when it actually changes. I would say the latter, but apparently it does not work that way.

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [July 3, 2022, 12:06pm UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453/5 "2022-07-03T12:06:10Z")

</div>

Can you test it with the build in logic?

---

<div class="post-metadata">

**Author:** ![Jo\_San](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jo_san/32/3732_2.png) [@Jo\_San](https://community.homey.app/u/Jo_San)\
**Post date:** [July 3, 2022, 12:19pm UTC](https://community.homey.app/t/help-requested-with-virtual-switch/65453/6 "2022-07-03T12:19:24Z")

</div>

![Schermafbeelding 2022-07-03 om 14.21.19](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/a/ba486da4e76fdc9231d17b0e50c0a11b9c6150ed.jpeg)

Tried that for another one, and this seems to work as expected. So perhaps a bug or undesired feature in Better Logic.

@Caseda’s workaround does also work by the way.

 ![Schermafbeelding 2022-07-03 om 14.22.11](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/e/2eeaf5976a0788c2de5b0c64940962e1d9349dba.jpeg)
