Which is the best way to build a room presence detection system?

Hey I’ve been using this for over a year now Monitor - multi user passive presence detector is room assistant better?

Do u have an example of your automation when the timer restarts if a specific device is in use in that room. I like this idea

I would use a “tripwire” to count the persons in the room and turn the lights on/off. Something like an infrared or laser receiver/transmitter pair. If you want also to personalise the scene, you could use bluetooth devices for individual recognition but that’s far far from perfect :wink:

My whole config is available here. However I’m afraid, all my automations are in AppDaemon :sweat_smile:

However in HA automations, I would do it like this:

Create a timer:

timer:
  office:
    duration: '00:10:00'

Create an automation that triggers on motion and turns the light on and starts the time (just in case you didn’t know this, when you try to start an already running timer, it will restart the timer instead).

automation:
- alias: "Turn on office lights on motion"
  trigger:
  - platform: state
    entity_id: binary_sensor.motion_office
    to: 'on'
  action:
  - service: light.turn_on
    entity_id: light.office_ceiling
  - service: timer.start
    entity_id: timer.office

Create a second automation that triggers when the timer finishes that starts the timer again if one of the “override” devices is on.

- alias: "Restart timer if an override device is on"
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.office
  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: switch.computer_office
        state: 'on'
      - condition: state
        entity_id: media_player.office
        state: 'playing'
  action:
    service: timer.start
    entity_id: timer.office

Create a third automation that also triggers when the timer finishes that turns the lights off if none of the override devices is on.

- alias: "Turn off lights if no override device is on"
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.office
  condition:
    - condition: state
      entity_id: switch.computer_office
      state: 'off'
    - condition: state
      entity_id: media_player.office
      state: 'off'
  action:
    service: light.turn_off
    entity_id: light.office

The last two automations can probably be merged into one automation, not an expert in HA automations :upside_down_face:
I didn’t test these automations, but feel free to try it.

6 Likes

Good idea, but how about this:
One person is in the room, another person enters the room, how does the “tripwire” know if the person inside the room left the room or another person entered the room? I think you would need at least two tripwires to know in which direction it was tripped, or am I completely wrong?

These guys were going to bring this to market, but seems theyve changed direction.
I saw it in BRuh a while back
https://www.xandem.com/

At the moment the only reliable solution for exact room presence detection is using a thermopile grid sensor such as Panasonic Grid-EYE
Altough not cheap (about $30 per sensor), it’s still pretty affordable but requires some pretty simple build on Arduino, RPI or other DIY.
There are modules available on Aliexpress

2 Likes

Ooh nice; this could be super useful for an upcoming project. Thanks!

I was looking for an automation like this, thanks!

Good point @Burningstone, it would require a tandem of 2 tripwires positioned very close together.

It’s an option… two tripwires one after the other can be used to know if the person goes into a room or out.
But please, correct me if I am wrong… a PIR sensor can “see” the body’s heat (or the IR radiation emited by a hot body) . So, why is needed that the body’s be moving to trigger? Even if the person is static, keeps hot…

1 Like

Here’s an explanation on how PIR sensors work. I can tell you for sure that all of the PIRs I used don’t detect motion if you are sitting still in a room.

1 Like

Nice I look forward to your impending tutorial ?! :wink:

There are already a number of tutorials easily found by googling “arduino grid-eye” or similar.
This one for example.

Thanks have you tried it. To be clear this would remove the need for movement such as what is required by a pir sensor. Looks like they can do room counts with this thing…a little bit Orwellian hehe

Looks like a bit of work to get set up going through that tutorial especially if its your first arduino project but appears to be well documented. Maybe a good one for Dr z

1 Like

Yes, it will detect a person presence even when the person is asleep :slight_smile:
Also, you can control the wall lights closer to the person position in the room.
Never got to hang this one to the ceiling, so no personal experience.

1 Like

Did you ever see a working, reliable setup with this live? I somehow doubt that this works very well, otherwise I’m asking myself why is not everyone using this instead of motion sensors.

This is in no way meant as an offence.

Yes, it’s being used quite widely for presence detection. I know at least a couple of successful setups of my colegues. I myself have built a POC device with a very simple code but never got to meet the WAF to install it :smile:

1 Like

Keep in mind that a PIR sensor costs less than a buck while this thing costs about 30-40 bucks.

I just used 2 VL53L0X to detect motion at the entry point at the top and bottom of my staircase.

I modified WLED codebase to support these sensors and to turn on / off an LED strip.

I considered using two of these at top and bottom to be able to track number of people on the stairs but thought it was more hassle than I need for now.

ESPHome also supports this sensor (https://esphome.io/components/sensor/vl53l0x.html). I did get a single sensor working on a NodeMCU running ESPHome and reporting the distance back to homeassistant, but I’m unsure if ESPHome can handle multiple of these on the same device because the sensors use the same I2C address and you need to change the address of 2nd sensor on boot if you want to read data from these on the same microcontroller.

Alternatively, you could look at VL53L1X, which has two ‘zones’ for being able to track direction of travel.
Though there is no ESPHome support for this (according to their site). I have ordered one myself to play around with but it hasn’t arrived yet.

See their example here: https://www.youtube.com/watch?v=c91Ve-g0J2U

Still seems like this is not going to work for tracking multiple people passing under the sensor at the same time.

2 Likes