Please help me control the curtain with one button

Friends, help me solve this problem.
It seems simple, but I can’t figure out how to do it yet.
Task: when you press a button, open the curtain. Second press - stop. Third - close.
That is, one button does three actions in a circle.
This is necessary so that if you accidentally press open or close, you can immediately stop it and return it to how it was.
There must be a way to do this…
The curtain only has a position state of 0 or 100.
During the opening or closing process, the status does not change until it stops.
I made an automation that closes or opens the curtain.
But it’s important for me to be able to stop the curtain with the same button. Since sometimes the switching on happened by accident, or there is some kind of obstacle, interference, and it is necessary to stop it so that nothing happens.

You can use the same button for all three actions, open, close, stop.

1 Like

Thanks for the advice, but unfortunately this does not solve the problem. Or I was unable to use this template correctly.
The fact is that the proposed template creates a virtual curtain from a button and a switch.
And there is no intention of using an existing curtain.
I don’t have a switch. I use a Bluetooth-controlled drive, AM43, which already has an essence - a curtain.
But this drive has no motion status. Status only - open (100) or closed (0)
At the moment of opening or closing, the status and attributes do not change until the curtain is stopped or it itself reaches the extreme point.
So my problem is to be able to stop the movement of the curtains at any time using a button.
I would not like to install a triple switch so that each button is a trigger for opening, closing and stopping.
Is there an option to use one button, one trigger to alternate between opening, stopping and closing?

Did you try it?

If you supply the same action (button press) for open, close and stop action it should solve your problem. As you don’t have state feedback it will operate in optimistic mode.

No idea what you are on about here. All you need to supply is the three actions.