Light max run time automation

I’ve had a look throug some blueprints, but nothing seems to do what I am looking for,

Im looking for an automation that will make all my lights that are selected run for a MAX run time, say maximum of 60 minutes.

I have added this blueprint,

Turn a switch off after a defined set of time (simple switch automation) - Blueprints Exchange - Home Assistant Community (home-assistant.io)

However, when I manually switch the light on, the automation does not trigger.

What I want is,

No mattery how I turn the light(s) on, they run for a max of x minutes. This is incase the lights are left on in areas that are not usually occupied.

Thanks

By “manually”, do you mean powering the light on?

The blueprint should work unless you power the light back on before HA realized you powered it off. For zigbee lights and ZHA, it takes 2H by default (IIRC)…

Thanks,

All my lighting automation is done with esphome.

I am switching the light on simply by going to the entity, and turning it on.

Not sure what you mean by that, because blueprint automations are pure HA, not esphome.

Should work then.
Check the state of the entity before and after turning on to be certain, but likely some kind of human error, here (wrong light?).

Oh damn ok it is working.

I think I was expecting the automation to trigger as soon as I turned the light on, to start the timer.

Instead, the automation only triggers when the time is reached,

Thanks.

Would you know how or if its possible in this blueprint to combine multiple entities rather then jus 1.

Save me creating 20 different automations for the same thing.

Thanks

:slight_smile:

In “plain” yaml automations, sure. In this specific blueprint, no.

How would I create this bluepint as a plain YAML automation,

I only need to create one, then add to it as I add lights

Blueprints are templates for actual automations.
That blueprint will generate an automation equivalent to:

automation:
- id: '1562003834289'
  alias: Switch light off
  trigger:
    - platform: state
      entity_id: light.the_light
      to: 'on'
      for: '00:10:00'
  condition: []
  action:
    - service: switch.turn_off
      data: {}
      entity_id: light.the_light
  mode: single

In plain yaml, you could write an automation that triggers on multiple lights, e.g.

automation:
- id: '1562003834289'
  alias: Switch light off
  trigger:
    - platform: state
      entity_id: 
        - light.the_light
        - light.the_light2
        - light.the_light3
        - light.the_light4
      to: 'on'
      for: '00:10:00'
  condition: []
  action:
    - service: switch.turn_off
      data: {}
      entity_id: "{{ trigger.entity_id }}"
  mode: single