Motion Sensor Automation Script

Hey guys, i’m stuck :stuck_out_tongue:

I have a xiaomi Motion sensor in my Kitchen and the normal automation works fine:

  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d000113d0ff
    to: 'off'
    for:
      minutes: 5

But, because i have the Limitlessled bulps, they sometimes won’t turn off (just dim to the min).
So i came up with the idea to fire up a script with a Loop in it:

kueche_loop1:
  alias: "kueche loop1"
  sequence:
  - service_template: >
      {% if (not is_state('binary_sensor.motion_sensor_158d000113d0ff', 'on'))  %}light.turn_off{% else %}light.turn_on{% endif %}
    data:
      entity_id: light.kueche
  - service: script.turn_on
    data:
      entity_id: script.light_loop1
light_loop1:
  alias: "kueche loop2"
  sequence:
    - delay:
        seconds: 1
    - service: script.turn_on
      data:
        entity_id: script.kueche_loop1

Now the problem is, i don’t know how i can get the “off for X min” Attribute. (the sensor itself sets the state to off after 60 or 120 sec, and this ist too short)

Can someone help me with this? :slight_smile: