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.
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.
Old topic, but i need exactly this.
This is my Code in configuration.yaml:
- platform: template
covers:
markise_templ:
device_class: awning
friendly_name: "Markise Template"
open_cover:
action: script.markise_offnen
close_cover:
action: script.markise_schliesen
stop_cover:
action: script.markise_stop
What did u mean with " same action (button press) for open, close and stop? I mean, how do you implement that?
So, what do i need? I want control my awning with one Button. One click - open, another click, stop, another click, close and so on.
Hi! Controlling all the curtain modes with one switch turned out to be a difficult task. I managed to solve it. But maybe my solution is more complicated than it could be. However, I did not find another option.
So, I have a Sonoff touch switch with one button.
When you press it, the internal relay switches on or off. This state is transmitted to the HA.
To control the curtain with it, I created a list selector of 4 items. Later you will understand why 4.
List of items - Open, stop, close, stop2.
Then automation is created. Which, depending on the set item, sends a command to the curtain.
alias: Covers input
description: ""
mode: single
triggers:
- entity_id:
- input_select.rezhimy_shtor
to: open
id: op
trigger: state
- entity_id:
- input_select.rezhimy_shtor
to: stop
id: st
trigger: state
- entity_id:
- input_select.rezhimy_shtor
to: close
id: cl
trigger: state
- entity_id:
- input_select.rezhimy_shtor
to: stop2
id: st2
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- op
sequence:
- metadata: {}
data: {}
target:
entity_id: cover.shtory
action: cover.open_cover
- conditions:
- condition: trigger
id:
- st
sequence:
- metadata: {}
data: {}
target:
entity_id: cover.shtory
action: cover.stop_cover
- conditions:
- condition: trigger
id:
- cl
sequence:
- metadata: {}
data: {}
target:
entity_id: cover.shtory
action: cover.close_cover
- conditions:
- condition: trigger
id:
- st2
sequence:
- metadata: {}
data: {}
target:
entity_id: cover.shtory
action: cover.stop_cover
But in order for these modes to switch, you need automation that will change the selector when switching the relay, which is controlled by the touch button. If you set a simple state change as a trigger, then if the state is unknown or unavailable, then the trigger will also work and the curtains will open or close, sometimes in the middle of the night. To prevent this from happening, I set a specific action as a trigger in the automation. Here is my automation.
alias: Control with button
description: ""
mode: restart
triggers:
- entity_id: switch.sonoff_1000933f3f_2
from: "on"
to: "off"
trigger: state
- entity_id: switch.sonoff_1000933f3f_2
from: "off"
to: "on"
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: cover.shtory
state: closed
sequence:
- metadata: {}
data: {}
target:
entity_id: cover.shtory
action: cover.open_cover
- conditions:
- condition: state
entity_id: cover.shtory
state: open
sequence:
- metadata: {}
data: {}
target:
entity_id: cover.shtory
action: cover.close_cover
enabled: false
- metadata: {}
data:
cycle: true
target:
entity_id: input_select.rezhimy_shtor
action: input_select.select_next
My curtain only has the open and closed states. During the opening process, the status does not change until it is completely open or closed. Therefore, it was difficult to figure out how to stop the curtain at any time using a button. Because it is impossible for the system to determine the moment of movement. This was done with another automation.
But if you have other devices, this will probably be an unnecessary complication.
Good luck with your projects.
Thank you for your help.
I found another solution for me. It is without the template sensor in configuration.yaml.
Maybe for you or someone else who is looking for it in the future. Maybe easier than yours.
I created a helper input_boolean.
When the awning is opened, the helper switches on. As soon as I press the button again, it checks whether the helper is switched on and retracts and switches the helper off again.
Here my script:
- if:
- condition: numeric_state
entity_id: sensor.markise_electric_consumption_w
above: 0
then:
- action: script.markise_stop
metadata: {}
data: {}
else:
- if:
- condition: state
entity_id: input_boolean.markise_automationshelfer
state: "on"
then:
- action: script.markise_schliesen
metadata: {}
data: {}
else:
- action: script.markise_offnen
metadata: {}
data: {}
alias: Markise auf_stopp_zu
The other 3 scripts are just stop, open and close. Then once with helper on and off. I did these individually because I also control the state via Alexa.
Hi,
sorry for bringing this old topic up again but i guess i have a similar topic and would like understand your proposal.
I would like to control one shutter (per room) with just one button similar to how KNX buttons can do. If you push the button the shutter will move in opposite direction compared to the last movement. If the shutter is moving it will stop.
Can i just use template covers for that?
Thanks you.
Friend, I wrote my solution above. It has been working for me for a long time. There are probably other options. Write in more detail what you can’t do.