Comprehensive Room Presence Detection: Linking it all up!

My room presence detection methods are something I’ve been working on for what seems like forever, but it finally seems to be at a reliable stage, so I decided to write my first guide on my methods.

Since I’ve had Node-RED based room presence up and running in Home Assistant, it’s been so much easier to create new automations to control lighting, set alarms amongst other things. The number of conditions that must be fulfilled for an automation to run has decreased dramatically.

I’ve summarised my workflow below but have also written a more detailed guide along with sample files you can download at the link below:

I’ve also done a quick mock-up of how room presence can be nicely implemented in a lovelace frontend view.

In this example, both Person 1 and Person 2 are home (along with their car). Person 1 is in bed, their bed presence on the right side of the bed is indicated. They have also triggered motion in the bedroom. Person 2 is in the Living Room with the TV on. There is no motion detected in that room but Person 2 will remain set in the living room since her presence is currently being set by BLE room presence detection. Both the bathroom and the kitchen are empty and the shower is not running.

Methods

Briefly, the idea was to combine all the available indicators of presence to set house and room presence and person location as precisely as possible all the time.

My flows give a guide to combining various presence indicators like GPS, Bluetooth Low Energy (BLE), bed presence and motion sensors. I’ve also shown how to add other less commonly used indicators of presence like a humidity sensor in the bathroom to detect shower usage (suggesting presence). Things like TVs etc. could easily be added too.

The presence is saved under various input select entities that keep track of house and individual room presence as well as the locations of all the tracked people

All the flows are configured so incoming information that is more precise than what is currently set always overwrites the current states (such as a room presence indicator going from just “Somebody” to a specific person). These are also reverted to less precise designations if more precise information is no longer available.

I break my room presence detection down to three main categories - Home/Away presence, Generic Room Presence Detection (motion sensors and other generic indicators) and BLE Room Presence Detection (which determines which room individual people are in).

Home/Away Presence

At the top level - House presence and the Home/Away status of people are set based on changes in their person integration entities.

Generic Room Presence Detection

Next, motion sensors and other generic indicators of presence (like bed presence) are used to update input select indicators for individual room presence to “Somebody” when occupation is detected.

When these generic indicators suggest a room is no longer occupied, there is a short delay before the rooms are set to “Empty” unless a more precise room presence has been set (by BLE based presence detection) in which case the timer is cancelled.

BLE Room Presence Detection

This final layer of room presence detection is the most precise. I use ESP32 sensors in each room that scan beacons running on Android phones and detect which room the phones are in.

There are various checks before a person’s location is updated to a specific room to limit the effects of the rare incorrect BLE signals. These include things like checking that there has been recent motion in either the living room or the bedroom before confirming that a person is in the bathroom since they would move through either of these rooms on the way there.

Other checks include requiring a longer time in a certain room if a person’s location is set to be somewhere other than the bedroom while their bed presence indicates that they are in bed.

Update Room Presence

Finally, individual room presence is updated based on changes in a person’s room location. Again, setting a room to “Empty” is subject to a delay that can be cancelled by a room no longer being seen as “Empty”. This helps reduce the effects of temporary slip-ups by the flows when it comes to lighting and other automations.

This step also includes an added step that effectively reverts a room’s presence back to being set by Generic Room Presence Detection if generic presence is detected but BLE presence is not. This is done by setting the room back to “Someone” in the event that BLE doesn’t detect someone in a room, but generic presence is still detected. Now, the room will be set to “Empty” on by the absence of room presence based on generic room presence detection.

I designed these methods to be modular and to follow what I hope is simple logic so that they can easily be expanded or implemented by others.

Check out my more detailed guide at the link to see an in-depth look at the logic of each section and to download a file that you can import into Node-RED to try it out yourself. Let me know if you have any questions :slight_smile:

20 Likes

That’s almost the same setup as mine except that you did it in node-red and I did it in AppDaemon :smiley:

Nice! I had no coding background coming in to this so I really took to the visual ways of Node-RED and just stuck with it. Granted, having to configure all the function nodes has taught me some new skills too.

I’m curious, what sensors are you using for everything. How are you detecting when some is in bed or when the shower is on?

Oh never mind, I see you have them on your full guide…lol.

This is so cool, I think Im gonna implement something similar

1 Like

Jeeesh, I can barely get my lights to turn on and off the way I want, very impressive. :yum:

1 Like

I’m curious about that, can you share it?

Hi @Gergo.io. As a starter with ESP32, i’ve got a question.
Your set-up with hardware/HA seems a good one for me.
Have been looking at ESP32 for a while now, this sounds like a great project.

But, how do you use your 4 ESP32. How do you power them? And do you use a case with it?

Hey, sorry for the delay, I missed your comment. Here’s a link to an example of how to achieve a similar frontend, hope it helps: https://pastebin.com/uHtHzGhR

Hi Rick. I just powered all my ESP32’s with random iphone and other wall chargers I had laying around. Then using a generic microusb cable.
I didn’t use a case but did have them in a small breadboard so they could sit nicely on a flat surface.

Since I wrote that guide I had some undiagnosed issues with the ESP32’s going offline periodically. I never did get to the bottom of it. Sometimes they would come back online after a power cycle but sometimes I would have to reflash them and even then it wasn’t 100% effective. Could be the way I was powering them, I’m unsure. Since then I’ve been experimenting with room assistant but that requires pi zeros so it’s a much higher initial cost. I’ve had much better stability but if you were just starting out and didn’t want the initial cost I’d still recommend the ESP32 method.

When working, I’ve had really good results with both.

1 Like

Thank you for your reply!
Have ordered some ESP32’s this afternoon!

@Gergo.io

This looks like exactly what I have been trying to set up with a bunch of sprawling automations. I have a similar setup with mmwave/PIR/BLE trackers in all important rooms.

I haven’t worked with Node-Red before so the config looks a little intimidating. Would you be able to give me a high level overview of what needs to be changed in the node-red config to match my environment? Also, what is the minimum level of configuration I need setup on the HA side to verify it is working?

Thank you for sharing this, it looks like great work

1 Like

Hi,

I wanted to thank you very much for your work and help,perfectly (I need to make some more settings of course)