Aqara Motion Sensor Setup for Basement Lighting Automation

I recently set up my basement lighting automation using Aqara motion sensors and presence detectors, and I wanted to share my experience and a question I’m struggling with.

Setup Overview:

  • I have an Aqara motion sensor in the stairwell that triggers the basement lights when motion is detected.
  • There’s also an Aqara FP1 presence detector in the main basement room to monitor if someone is present.
  • Both sensors are grouped together for easier management.

Objective:

  1. When I come down the stairs, the lights should turn on. If someone is in the main room, the lights should stay on (unless manually turned off).
  2. If I go to my office (which doesn’t have a motion sensor), the lights should turn off after a short delay, even if the FP1 detector isn’t picking up any presence.

Current Setup Issues:
I’ve configured a script to handle the lights turning on, but the system isn’t reliably turning them off when I leave the main room. I tried resetting the FP1 state, waiting for a minute, and then turning off the lights if no presence is detected. However, this approach isn’t working as intended. Here’s the script I’m using:

plaintext
alias: ‘Basement Lights Automation’
trigger:
platform: state
entity_id:
- binary_sensor.aqara_basement_presence_group
to: ‘on’
action:

  • service: script.turn_on
    data:
    entity_id: script.basement_lights_on
  • device_id: 508e159cc75e7220dce8c832d8c92559
    domain: select
    entity_id: select.0x54ef441000712289_reset_nopresence_status
    type: select_first
  • if:
    condition:
    state:
    entity_id: binary_sensor.0x54ef441000712289_presence
    state: ‘off’
    for:
    minutes: 1
    then:
    - service: script.turn_off
    data:
    entity_id: script.basement_lights_off

Question:
I suspect that using Node-RED might simplify this automation, but I’m not very familiar with it. Has anyone successfully implemented a similar setup using Node-RED? Any tips or sample flows would be greatly appreciated!

Looking forward to hearing your thoughts and solutions!