Need help with my first ever automation

I new here. I just recently installed HAOS on an x86 machine and had a bit of a play with things.
Just yesterday I managed to connect up a few devices and had a go at my first automation. It is just a sensor that detects someone who is about to go up or down the stairs (at night time) and then switch an LED strip on. Then when there has been no motion for a period of say 15-30 seconds to turn off the LED Strip.
I’ve managed to get the automation to work, however I cant figure out how to change/adjust the time for how long the light should be on after it stops detecting motion.

In summary, the motion sensor is a Sonof SNZB-03, and it triggers an Ikea Tradfri smart wall outlet that is connected to the LED strip. Both the wall outlet and the motion sensor are connected to an SMLight SLZB-06M zigbee coordinator.

The automation to turn the light on is:

and the YAML:

alias: Stair LED on
description: “”
trigger:

  • type: motion
    platform: device
    device_id: 4c99e1ea873e41594704c1d64b4f998a
    entity_id: e2d02ec63d9dbf635532a01830787b1d
    domain: binary_sensor
    condition:
  • condition: sun
    before: sunrise
    after: sunset
    action:
  • type: turn_on
    device_id: 2cdb74f49a478c19bb8cee99d1f87a9b
    entity_id: ac48663507481be64319939094a54600
    domain: switch
    mode: single

To turn the LED strip off, I did this:

And its YAML:

ias: LED Stairs Off
description: “”
trigger:

  • type: no_motion
    platform: device
    device_id: 4c99e1ea873e41594704c1d64b4f998a
    entity_id: e2d02ec63d9dbf635532a01830787b1d
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 5
    condition:
    action:
  • type: turn_off
    device_id: 2cdb74f49a478c19bb8cee99d1f87a9b
    entity_id: ac48663507481be64319939094a54600
    domain: switch
    mode: single

However, when I alter the duration time, it makes no difference in the amount of time from no motion to the time the light switches off.

Can someone please let me know what I am doing wrong here. Also, if theres a better way to do this, then it would be appreciated if you could let me know.

Thank you

Sorry, the previous post didn’t allow me to include the screenshot of the lights off ui:

Please help us help you. The code formatting and the pictures are very hard to work from.

ok, thanks, I’ll try again.

I new here. I just recently installed HAOS on an x86 machine and had a bit of a play with things.
Just yesterday I managed to connect up a few devices and had a go at my first automation. It is just a sensor that detects someone who is about to go up or down the stairs (at night time) and then switch an LED strip on. Then when there has been no motion for a period of say 15-30 seconds to turn off the LED Strip.
I’ve managed to get the automation to work, however I cant figure out how to change/adjust the time for how long the light should be on after it stops detecting motion.

In summary, the motion sensor is a Sonof SNZB-03, and it triggers an Ikea Tradfri smart wall outlet that is connected to the LED strip. Both the wall outlet and the motion sensor are connected to an SMLight SLZB-06M zigbee coordinator.

The YAML for the automation to turn the light on is:

‘’’
alias: Stair LED on
description: “”
trigger:

  • type: motion
    platform: device
    device_id: 4c99e1ea873e41594704c1d64b4f998a
    entity_id: e2d02ec63d9dbf635532a01830787b1d
    domain: binary_sensor
    condition:
  • condition: sun
    before: sunrise
    after: sunset
    action:
  • type: turn_on
    device_id: 2cdb74f49a478c19bb8cee99d1f87a9b
    entity_id: ac48663507481be64319939094a54600
    domain: switch
    mode: single
    ‘’’

To turn the LED strip off, The YAML is:

‘’’
alias: LED Stairs Off
description: “”
trigger:

  • type: no_motion
    platform: device
    device_id: 4c99e1ea873e41594704c1d64b4f998a
    entity_id: e2d02ec63d9dbf635532a01830787b1d
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 5
    condition:
    action:
  • type: turn_off
    device_id: 2cdb74f49a478c19bb8cee99d1f87a9b
    entity_id: ac48663507481be64319939094a54600
    domain: switch
    mode: single
    ‘’’

However, when I alter the duration time, it makes no difference in the amount of time from no motion to the time the light switches off.

Can someone please let me know what I am doing wrong here. Also, if theres a better way to do this, then it would be appreciated if you could let me know.

Thank you

(Sorry if I haven’t formatted the code correctly :frowning: )

Where you set the value of “Duration” determines how long the Device Trigger waits for “no motion detected” before it triggers the automation (LED Stairs Off).

So if you set it to 30 seconds, the Device Trigger will trigger only after it sees the motion detector has reported no motion for at least 30 seconds.

So what is the amount of time that it waits before turning off the light?

At the moment the light stays on for just over a minute, and the setting is 5 seconds.
Do I need to restart the server whenever I make a change to an automation?

That implies the motion sensor’s “cooldown period” is fixed at one minute. In other words, it has an internal timer that is set to report “no motion” only after 1 minute has passed since it detected motion.

You’ll need to review the device’s specifications to see if its cooldown period is adjustable and can be reduced.

NOTE

Some devices report motion and occupancy.

Motion is typically sensitive to movement and has a short cooldown period whereas occupancy avoids being overly-sensitive to movement and has a longer cooldown period.

If your device reports both motion and occupancy, ensure you’re using the one that’s appropriate for your intended application.

Thank you for you reply. It looks as though the sonoff snzb-03 has a 60second cooldown time and isn’t adjustable.

I’m now thinking, is there some some code that can be added to the “Stair LED on” script to make the light have a countdown of say 30 seconds and then switch off?