blueprint: name: Bathroom Fan Controller description: > Turns on the fan when any bathroom light is on (after a delay), keeps it on 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 input: fan_entity: name: Bathroom Fan description: The fan to control selector: entity: domain: fan bathroom_lights: name: Bathroom Lights description: One or more lights in the bathroom selector: entity: domain: light multiple: true delay_after_light_on: name: Delay After Light On description: Delay before turning on the fan once any light is turned on default: 0 selector: duration: time_fan_stays_on_after_lights_off: name: Duration Fan Stays On After Lights Off description: How long the fan should stay on after all lights are off 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 max: 5 trigger: - platform: state entity_id: !input bathroom_lights from: 'off' to: 'on' - platform: state entity_id: !input bathroom_lights to: 'off' for: !input time_fan_stays_on_after_lights_off - platform: time_pattern minutes: "/5" condition: [] action: - choose: - conditions: - condition: template value_template: > {{ 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 - 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 - service: fan.turn_off target: entity_id: !input fan_entity - conditions: - condition: template value_template: > {{ trigger.platform == 'time_pattern' and cadence_enabled }} sequence: - service: fan.turn_on target: entity_id: !input fan_entity - delay: !input cadence_duration - service: fan.turn_off target: entity_id: !input fan_entity