Keep light on with presence

Having a stupid problem that seems like it should be simple, and I know its possible.

I have a presence sensor turning on lights when I enter a room (Aqara FP2). But, using the blueprints from a few people I can only see a way of turning the light back OFF after an amount of time. So my lights turn off after the set time, then a few seconds later they turn back on, because I am still in the room. There must be a way to keep them on as long as there is presence in the room, without them turning off first.

Seems like a basic function, but I’m not doing something correctly. What am I missing?

Thanks,

-Greg

I would just do it manually without a blueprint. Here is how I approach it. I set the automation to trigger on any change in the presence sensor (detected > not detected or the other way around).

I then set my automation to restart if there is a change to the presence sensor. More on this later.

On the Change Mode, set it to Restart

image

The key to the automation is a Chooser. There are two choices, presence detected and presence not detected.

The payload for the presence detected is to turn on the light.

The presence for the presence NOT detected is to have a delay and then turn off the light.

If presence is detected while you are in this delay the automation will restart (since we set it to restart) and then that delay is cancelled.

If no more presence is detected while you are in the delay then the light will turn off.

There are two choices, option 1 (presence detected) and option 2 (presence not detected).

OPTION 1

The Action for OPTION 1 is light turn on

OPTION 2

There are two Actions for OPTION 2, a delay and light turn off.

Most of my automations are done in this way with a Chooser. Remember, the delay will be cancelled if presence is re-detected and the light will stay on.

Collapsed it looks like this

Took me a minute to wrap my head around that, but I followed your amazing instructions, and it seems to be working great. You taught me some new ‘commands’ in HA which I never even realized I could do. This changes so much for me. Thank you so much, time to go play with more automations :slight_smile:

1 Like

Wow, a new approach for me aswell, happend to stumble upon this automation, i have entered it, curious to see if it works well when i get home.

And if you are using

  - platform: state
    entity_id: binary_sensor.your_motion_sensor_here # change this
    to: 'off'
    for:
      minutes: 2 # adjust as necessary 

There is no need to use restart mode, single mode will do, as the trigger gets triggered ‘on’ if motion is detected within the 2 minutes of ‘off’.
If you decide to use a delay (which I do myself, as I have a stateless motion detector (which only turns on, never off), then you should use restart mode :wink:

Tried this and although the light comes on… it doesnt seem to go back off again afterwards?

alias: Corridor Lights (State)
description: “”
trigger:

  • platform: state
    entity_id:
    • binary_sensor.presence_sensor_fp2_ab77_presence_sensor_1
      condition:
      action:
  • choose:
    • conditions:
      • condition: state
        entity_id: binary_sensor.presence_sensor_fp2_ab77_presence_sensor_1
        state: “on”
        sequence:
      • type: turn_on
        device_id: 5a070f6cbc55561694b031d6bf31c7f3
        entity_id: 54fd300c1ba68adeb63f017aeeb48c29
        domain: light
        brightness_pct: 100
    • conditions:
      • condition: state
        entity_id: binary_sensor.presence_sensor_fp2_ab77_presence_sensor_1
        state: “off”
        sequence:
      • type: turn_off
        device_id: 5a070f6cbc55561694b031d6bf31c7f3
        entity_id: 54fd300c1ba68adeb63f017aeeb48c29
        domain: light
        mode: restart