Hi,
I have a roller shutter with a zigbee switch. When I open or close the shutter, I have to press stop to be able to do the opposite action.
I want to know if it is possible to automate the stop after the triggering of the open or close.
Can an automation use a service as a trigger ?
For instance, like this ? :
trigger:
- service: cover.open_cover
target:
entity_id: cover.volet_salon
action:
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- service: cover.stop_cover
target:
entity_id: cover.volet_salon
If yes, how can i use a service as a trigger please ?
Thanks a lot
itnassol
(Andrew)
November 4, 2022, 12:07pm
2
You could try a timer then use trigger IDs to control it, something like this maybe?
alias: Stop cover after 30 seconds
description: ""
trigger:
- platform: state
entity_id:
- cover.volet_salon
from: "closed"
to: "open"
id: Cover-on
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.cover.volet_salon
id: Cover-Off
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Cover-on
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.cover.volet_salon
- conditions:
- condition: trigger
id: Cover-off
sequence:
- service: cover.stop_cover
data: {}
target:
entity_id: cover.volet_salon
mode: single
You would need to make a timer in helpers and make sure you check restore.
Maybe this ?
alias: Stop cover after 30 seconds
trigger:
- platform: state
entity_id: cover.volet_salon
from: "closed"
to: "open"
for:
seconds: 30
action:
- service: cover.stop_cover
entity_id: cover.volet_salon
Thanks for you help.
The problem is that when I open the shutter with the zigbee switch, as long as I donât press stop, Home assistant does not know that the shutter is open (on my dashboard it is always closed).
So I donât know if i can use a state trigger with âfrom: closed to: openâ. Do you see what i mean ?
The only thing that i could use is when the services âcover.open_coverâ or âcover.close_coverâ start and begin a timer of X seconds and finally stop the shutter.
OK what about using the zigbee button as the trigger ? I assume you have some automation already using the zigbee button so tag this on the end
Which zigbee switch are you using and how is it connected to the blind ?
action:
- service: cover.open_cover
entity_id: cover.volet_salon
- delay: "00:00:30"
- service: cover.stop_cover
entity_id: cover.volet_salon
Actually i use this integration :
It works well but only if i donât use the switch on the wall. So itâs not practical if we want to use both HA and the physical switch.
My zigbee switch :
Itâs connected with a conbee 2 plugged into a raspberry pi 4.
So that i want :
I open/close the shutter with the button on the switch or in HA or with siri
the service âcover.stop_coverâ starts after X seconds (for not doing this manually)
Assume you are using ZHA ? What does the cover entity look like in dev tools ?
I donât know if this is what you want :
123
(Taras)
November 4, 2022, 1:34pm
9
It can listen for the event produced when a service is called.
alias: example
trigger:
- platform: event
event_type: call_service
event_data:
domain: "cover"
service: "open_cover"
action:
... etc ...
2 Likes
@123 thatâs a good news. Maybe this is what i need ! So if i do this, it will works ?:
alias: "stop cover after opening"
trigger:
- platform: event
event_type: call_service
event_data:
domain: "cover"
service: cover.open_cover
action:
- service: cover.stop_cover
target:
entity_id: cover.my_cover
What means âdomainâ ? what i have to put here ?
Thanks
123
(Taras)
November 4, 2022, 1:44pm
11
alias: "stop cover 30 seconds after opening"
trigger:
- platform: event
event_type: call_service
event_data:
domain: "cover"
service: "open_cover"
action:
- delay:
seconds: 30
- service: cover.stop_cover
target:
entity_id: cover.volet_salon
If you have more than one cover, the automation must be enhanced because it currently will trigger for cover.open_cover
called for any cover.
EdwardTFN
(Edward Firmo)
November 4, 2022, 1:45pm
12
Iâve a similar problem in the past and it was fixed with this:
alias: Home - Covers - Reset when stuck in a state
description: ""
trigger:
- platform: state
entity_id:
- cover.lumi_lumi_curtain_agl001_cover
- cover.bedroom_curtains_dual
- cover.bedroom_curtain_left
- cover.bedroom_curtain_right
- cover.living_room_blinds
- cover.living_room_blind_right_cover
- cover.office_roller_blind_cover
- cover.living_room_blind_left_cover_2
- cover.gaming_room_blind_2_cover
- cover.gaming_room_blind_1_cover
- cover.gaming_room_blinds
- cover.living_room_blind_centre_cover
- cover.bedroom_curtains
- cover.office_shutter_cover
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: cover.stop_cover
target:
entity_id: "{{ trigger.entity_id }}"
mode: parallel
max: 15
Iâm basically monitoring all the covers and if one changes it state for 1min the automation will send it a stop command.
Ok, thanks. Yes i have severals covers.
I will test it.
But what does it mean the « domain » section in event_data ?
@EdwardTFN Ok but in your case itâs assuming that in HA the state of your cover change automatically when it get down or up no ?
123
(Taras)
November 4, 2022, 2:20pm
15
The following list contains a few examples of domains:
light
switch
lock
cover
input_boolean
Ok thanks.
I think itâs not a big problem because the action is just to stop a cover. So if itâs stop another cover already stop or open, itâs not a problem I think.
EdwardTFN
(Edward Firmo)
November 4, 2022, 3:01pm
17
This is the point⊠It updates sometime, but sometimes it says with state âmovingâ up or down forever (or for really long time) and I cannot send new commands until it realized the previous movement already finished.
So I send a stop command in all cases. I know sometimes the command is sent unnecessarily, but as this is working quite reliable since a while I never touched this automation.
Ok so in my case it will be :
alias: Stop cover
description: ""
trigger:
- platform: state
entity_id:
- cover.volet_salon
for:
hours: 0
minutes: 0
seconds: 30
condition: []
action:
- service: cover.stop_cover
target:
entity_id: "{{ trigger.entity_id }}"
mode: parallel
max: 15
What is max: 15 ?
And âfor:â means after X seconds ?
EdwardTFN
(Edward Firmo)
November 4, 2022, 3:38pm
19
Guibertinpro:
What is max: 15 ?
That means if your cover changes state again it will run another instance of this automation in parallel (mode: parallel
), but with a maximum of 15 instances.
In that example it means 0 hours + 0 minutes + 30 secs, or, 30 secs.
123
(Taras)
November 4, 2022, 3:42pm
20
If Home Assistant doesnât know the shutter was opened, a State Trigger wonât be able to detect when itâs open.