# Virtual 3 state button

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

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

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.

Maybe you can make a counter

IF button pressed
AND counter is 1
THEN curtain down

IF button pressed
AND counter is 2
THEN curtain stop

IF button pressed
AND counter is 3
THEN curtain up

IF button pressed
AND counter is 4
THEN curtain stop

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.

use 3 x V1 virtual switch and the rull

Can I control that with just 1 button?

@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

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.

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

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.