Do something when light is turned off, but only if it has been on for at least 15 minutes

There is… the trigger variable holds both the to_state of the triggering entity as well as the from_state.

triggers:
  - trigger: state
    entity_id: light.bathroom_light
    to: 'off'
    from: 'on'
conditions:
  - alias: The light was in its previous state ('on') for at least 15 minutes
    condition: template
    value_template: |
      {{ now() - trigger.from_state.last_changed >= timedelta(minutes=15)}}   
actions:
#YOUR FAN ACTIONS


1 Like