Light keeps turning off prematurely - Aqara p1 sensor

Since the Aqara FP300 is currently sold out, I’ve been trying to get an Aqara p1 to work similar to a presence sensor. The automation below is close, but sometimes the light turns off while I’m still in the bathroom. FYI, I’m using Office Lamp Two for testing purposes until I get my smart switch installed. I’ve tried various combinations of the sensors properties. I’ve changed the cooldown period several times. Still, sometimes, when I’m in the bathroom testing, not moving much, the light turns out until it detects more motion. I’ve added conditionals and a boolean, but it ALMOST works. It’s not a presence sensor so maybe I’m expecting too much.

Any advice to get this working 100% of the time would be appreciated.

alias: Bathroom Motion Sensor
description: ""
triggers:
  - type: motion
    device_id: 9bd9e6925d0ce3bc104616d0062fd52b
    entity_id: 5f13f951cf89154d58f5bc06fd3dcbf4
    domain: binary_sensor
    trigger: device
    enabled: true
  - trigger: state
    entity_id:
      - binary_sensor.motion_sensor
    enabled: true
    to:
      - "off"
conditions: []
actions:
  - if:
      - condition: state
        entity_id: input_boolean.bathroom_switch
        state:
          - "off"
    then:
      - type: turn_on
        device_id: 36886995dfa78b45228e71e7e46ce963
        entity_id: f8673b35003d86723c54f367950ea856
        domain: light
      - action: input_boolean.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: input_boolean.bathroom_switch
    else:
      - condition: state
        state:
          - "off"
        entity_id: binary_sensor.motion_sensor
        enabled: true
      - condition: state
        state:
          - "on"
        enabled: true
        entity_id: input_boolean.bathroom_switch
      - delay:
          hours: 0
          minutes: 0
          seconds: 10
          milliseconds: 0
      - action: input_boolean.turn_off
        metadata: {}
        data: {}
        target:
          entity_id: input_boolean.bathroom_switch
        enabled: true
      - type: turn_off
        device_id: 36886995dfa78b45228e71e7e46ce963
        entity_id: f8673b35003d86723c54f367950ea856
        domain: light
        enabled: true
mode: single

kinda yes. you can only leave light on for x minutes and let automation restart on new motion. Still you could endup in the dark when you dont want to, 100% wont be achieved. If you want presence only and not break the bank, look for sensy one : Sensy-One mmWave Sensor (Hi-Link LD2450) – UPDATE: 300+ Sensors Sold! 🚀

Yup, this is why you need a mmWave sensor. In the past I’ve just set the for: option on the ‘off’ trigger to 3-5 minutes or more. Yes it will leave the light on longer every time, but if you don’t want it to turn off.

I also use trigger IDs and a choose instead of the if/then. This way I can only trigger the yaml I want by the trigger ID and I don’t have to think about whether my if/then will mess with other parts of the automation.

You’re trying to use a PIR sensor instead of a sensor with both PIR & MMwave, so your results won’t be bulletproof.

If, for some reason you still want to create your own automation instead of using 1 of the many motion blueprints, then try adding a for to the off trigger.

Something like this:

  - trigger: state
    entity_id:
      - binary_sensor.motion_sensor
    enabled: true
    to:
      - "off"
    for:
       hours: 0
       minutes: 0
       seconds: 10

Probably messed up the formatting since I had to freehand it on mobile, but hopefully you get what I’m trying to say.

Thanks I’ll check it out. But I did order an Aqara FP1E which should arrive today.

Thanks, I’ll have to give trigger ID’s a try.