You’re welcome! The next step is to add this to your automation’s action
.
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.back_door
from: 'on'
to: 'off'
for: '00:02:00'
timeout: '00:10:00'
continue_on_timeout: false
It waits for binary_sensor.back_door to change it state
to off
and hold that state for at least 2 minutes. When that happens it will continue to execute the next action (not shown above) which will be to set climate.nest_thermostat
to heat
.
It also includes a 10-minute timeout. If the back_door is not closed within 10 minutes, the automation will end (because we have set continue_on_timeout
to false
). Feel free to adjust the duration of timeout
and if you prefer to have it continue executing the next action even after the timeout expires.
Here is your automation with wait_for_trigger
.
- id: '1631090131652'
alias: Conserve Energy When Back Door Open
description: ''
trigger:
- platform: state
entity_id: binary_sensor.back_door
from: 'off'
to: 'on'
for: '00:03:00'
id: 'Nest Switched To Off'
condition:
- condition: device
device_id: 47585fcc9681ecc15ff20c2238c72a74
domain: climate
entity_id: climate.nest_thermostat
type: is_hvac_mode
hvac_mode: heat
action:
- device_id: 47585fcc9681ecc15ff20c2238c72a74
domain: climate
entity_id: climate.nest_thermostat
type: set_hvac_mode
hvac_mode: 'off'
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.back_door
from: 'on'
to: 'off'
for: '00:02:00'
timeout: '00:10:00'
continue_on_timeout: false
- device_id: 47585fcc9681ecc15ff20c2238c72a74
domain: climate
entity_id: climate.nest_thermostat
type: set_hvac_mode
hvac_mode: 'heat'
mode: single
Here is the same automation but instead of using a Device Condition and Device Actions it uses a Template Condition in shorthand notation and service calls. It’s functionally equivalent to the first automation, only shorter.
- id: '1631090131652'
alias: Conserve Energy When Back Door Open
description: ''
trigger:
- platform: state
entity_id: binary_sensor.back_door
from: 'off'
to: 'on'
for: '00:03:00'
condition: "{{ is_state('climate.nest_thermostat', 'heat') }}"
action:
- service: climate.set_hvac_mode
target:
entity_id: climate.nest_thermostat
data:
hvac_mode: 'off'
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.back_door
from: 'on'
to: 'off'
for: '00:02:00'
timeout: '00:10:00'
continue_on_timeout: false
- service: climate.set_hvac_mode
target:
entity_id: climate.nest_thermostat
data:
hvac_mode: 'heat'
mode: single
NOTE
In your original automation you assigned a named id
to the trigger (Nest Switched To Off
). Unless you plan to refer to this id
in the automation’s action
(using trigger.id
) it’s not obligatory to do it.