74 lines
1.7 KiB
YAML
74 lines
1.7 KiB
YAML
blueprint:
|
|
name: Fan Cadence with Light Check
|
|
description: >
|
|
Turns on a fan every X minutes for Y seconds, but keeps it on if any selected lights are on.
|
|
domain: automation
|
|
input:
|
|
fan_entity:
|
|
name: Fan Entity
|
|
selector:
|
|
entity:
|
|
domain: fan
|
|
|
|
interval_minutes:
|
|
name: Interval (minutes)
|
|
description: How often to start the fan cycle
|
|
default: 15
|
|
selector:
|
|
number:
|
|
min: 1
|
|
max: 1440
|
|
unit_of_measurement: minutes
|
|
|
|
duration_seconds:
|
|
name: Fan On Duration (seconds)
|
|
description: How long the fan stays on each cycle
|
|
default: 60
|
|
selector:
|
|
number:
|
|
min: 5
|
|
max: 3600
|
|
unit_of_measurement: seconds
|
|
|
|
override_lights:
|
|
name: Override Lights
|
|
description: Fan will not turn off if any of these lights are on
|
|
selector:
|
|
entity:
|
|
domain: light
|
|
multiple: true
|
|
|
|
trigger:
|
|
- platform: homeassistant
|
|
event: start
|
|
- platform: time
|
|
at: "00:00:00" # ensures automation starts at midnight if HA is already running
|
|
|
|
variables:
|
|
fan: !input fan_entity
|
|
lights: !input override_lights
|
|
interval: !input interval_minutes
|
|
duration: !input duration_seconds
|
|
|
|
condition: []
|
|
|
|
action:
|
|
- repeat:
|
|
while: []
|
|
sequence:
|
|
- service: fan.turn_on
|
|
target:
|
|
entity_id: "{{ fan }}"
|
|
- delay:
|
|
seconds: "{{ duration }}"
|
|
- condition: template
|
|
value_template: >
|
|
{{ lights | map('states') | select('eq', 'on') | list | length == 0 }}
|
|
- service: fan.turn_off
|
|
target:
|
|
entity_id: "{{ fan }}"
|
|
- delay:
|
|
minutes: "{{ interval }}"
|
|
|
|
mode: restart
|