So it means that the action will start EVERY 30sec because there are no “from” “to” option for the state platform ?
That means the actions will start 30secs after any change on the state. If no changes in the states, the automation will never be triggered, but if any change (regardless the from or to), it will trigger after 30sec.
I don’t know if I understand well…
That’s my problem. I think there is no state change when I close or open the cover form the switch.
Do your code solve this problem sending a stop command after a delay ?
Can you tell me what I have to write to send a stop command after a service is call ? Is this code will work ?
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 Home Assistant is completely unaware of when you control the cover via the switch then there’s nothing available for an automation to use as a trigger.
HA change the statut of the cover only if a press stop after the cover is up or down.
If I don’t press stop I can’t do the other movement ( down if it was up before or up if it was down)
That’s my point… I bet HA is not “completely unaware”.
@Guibertinpro, could you please open Developer Tools, States and search for cover.volet_salon
, then look at the attributes column how is the attribute current_position
behaving when your cover is opening or closing?
So contrary to what you stated earlier, Home Assistant is aware of when you use the switch to control the cover but for only one command: stop.
When the cover is open and I close it, the current_position stay to 100 after the cover is closed. But when i push the stop button the current_position change to 0.
So i can’t use the current_position to send a stop command because it only when a push on stop button that the current_position change.
So i tried this :
alias: Stop cover salon
description: ''
trigger:
- platform: state
entity_id:
- cover.volet_salon
for:
hours: 0
minutes: 0
seconds: 27
condition: []
action:
- service: cover.stop_cover
target:
entity_id: '{{ trigger.entity_id }}'
mode: parallel
max: 15
And this :
alias: Pause après ouverture volet salon
description: ''
trigger:
- platform: event
event_type: call_service
event_data:
domain: cover
service: cover.open_cover
action:
- delay:
seconds: 27
- service: cover.stop_cover
target:
entity_id: cover.volet_salon
data: {}
But it doesn’t work. The state of the cover stay up when i open it. It doesn’t change to Stop.
When I push the open button on the switch, in the log I have one ligne that says : “Volet salon was closed” like an event. Maybe i can use it…
Let’s try something different…
I’m supposing you are using ZHA. Please let us know if that is not the case.
Go to Developer tools, Events and then start listening to zha_event
and then press your button to close the cover… Please let us know if any event is captured.
Also, are you sure the control is sending the open/close command directly to the cover? Are you sure there’s no automations on Home Assistant handling this process?
I tested but there is nothing captured when i open or close the cover…
I have 6 entities in ZHA for 2 covers :
I did new tests.
And your code works because it waits a new state of the cover and after it send a stop action.
But i saw that the new state like this one below appears only when i push the stop button at the end of the opening…
So your code execute a stop command only when I pushed the stop button … because when I push the up or down button i see nothing in the logs. I don’t know how to get the opening or closing information to start a stop command after 27 seconds… that’s what I need