blueprint:
name: Turn off Switch after Time has elapsed
description: Given a switch entity, watch for it turning on, and then turn it off after a certain period of time.
domain: automation
input:
switch:
name: Switch
description: Select the switch to monitor and control
selector:
entity:
domain: switch
time:
name: Duration
description: The duration to leave the switch on for
selector:
duration:
trigger:
- platform: state
entity_id: !input switch
to: 'on'
for: !input time
condition: []
action:
- service: switch.turn_off
data: {}
entity_id: !input switch
mode: single
blueprint:
name: Turn off Light after Time has elapsed
description: Given a light entity, watch for it turning on, and then turn it off after a certain period of time.
domain: automation
input:
light:
name: Light
description: Select the light to monitor and control
selector:
entity:
domain: light
time:
name: Duration
description: The duration to leave the light on for
selector:
duration:
trigger:
- platform: state
entity_id: !input light
to: 'on'
for: !input time
condition: []
action:
- service: light.turn_off
data: {}
entity_id: !input light
mode: single
domain can accept a list of domains. If you specify both light and switch, a single blueprint will be able to handle both. Just remember to change light.turn_off to homeassistant.turn_off (because it’s able to turn off lights and switches).
So this was super helpful. I was wondering if this can be modified to include multiple lights/switches. My use case is that I have 7 different bath fans. I only want them to run for 15 minutes after they get turned on. My family tends to leave them running indefinitely. I could duplicate the automation 7 times with each entity, but I was wanting to create one automation and just list all 7 devices.