Delay turn off light

Hi all I have an automation turning on my light switch when I open the door and come home.
Where I exit home and I turn off light and the open the door the light turns on…how can I say to the automatism not to turn on the light if it has benne turned off few seconds before? My automation is…

alias: Accensione luce corridoio
  trigger:
    entity_id: binary_sensor.door_window_sensor_158d00033a9289
    from: 'off'
    platform: state
    to: 'on'
  condition:
    condition: and
    conditions:
    - condition: sun
      after: sunset
    - condition: time
      before: '22:30:00'
  action:
    entity_id: scene.a5ak97silusytapx
    service: scene.turn_on
  • create an input_boolean
  • create an automation that sets the input_boolean to on when the light is turned off, a delay of 30 seconds, and then sets the input_boolean to off
  • adjust your current automation with a condition that the input_boolean is off

Add a condition:

- condition: state
  entity_id: light.YOUR_LIGHT
  state: 'off'
  for:
    minutes: 1

It will only fire the automation if your light has been off longer than 1 minute.

Can you please help me filling the condition in my automation?
Thanks

Had not thought of that solution. Way less complicated :slight_smile:

Here you go:

alias: Accensione luce corridoio
  trigger:
    entity_id: binary_sensor.door_window_sensor_158d00033a9289
    from: 'off'
    platform: state
    to: 'on'
  condition:
    condition: and
    conditions:
    - condition: sun
      after: sunset
    - condition: time
      before: '22:30:00'
    - condition: state
      entity_id: light.YOUR_LIGHT
      state: 'off'
      for:
        minutes: 1
  action:
    entity_id: scene.a5ak97silusytapx
    service: scene.turn_on

Replace “light.YOUR_LIGHT” with the correct entity for your light
“minutes: 1” can be replaced with “seconds: 30” etc.

Thanks I’ll check if it works