Aqara FP300 Presence Sensor Automation

I just got my Aqara FP300 Presence Sensor set up in Home Assistant. I set the sensor up in the Aqara app as a Zigbee device, then closed the app once it had finished changing it to Zigbee. In Home Assistant, I installed two apps: 1: MQTT Mosquito Broker, and 2: Zigbee2MQTT. I paired the Fp300 using the Zigbee2MQTT “Permit Join” function.
After that, I created an automation that uses the PIR or Presence Sensor (either) to turn on a Smart Plug that controls a light. Only the FP300 Presence sensor can turn off that Smart Plug (I chose this because the PIR sensor kept staying on 2 minutes after I left the room, and I wanted the light to shut off sooner if no one was in that room). I also added a 20 second timer so that if the PIR detected something, but the Presence Sensor did not (such as me starting to walk in that room, but turning around), the Smart Plug would still be turned off 20 seconds later.
Here’s the automation:

- alias: "Bathroom Light Strip (FP300 PIR + Presence Control)"
  description: >
    PIR turns ON quickly. Presence turns ON slower. Presence controls OFF.
    If no presence detected within 20 seconds after PIR,
    light turns OFF automatically.
  mode: restart
  id: date02102026001

  trigger:
    #############################################################
    # FAST ON (PIR)
    #############################################################
    - platform: state
      entity_id: binary_sensor.aqara_fp300_sensor_pir_detection
      from: "off"
      to: "on"
      id: pir_on

    #############################################################
    # BACKUP ON (Presence direct)
    #############################################################
    - platform: state
      entity_id: binary_sensor.aqara_fp300_sensor_presence
      from: "off"
      to: "on"
      id: presence_on

    #############################################################
    # TURN OFF (Presence clears)
    #############################################################
    - platform: state
      entity_id: binary_sensor.aqara_fp300_sensor_presence
      from: "on"
      to: "off"
      id: presence_off

  action:
    - choose:

        #############################################################
        # PIR → TURN LIGHT ON + 20s PRESENCE CHECK
        #############################################################
        - conditions:
            - condition: trigger
              id: pir_on
          sequence:
            - service: switch.turn_on
              target:
                entity_id: switch.smart_plug_mini_5

            # Wait up to 20 seconds for presence to activate
            - wait_for_trigger:
                - platform: state
                  entity_id: binary_sensor.aqara_fp300_sensor_presence
                  from: "off"
                  to: "on"
              timeout: "00:00:20"
              continue_on_timeout: true

            # If presence never activated → turn light OFF
            - choose:
                - conditions:
                    - condition: template
                      value_template: "{{ wait.trigger is none }}"
                  sequence:
                    - service: switch.turn_off
                      target:
                        entity_id: switch.smart_plug_mini_5

        #############################################################
        # PRESENCE → TURN LIGHT ON
        #############################################################
        - conditions:
            - condition: trigger
              id: presence_on
          sequence:
            - service: switch.turn_on
              target:
                entity_id: switch.smart_plug_mini_5

        #############################################################
        # PRESENCE CLEARS → TURN LIGHT OFF
        #############################################################
        - conditions:
            - condition: trigger
              id: presence_off
          sequence:
            - service: switch.turn_off
              target:
                entity_id: switch.smart_plug_mini_5
3 Likes

Great job!

If it’s bothering you, play around with the 2 settings below.

I know the first one mentions Presence instead of PIR, but I’ve been testing this for the past 2 months and it definitely affects the PIR reporting off states. In my case, all PIR triggers last exactly 60s with that setting above:

I did try changing the PIR setting you showed, but when I exited the settings screen and went back to look, it kept jumping up to higher delays. The adjustment I made just wouldn’t stick - like it is haunted. Maybe it needs time to “learn”? In any case, I was able to solve it in my yaml. Now, the light turns off 10-15 seconds after I leave the room even if the PIR is still on. Thank you for your suggestion.

1 Like

Weird, never had that happen to me. Worst case scenario I had to wait a few minutes for the setting to take since the device needs to “check in” for the updates to be applied.

Yes, you need to trigger the Spatial Learning and make sure nobody is in the room for at least 10 minutes while it runs.
Might also be a good idea to ensure that “Ai interference source selfidentification” toggle is on when running spatial learning. I’m still not 100% sure what benefits this brings outside of the spatial learning, but I left it on just in case.