Ok so I needed to automate the Bathroom fan to come on when the Bathroom light is turned on (Presence detected). This turns on a Bathroom light timer helper set at 5 minutes. If the Bathroom light is switched off due to ‘No presence’ within the 5 minutes I need the Bathroom fan turned off as well. If the Bathroom light is turned off after 5 minutes then a second helper Bathroom fan timer starts counting down 20 minutes and then turns off Bathroom fan.
The idea is short stay in bathroom should result in immediate fan turn off cue the light. Long stay which usually means a fan to stay on for 20 minutes to exhaust humid air.
Using helpers to ensure timers are robust. Watched a video recently on how to set them up.
Everything else works perfectly except the turning off within 5 minutes
The issue is within this part:
condition: trigger
id:
- Bathroom Light Off
condition: not
conditions:
- condition: state
entity_id: timer.bathroom_light_timer
state: idle
type: turn_off
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: 6ba769696ca9b3f1e738649ebc45b1e3
domain: switch
service: timer.cancel
target:
entity_id:
- timer.bathroom_fan
data: {}
The entire automation:
alias: Bathroom Fan
description: ""
trigger:
- platform: device
type: turned_on
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: bd53073741dae02a5eaebcb48e1a3cef
domain: switch
id: Bathroom Light On
- platform: device
type: turned_off
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: bd53073741dae02a5eaebcb48e1a3cef
domain: switch
id: Bathroom Light Off
- platform: state
entity_id:
- timer.bathroom_fan
from: active
to: idle
id: Bathroom Fan Delay
- platform: device
type: turned_off
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: 6ba769696ca9b3f1e738649ebc45b1e3
domain: switch
id: Bathroom Fan turned off
condition: []
action:
- service: notify.notify
data:
message: Aquarium Solonoid Off
title: Alert
enabled: false
- choose:
- conditions:
- condition: trigger
id:
- Bathroom Light On
sequence:
- type: turn_on
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: 6ba769696ca9b3f1e738649ebc45b1e3
domain: switch
- service: timer.cancel
target:
entity_id:
- timer.bathroom_fan
data: {}
- service: timer.start
data: {}
target:
entity_id: timer.bathroom_light_timer
- conditions:
- condition: trigger
id:
- Bathroom Light Off
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.bathroom_fan
- conditions:
- condition: trigger
id:
- Bathroom Fan Delay
sequence:
- type: turn_off
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: 6ba769696ca9b3f1e738649ebc45b1e3
domain: switch
- conditions:
- condition: trigger
id:
- Bathroom Fan turned off
sequence:
- service: timer.cancel
target:
entity_id:
- timer.bathroom_fan
- timer.bathroom_light_timer
data: {}
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- Bathroom Light Off
- condition: not
conditions:
- condition: state
entity_id: timer.bathroom_light_timer
state: idle
sequence:
- type: turn_off
device_id: c64baab5b4e966fd414cdcdfbc5569de
entity_id: 6ba769696ca9b3f1e738649ebc45b1e3
domain: switch
- service: timer.cancel
target:
entity_id:
- timer.bathroom_fan
data: {}
mode: single