[monitor] Reliable, Multi-User, Distributed Bluetooth Occupancy/Presence Detection

No interference with WiFi by scanning every minute?

Not sure. How to tell there is a interference? What are the telltales?

Either wifi or bluetooth failing periodically.

Tell me @masterkenobi - can you only track one device’s rssi per esp32 via this component?

So far didn’t notice such issue.

You can add multiple ble devices in the configuration. But I only have one device to track at the moment. Can’t tell how reliable it will be if it were to track multiple devices.

Thanks for that

As befits an old jedi living alone in a cave :slight_smile:

1 Like

I’ve been using esphome to track my Mi band 3 for about a month and it’s been solid after some initial issues.

But you can’t scan on demand:

Also, I can’t get the super fast detection I want (3-5 secs). But as the Esphome BLE scanner is “passive”, I think that it is quite dependent on the frequency of the BLE devices advertisements.

This is why I’ve just pulled the pin and am going to try the monitor path (Pi zero just arrived). Then I can trigger a scan activated by a PIR sensor.

I’m very Interested in the new BLE 5.0 spec and what that will get us. Like using a Mi band 4 and a Pi 4?

@Klagio , this link may help a little.

is that a limitation of ESP32? or just ESPhome is not ready?

I’m not 100%. I think it’s a ESPhome thing.

well that scan on demand plus integration with persona and device_tracker would be perfect

1 Like

We are running monitor with 3 nodes, 1 with -tadr and 2 with -tad. All monitor nodes will report only home and not_home. All monitors are part of Person component with nmap presence detection. We have 3 doors leading to outside, so any door opening will trigger automation publishing depart script publishing to mqtt. Also, if nmap reports not_home for 15 seconds, automation will be triggered to run a script publising depart scan with (and if nmap changes from not home to home, arrival script is run). This gives us about 30 seconds delay leaving the house before we are reported as not_home (yard is quite big, so monitors will report not_home long before nmap does, but nmap will keep us home if we are home, but at yard). Coming home is about 15 seconds delay (nmap detects us first) and nmap detects us home from parking lot. As a backup I have automation running every 30 mins, scanning arrive + depart from monitors (if one of other scannings fail for some reason).

With this setup we are getting reliable precense detection. It is a bit of hack and it is not as fast it could be, but it works for us. Only using monitor, we had a lot of false not_home reports, also we were reported not home when at yard, so motion sensors for cameras etc were on, it was not good for us. Only using nmap we were also reported not_home, when phone was not connected to wifi for some reason. With -r flag our Neato vacuum and all monitor nodes were offline most of the time (too much interference to 2,4 ghz wifi) so I had to rethink the system. My phone is OnePlus 6 and wife has 5t (so only periodical scan or manually triggered will work).

1 Like

Been using Monitor for a week or so now I have a Pi3 and a Pi zero…Main floor and Basement. Im using as a peson home presence not room presence. For the most part its working but im noticing that it sometimes just stops scanning or not responding. Like example, I woke up this morning, im sitting in the same room as the pi3 and it shows me 0% confidence. Watching the mqtt activity nothing is happening untill I run the mqtt restart command.

Looking at the docs on guthub Im wondering in my case should I be using the -r flag to constantly monitor the area? Is it fine to use on both devices? I using my unifi aps as presence detection but plan to use all sensors in a bayesian sensor. As of right now Im not fully confidant using it with monitor. Any ideas or tips?

I just have finished the installation of monitor.sh on my seperate pi. But I am lost what to do next to get it integrated into home assistant. The target I want to achieve is to know when one of my family enters the room where the PI is. Only thing I configured is the mqtt config on the bluetooth pi so far. Any tips are welcome. I am very new in mqtt/home assist integration. So I dont know what exactly I have to do now.

" When I run sudo bash monitor.sh -b none of my iOS devices are showing up in the scans, though several items say they are are apple devices. I ran the following using my iPad MAC address
hcitool name 88:AE:07:79:FF:A0
And it returned iPad . I suppose I should add my devices to known devices, but why isn’t this and my other devices showing up with the monitor command? Where are the MAC addresses that are showing up in -b coming from?"

Hey, did you ever solve this? I think I’m running into the same issue. name call returns the name, but no iOS devices are showing up in the scan/on MQTT. I can get the neighbor’s AppleTV and Samsung TV, but not my iphone.

Thanks!

The usual way is to follow the instructions GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

The usual way is to follow the instructions GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

yeah…I’m pretty new to this whole thing too and I can attest to what lweberru is saying. The instructions are great, up to a point and then it’s pretty confusing and assumes a lot of knowledge on the part of the user. Not that this kind of thing isn’t specifically for a very particular audience who generally know these things…

But yeah. just “read the instructions” isn’t helpful in this case.

1 Like

Yes but pointing to the instructions (as I did) is helpful. There is a section there in the link I gave that is clearly labelled “Home Assistant Example”. If that isn’t understood or is unclear, ask away, but don’t come here without having read and attempting to understand.

I read the instructions. Before I addressed here, that I have no clue, about how to continue. As Fart mentioned. The docu and the examples assumes a lot of knowedge on the part of the user. So lets assume the following:

  • I have the monitor.sh running as service - log says all is fine. The mqtt integration also works (hopefully), but I dont know how to test even that. So How can I test it.
  • I want to detect at least one single device if it is “near” the PI, or want to know the distance or whatever it can tell me.

So an explanation what to do next is missing for me.

Lets take the given example there:

- platform: mqtt
  state_topic: 'monitor/first floor/alias'
  value_template: '{{ value_json.confidence }}'
  unit_of_measurement: '%'
  name: 'First Floor'

Which parts of the “state_topic” is a fixed string, which is a variable I have to replace which something different?
Where do I define the name of the location - here “First Floor”. I think I have to tell it the pi with the running monitor.sh?

I hope its now clearer, why I dont know how to proceed

1 Like

If it helps, this is what I did: Bluetooth LE Tracker issues

Hi John. Yes this helps me a lot. The feature “PREF_DEVICE_TRACKER_REPORT=true”, does this prevent the monitor from pushing these % values or is this just an additional feature to get a clear home/not home message? Also unclear is the need to use this known_static_addresses or what happens if I let it empty

I left known_static_addresses empty because when I inputted my Tile’s MAC in there it would scan my Tile twice and give a home message followed by a not_home message, thus rendering it useless. Left empty, it works fine, HA knows what MACs to look for via what I wrote in configuration.yaml

And yes, if you want percentages my setup might not be what you’re looking for, via PREF_DEVICE_TRACKER_REPORT I forced it to give me an “all or nothing” message…in any case, I am not sold on whether the percentages given are good enough for room detection (at least not without multiple Pis) and for “being home” detection a simple yes/no should suffice, no?

This setup + a Tile on my keychain means that I get recognized as Home as soon as I walk within BLE range (usually the front door of my apartment building, since I live on the ground floor) and get set to Not Home a few hundred meters down the street (which actually is very handy to not be set as Not Home when simply taking out the trash).