Motion sensor in the bedroom

Hello all,
I’ve an aqara motion sensor ( RTCGQ11LM - without hw hack) configured with zigbee2mqtt in my system located in the bedroom.
Here is the fact: during the night, when I sleep, I can moove in bed, and this turns on the light.
I would like to know if it is possible to set somehow that the light is turned on only if the motion is detected for longer the 5 seconds? but if the movement is less the 5" the lights stay off.

Here is my actual automation:

alias: Gestione luce camera da letto
description: ""
trigger:
  - type: motion
    platform: device
    device_id: e5b1ef6b036637201e3206448ee314c5
    entity_id: 0f0f63e8ab6e42f729baca200885df9d
    domain: binary_sensor
condition: []
action:
  - if:
      - condition: time
        before: "23:30:00"
        weekday:
          - sun
          - mon
          - tue
          - wed
          - fri
          - sat
          - thu
        after: "06:30:00"
    then:
      - type: turn_on
        device_id: 55c036b9ffe4c09675f3112c84d96bc1
        entity_id: 1ae484c1406ec67b6307c34d163e575b
        domain: light
      - delay:
          hours: 0
          minutes: 5
          seconds: 0
          milliseconds: 0
      - type: turn_off
        device_id: 55c036b9ffe4c09675f3112c84d96bc1
        entity_id: 1ae484c1406ec67b6307c34d163e575b
        domain: light
    else:
      - type: turn_on
        device_id: 38bf24f042aa715db7b96cd0cb3bda81
        entity_id: 101732e6302d3f3ce2a3248340dcb6c3
        domain: light
      - delay:
          hours: 0
          minutes: 5
          seconds: 0
          milliseconds: 0
      - type: turn_off
        device_id: 38bf24f042aa715db7b96cd0cb3bda81
        entity_id: 101732e6302d3f3ce2a3248340dcb6c3
        domain: light
mode: restart

Yes, you can add a duration to a device trigger as follows:

trigger:
  - type: motion
    platform: device
    device_id: e5b1ef6b036637201e3206448ee314c5
    entity_id: 0f0f63e8ab6e42f729baca200885df9d
    domain: binary_sensor
for:
  seconds: 5

However, most motion sensors have a “cool down” period. You will need to find out how long your sensors stay “on” based on a single movement, then make your duration longer than that.

1 Like

Thank you, seems working :blush: