Pico1965
(Pico1965)
June 29, 2023, 9:14am
1
In my automation i use:
- wait_for_trigger:
- platform: state
entity_id: switch.lastricosolare_pressostatorabboccovasche
from: "off"
to: "on"
for: "00:00:30"
timeout: "00:15:00"
continue_on_timeout: true
I need to handle differently the exit from the function for the satisfaction of the trigger or for the timeout.
Which is basically the behavior of the variable wait.completed unavailable in this scenario.
How can I do?
Thanks
tom_l
June 29, 2023, 9:38am
2
- wait_for_trigger:
- platform: state
entity_id: switch.lastricosolare_pressostatorabboccovasche
from: "off"
to: "on"
for: "00:00:30"
timeout: "00:15:00"
continue_on_timeout: true
- if: # timeout occured
- "{{ wait.remaining == 0 }}"
then:
- service: # do something
else:
- service: # do something else in the triggered case
Or another test you could use:
- if: # timeout occured
- "{{ wait.trigger == none }}"
https://www.home-assistant.io/docs/scripts#wait-variable
1 Like
There is a wait.completed member that tells you if it was successful.
- wait_template: "{{ is_state(entity_id,'on') }}"
timeout:
seconds: "{{ timeout_seconds * repeat.index }}"
continue_on_timeout: true
- if:
- "{{wait.completed}}"
then:
- service: system_log.write
data:
level: info
message: "turn_on {{entity_id}} {{target_value}}- success"
logger: service
- service: input_text.set_value
data_template:
entity_id: "{{ message_id }}"
value: "turn_on {{target_value}}- success"
tom_l
June 29, 2023, 11:43am
4
The docs say that variable,
Exists only after wait_template
.
So I did not include it because I was not sure if that also applies to a wait for trigger (instead of template).