Turn off switch after x minutes without delay

Hey,

So I’ve got an aqara door sensor for our balcony door. It should turn on the light (controlled with a shelly switch) after dark for 5 minutes OR until the door is closed again.

Currently I’ve got it set up with a delay for 5 mins, which won’t react to the door being closed early.

I’ve read about platform: state , but didn’t managed to get it working as it may have become obsolete.

Show your automation.

triggers:
  - type: opened
    device_id: 6f829488cab6fe411e421fb79622d5f6
    entity_id: ce175a8ce2451e79edc9078b7a466856
    domain: binary_sensor
    metadata:
      secondary: false
    trigger: device
    id: AUF
  - type: not_opened
    device_id: 6f829488cab6fe411e421fb79622d5f6
    entity_id: ce175a8ce2451e79edc9078b7a466856
    domain: binary_sensor
    trigger: device
    id: ZU
conditions:
  - condition: sun
    before: sunrise
    after: sunset
    enabled: true
actions:
  - if:
      - condition: trigger
        id:
          - AUF
    then:
      - type: turn_on
        device_id: 6448eb6e12ee8967c6fc0c5647c90fa4
        entity_id: 057774c92550b9371fbc2ffc2ff8da95
        domain: switch
      - delay:
          hours: 0
          minutes: 5
          seconds: 0
          milliseconds: 0
      - type: turn_off
        device_id: 6448eb6e12ee8967c6fc0c5647c90fa4
        entity_id: 057774c92550b9371fbc2ffc2ff8da95
        domain: switch
    else:
      - type: turn_off
        device_id: 6448eb6e12ee8967c6fc0c5647c90fa4
        entity_id: 057774c92550b9371fbc2ffc2ff8da95
        domain: switch
mode: single

There are a few options:

1 Like

Thanks, the wait timer did the trick :slight_smile:

Now I can even simplify the whole automation as well by only watching the doors closed inside the wait trigger.