I just trying to do a very simple thing i guess but I just can’t make it because the UI automation/script does not have this option. Really appreciate if somebody could help me.
I just need a script thats when fired, repeats and checks the state of the binary_sensor.tor_offen every 2 seconds until the state is off. When the state is finally off, it should call another service.
Unless you have an unusual application, it is normally unnecessary to poll an entity to determine when its state changes. Simply use a State Trigger to trigger when the desired state-change occurs (as shown in tom_I’s example).
alias: ALEXA Garagen Tor zu wenn offen
description: ''
trigger:
- platform: state
entity_id: script.garagen_tor_zu
from: 'off'
to: 'on'
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.tor_offen
state: 'on'
sequence:
- type: turn_on
device_id: xxx
entity_id: switch.tor
domain: switch
- service: notify.alexa_media
data:
data:
type: announce
target:
- media_player.echo_wohnzimmer_2
- media_player.echo_schlafzimmer_2
message: Die Garage geht zu.
- conditions:
- condition: state
entity_id: binary_sensor.tor_offen
state: 'off'
sequence:
- service: notify.alexa_media
data:
data:
type: announce
target:
- media_player.echo_wohnzimmer_2
- media_player.echo_schlafzimmer_2
message: Die Garage ist schon zu.
default: []
mode: single
Now I want that after the automation did the first choose and the state of binary_sensor.tor_offen changed to off, I get an confirmation announce that it is closed.
For sure their are many solution to get this done maybe also with delay or wait service within the automation but even those I dont know to handle correct.
Because I dont want the announce triggered every time i closed the garage manual, a simple trigger for stet changed is not a solution.
Regrettably, I don’t understand the requirements of your second post. In addition, I don’t understand its relationship with the requirements of your first post. I think I will bow out and let others assist you. Sorry and good luck.
In short: Automation that closes a door, when door is closed sends me a feedback. My Idea was to run a script at the end of the automation which does the confirmation after the door is closed an therfor should repeat until state is fullfilled.
Based on what you just described, what you need is a wait_template .
What it’s doing is looping at very high speed (because it has nothing to do in each loop) until the binary_sensor is off. This is not a good application of repeat.
What you appear to want is for the action to wait until the binary_sensor if off and then send the notification. There is a straightforward and efficient way to do that in Home Assistant and that is the wait_template.