fix an issue with an input template

This commit is contained in:
2025-07-06 16:49:44 -04:00
parent 0a2381e91b
commit a7274f6053

View File

@ -1,8 +1,7 @@
blueprint: blueprint:
name: Fan Cadence with Light Check name: Fan Cadence with Light Check
description: > description: >
Runs a fan on a cadence every X minutes. Turns on a fan every X minutes for Y seconds, but keeps it on if any selected lights are on.
Turns it off after Y seconds unless any of the specified lights are on.
domain: automation domain: automation
input: input:
fan_entity: fan_entity:
@ -12,8 +11,8 @@ blueprint:
domain: fan domain: fan
interval_minutes: interval_minutes:
name: Fan Activation Interval (minutes) name: Interval (minutes)
description: How often to turn the fan on description: How often to start the fan cycle
default: 15 default: 15
selector: selector:
number: number:
@ -22,8 +21,8 @@ blueprint:
unit_of_measurement: minutes unit_of_measurement: minutes
duration_seconds: duration_seconds:
name: How Long to Keep Fan On (seconds) name: Fan On Duration (seconds)
description: How long the fan stays on before trying to turn it off description: How long the fan stays on each cycle
default: 60 default: 60
selector: selector:
number: number:
@ -33,33 +32,42 @@ blueprint:
override_lights: override_lights:
name: Override Lights name: Override Lights
description: Fan will not be turned off if any of these lights are on description: Fan will not turn off if any of these lights are on
selector: selector:
entity: entity:
domain: light domain: light
multiple: true multiple: true
trigger: trigger:
- platform: time_pattern - platform: homeassistant
minutes: "/{{ iif(interval_minutes | int > 0, interval_minutes, 15) }}" event: start
- platform: time
at: "00:00:00" # ensures automation starts at midnight if HA is already running
variables: variables:
fan: !input fan_entity fan: !input fan_entity
lights: !input override_lights lights: !input override_lights
interval: !input interval_minutes
duration: !input duration_seconds
condition: [] condition: []
action: action:
- service: fan.turn_on - repeat:
target: while: []
entity_id: "{{ fan }}" sequence:
- delay: - service: fan.turn_on
seconds: !input duration_seconds target:
- condition: template entity_id: "{{ fan }}"
value_template: > - delay:
{{ lights | map('states') | select('eq', 'on') | list | length == 0 }} seconds: "{{ duration }}"
- service: fan.turn_off - condition: template
target: value_template: >
entity_id: "{{ fan }}" {{ lights | map('states') | select('eq', 'on') | list | length == 0 }}
- service: fan.turn_off
target:
entity_id: "{{ fan }}"
- delay:
minutes: "{{ interval }}"
mode: parallel mode: restart