Switch lights off after 5 minutes automatically

Hi,

I do have hidden sensors in my doors that will trigger a alarm if some conditions are fullfilled like GPS Tracker in Home Zone ect…

I also wrote an automation that when I open the basement door the lights in the basement are turning on automatically.
But… I cannot find options / commands to turn it off automatically after 5 e.g. minutes?

any Idea what line I might add in the yaml file to turn it off after 5 minutes?

Thanks a lot for sterring me in the right direction.

My code so far:

alias: Motion Detection - Kellertür öffnet - Licht Keller an + flur EG

trigger:

  • type: opened
    platform: device
    device_id: 471893fd551bcb208af06e96c878f023
    entity_id: b33ad39c6822c5b3f18c6283f0a08812
    domain: binary_sensor

condition:

  • condition: time
    after: “23:30:00”
    before: “23:25:00”
  • condition: state
    entity_id: sun.sun
    state: below_horizon
    action:
  • type: turn_on
    device_id: 7416fa470cf41d363a0a454ce2c28db4
    entity_id: d1a4babad32841470d4d2c5ec22fae0c
    domain: light
  • type: turn_on
    device_id: 2068d2987eac9b16f42fd3e6cab748f7
    entity_id: 2def482011dc53a56126a9bca92c5302
    domain: light
  • type: turn_on
    device_id: 14b66ed3d10ba1d735c75301bb04e53d
    entity_id: b2c5efdb2179f7bc5296a0256b3c9853
    domain: light
  • type: turn_on
    device_id: 1fc399e24b118e343a6a57c59fcfdce0
    entity_id: d87f91d1633ece480a6fc206b23c5f50
    domain: light
    mode: single

Is this any help?

Hi, as I said already, this isn’t the issue - I do not have motion sensors. I want to trigger a “platform_ device” (type: opened). and just switch off the light after 5 minutes - WITHOUT needing a motion sensor which is turning off the lights after some time of not detecting a sensor.
With motion-detecors I have already done it successfully as you did describbe above.

I need a: - type: turn_off - in 5 minutes…

If this helps, the devices are from homematic (the hidden door densors)

BR