another attempt at fixing fan management
This commit is contained in:
@ -1,107 +1,77 @@
|
|||||||
blueprint:
|
blueprint:
|
||||||
name: Bathroom Fan Controller
|
name: Bathroom Fan Manager
|
||||||
description: >
|
description: >
|
||||||
Turns on the fan when any bathroom light is on (after a delay), keeps it on
|
Turns fan on with bathroom lights (after optional delay), keeps it on while any light is on, and turns it off after all lights are off and a timeout.
|
||||||
after all lights are off for a specified time, and also runs the fan on a
|
|
||||||
regular cadence (e.g., every hour for 5 minutes).
|
|
||||||
domain: automation
|
domain: automation
|
||||||
input:
|
input:
|
||||||
fan_entity:
|
fan:
|
||||||
name: Bathroom Fan
|
name: Fan Entity
|
||||||
description: The fan to control
|
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: fan
|
domain: fan
|
||||||
bathroom_lights:
|
|
||||||
name: Bathroom Lights
|
lights:
|
||||||
description: One or more lights in the bathroom
|
name: Bathroom Light Entities
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: light
|
domain: light
|
||||||
multiple: true
|
multiple: true
|
||||||
delay_after_light_on:
|
|
||||||
name: Delay After Light On
|
delay_before_fan_on:
|
||||||
description: Delay before turning on the fan once any light is turned on
|
name: Delay Before Turning Fan On
|
||||||
|
description: Time to wait after any light turns on before turning on the fan.
|
||||||
default: 0
|
default: 0
|
||||||
selector:
|
selector:
|
||||||
duration:
|
number:
|
||||||
time_fan_stays_on_after_lights_off:
|
min: 0
|
||||||
name: Duration Fan Stays On After Lights Off
|
max: 300
|
||||||
description: How long the fan should stay on after all lights are off
|
unit_of_measurement: seconds
|
||||||
default: 00:05:00
|
|
||||||
selector:
|
|
||||||
duration:
|
|
||||||
cadence_enabled:
|
|
||||||
name: Enable Cadence Mode
|
|
||||||
description: Enable periodic fan activation
|
|
||||||
default: true
|
|
||||||
selector:
|
|
||||||
boolean:
|
|
||||||
cadence_interval:
|
|
||||||
name: Cadence Interval
|
|
||||||
description: Time between fan activations
|
|
||||||
default: 01:00:00
|
|
||||||
selector:
|
|
||||||
duration:
|
|
||||||
cadence_duration:
|
|
||||||
name: Cadence Duration
|
|
||||||
description: How long the fan stays on during each cadence
|
|
||||||
default: 00:05:00
|
|
||||||
selector:
|
|
||||||
duration:
|
|
||||||
|
|
||||||
mode: parallel
|
time_fan_stays_on_after_lights_off:
|
||||||
max: 5
|
name: Time Fan Stays On After All Lights Are Off
|
||||||
|
description: Time to keep the fan running after all lights are off.
|
||||||
|
default: 300
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 0
|
||||||
|
max: 3600
|
||||||
|
unit_of_measurement: seconds
|
||||||
|
|
||||||
|
mode: restart
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: !input bathroom_lights
|
entity_id: !input lights
|
||||||
from: 'off'
|
to:
|
||||||
to: 'on'
|
- "on"
|
||||||
|
- "off"
|
||||||
|
|
||||||
- platform: template
|
variables:
|
||||||
value_template: >
|
fan_entity: !input fan
|
||||||
{{ expand(inputs.bathroom_lights) | selectattr('state','eq','on') | list | count == 0 }}
|
lights: !input lights
|
||||||
|
|
||||||
- platform: time_pattern
|
|
||||||
minutes: "/5"
|
|
||||||
|
|
||||||
condition: []
|
|
||||||
|
|
||||||
action:
|
action:
|
||||||
- choose:
|
- choose:
|
||||||
# When any light turns on, start fan after delay
|
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{{ trigger.platform == 'state' and trigger.to_state.state == 'on' }}
|
{{ expand(lights) | selectattr('state', 'eq', 'on') | list | count > 0 }}
|
||||||
sequence:
|
sequence:
|
||||||
- delay: !input delay_after_light_on
|
- delay:
|
||||||
|
seconds: !input delay_before_fan_on
|
||||||
- service: fan.turn_on
|
- service: fan.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input fan_entity
|
entity_id: "{{ fan_entity }}"
|
||||||
|
|
||||||
# When all lights are off, delay then turn off fan
|
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{{ expand(inputs.bathroom_lights) | selectattr('state','eq','on') | list | count == 0 }}
|
{{ expand(lights) | selectattr('state', 'eq', 'on') | list | count == 0 }}
|
||||||
sequence:
|
sequence:
|
||||||
- delay: !input time_fan_stays_on_after_lights_off
|
- delay:
|
||||||
- service: fan.turn_off
|
seconds: !input time_fan_stays_on_after_lights_off
|
||||||
target:
|
|
||||||
entity_id: !input fan_entity
|
|
||||||
|
|
||||||
# Cadence mode
|
|
||||||
- conditions:
|
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{{ trigger.platform == 'time_pattern' and cadence_enabled }}
|
{{ expand(lights) | selectattr('state', 'eq', 'on') | list | count == 0 }}
|
||||||
sequence:
|
|
||||||
- service: fan.turn_on
|
|
||||||
target:
|
|
||||||
entity_id: !input fan_entity
|
|
||||||
- delay: !input cadence_duration
|
|
||||||
- service: fan.turn_off
|
- service: fan.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id: !input fan_entity
|
entity_id: "{{ fan_entity }}"
|
||||||
|
Reference in New Issue
Block a user