# Virtual 3 state button

**URL:** <https://community.homey.app/t/virtual-3-state-button/89548>\
**Category:** Questions & Help\
**Created:** [September 16, 2023, 3:27pm UTC](https://community.homey.app/t/virtual-3-state-button/89548 "2023-09-16T15:27:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rihanna](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rihanna/32/73733_2.png) [@rihanna](https://community.homey.app/u/rihanna)\
**Post date:** [September 16, 2023, 3:27pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/1 "2023-09-16T15:27:10Z")

</div>

I would like to program one button to control my curtain.  
Which toggles: down, stop, up.  
Is there something that already can do this?

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [September 16, 2023, 4:48pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/2 "2023-09-16T16:48:22Z")

</div>

A button that supports one click, two clicks and 3 clicks.  
Aqara maybe?  
Or do you have a button already.

---

<div class="post-metadata">

**Author:** ![rihanna](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rihanna/32/73733_2.png) [@rihanna](https://community.homey.app/u/rihanna)\
**Post date:** [September 16, 2023, 5:03pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/3 "2023-09-16T17:03:44Z")

</div>

I have some buttons I can use.  
And I have tried some virtual devices, but I can’t get them to toggle 3 states.

I was thinking like my garage button is working. Up, stop and down. With one button and same click.

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [September 16, 2023, 5:26pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/4 "2023-09-16T17:26:49Z")

</div>

Maybe you can make a counter

IF button pressed  
AND counter is 1  
THEN curtain down  
Add 1 to counter\_curtain

IF button pressed  
AND counter is 2  
THEN curtain stop  
Add 1 to counter\_curtain.

IF button pressed  
AND counter is 3  
THEN curtain up  
Add 1 to counter\_curtain

IF button pressed  
AND counter is 4  
THEN curtain stop  
Add 1 to counter\_curtain

IF counter is 5  
THEN set counter\_curtain to 1

You have to make a Variable counter\_curtain.  
Calculate counter\_curtain als {{counter\_curtain+1}}

I can not find how to calculate precisely how to calculate at the moment.  
Better you use the search function at this moment.

---

<div class="post-metadata">

**Author:** ![thierry\_arguimbau](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thierry_arguimbau/32/155444_2.png) [@thierry\_arguimbau](https://community.homey.app/u/thierry_arguimbau)\
**Post date:** [September 16, 2023, 9:39pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/5 "2023-09-16T21:39:49Z")

</div>

![Capture](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/7/17241ceb1759c06511c6bf2f788afed52789c6ad.jpeg)

use 3 x V1 virtual switch and the rull

---

<div class="post-metadata">

**Author:** ![rihanna](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rihanna/32/73733_2.png) [@rihanna](https://community.homey.app/u/rihanna)\
**Post date:** [September 17, 2023, 8:55am UTC](https://community.homey.app/t/virtual-3-state-button/89548/6 "2023-09-17T08:55:06Z")

</div>

Can I control that with just 1 button?

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [September 17, 2023, 8:20pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/7 "2023-09-17T20:20:42Z")

</div>

@rihanna Did you test this already?  
This works with one (hardware) button.  
I tested this on my timeline but you have to choose for Up, Down and Stop.  
Omlaag = Down  
Stop = Stop  
Omhoog = Up

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/9/a9029b335264ac693d01cdd87ba67e436c3c680a.png)

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/5/e5872f3c544a54aae7bded3cf1f1304169e1fd3d.png)

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/f/1f2447e04b7fc8a0245c083c8d3c9554430271fd.png)

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/2/f227adaaf2ccf41b0528bd43c950c85ef8ecc8b3.png)

---

<div class="post-metadata">

**Author:** ![rihanna](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rihanna/32/73733_2.png) [@rihanna](https://community.homey.app/u/rihanna)\
**Post date:** [September 17, 2023, 9:37pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/8 "2023-09-17T21:37:33Z")

</div>

Thanks.  
I got this to work.  
But I had to make a step that put the variable to 1.  
How can I get the variable to start from 1?

Also I see now that my idea is not the best 😊  
When my curtain reaches either end I don’t get a feedback. And I will have to press the button twice to get it moving again. I’ll try to play with a timer.

---

<div class="post-metadata">

**Author:** ![Mike1233](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike1233/32/20991_2.png) [@Mike1233](https://community.homey.app/u/Mike1233)\
**Post date:** [September 17, 2023, 9:47pm UTC](https://community.homey.app/t/virtual-3-state-button/89548/9 "2023-09-17T21:47:49Z")

</div>

In the web app you can set here the variable to 1

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/c/dc4fc4223fb2b389d2c1424d9f4b197122fe23b2.png)

It depends on the type of curtains if you get a feedback if it is at the end closed or the end open.  
If you get the feedback you could say that if the cutain is totay closed it sets the variable to X, and X is the variable that is used to open the curtains.  
And also the other way around. So totaly open, set variable to X, and X is the variable what is used to close the curtains.
