fix an issue where fan never gets turned off
This commit is contained in:
@ -61,7 +61,6 @@ trigger:
|
||||
- platform: state
|
||||
entity_id: !input bathroom_lights
|
||||
to: 'off'
|
||||
for: !input time_fan_stays_on_after_lights_off
|
||||
- platform: time_pattern
|
||||
minutes: "/5"
|
||||
|
||||
@ -69,22 +68,22 @@ condition: []
|
||||
|
||||
action:
|
||||
- choose:
|
||||
# Turn fan on when any light turns on
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ trigger.platform == 'state' and
|
||||
trigger.to_state.state == 'on' }}
|
||||
{{ trigger.platform == 'state' and trigger.to_state.state == 'on' }}
|
||||
sequence:
|
||||
- delay: !input delay_after_light_on
|
||||
- service: fan.turn_on
|
||||
target:
|
||||
entity_id: !input fan_entity
|
||||
|
||||
# Turn fan off after all lights have been off for a duration
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{{ trigger.platform == 'state' and
|
||||
trigger.to_state.state == 'off' and
|
||||
expand(inputs.bathroom_lights) | selectattr('state','eq','on') | list | count == 0 }}
|
||||
sequence:
|
||||
- delay: !input time_fan_stays_on_after_lights_off
|
||||
@ -92,6 +91,7 @@ action:
|
||||
target:
|
||||
entity_id: !input fan_entity
|
||||
|
||||
# Periodic cadence run
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >
|
||||
@ -104,4 +104,3 @@ action:
|
||||
- service: fan.turn_off
|
||||
target:
|
||||
entity_id: !input fan_entity
|
||||
|
||||
|
Reference in New Issue
Block a user