Hello,
I ran into a situation where I would like for an automation to wait for a certain time (condition) to trigger. To further explain, I have an automation that goes off when there is no motion inside the house with a time delay of 30 mins. At the same time, I would like for this automation to only go off if the time is between 8am and 9pm.
What happens is that sometimes, people leave the house earlier than 8 am and the automation triggers but the condition is not met and it never runs. So, I want to make sure that if the automation triggers before the given time, it waits until the condition is met, at the same time, if the trigger is reset the automation should be stopped.
I came up with this template for the wait on template trigger, but I believe is not working properly nor it will reset if the trigger is reset (people are inside the house)
{% set b = now()|as_local %}
{% if b >= today_at("08:00") and b <= today_at("21:00") %} on
{% endif %}
Here is the full automation
alias: HA_Auto_Idle_Set_AC_Off
description: >-
This automation will turn off the lights and A/C when tenants are not in the
house
trigger:
- platform: state
entity_id: group.motion_sensors
from: 'on'
to: 'off'
for:
hours: 0
minutes: 30
seconds: 0
condition:
- condition: state
entity_id: group.rental_control_calendars
state: 'on'
- condition: state
entity_id: group.backyard_motion_sensors
state: 'off'
for:
hours: 0
minutes: 20
seconds: 0
- condition: state
entity_id: group.motion_sensors
state: 'off'
for:
hours: 0
minutes: 30
seconds: 0
action:
- wait_template: |-
{% set b = now()|as_local %}
{% if b >= today_at("08:00") and b <= today_at("21:00") %} on
{% endif %}
continue_on_timeout: false
- service: homeassistant.turn_on
data: {}
target:
entity_id: input_boolean.home_away
- service: climate.turn_off
data: {}
target:
device_id: 2f04d7d0379ee7a2a45106f222365230
- service: homeassistant.turn_off
data: {}
target:
entity_id: group.house_lights
- service: flo.set_away_mode
data: {}
target:
entity_id: switch.shutoff_valve
mode: single
Thanks in advance.