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

I agree that I shouldn’t need 7, that’s just where I ended up when I turned the knobs that in my limited understanding could affect things :slight_smile: . If I reduce PREF_DEPART_SCAN_ATTEMPTS to 3 I end up with this:

image

Is this a phone? Using the phone’s mac? Have you paired the phone with the nodes? Does it ever reach 100% when your not home?

  • Yes, this happened with either my Samsung S10 or now with my Pixel 6 Pro.
  • The MAC is in known_static_addresses
  • Paired with the nodes? No, didn’t think that was a requirement. I can try that.
  • It never goes to 100%, only 90% and decays from there

Yeah, pairing with the nodes didn’t change anything :frowning:

Unable to start Mosquitto after a recent updates of Mosquitto. This is the updates list.

Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libev4 libuv1 libwebsockets12
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  libmosquitto-dev libmosquitto1 libwebsockets18 mosquitto mosquitto-clients
  rpi-eeprom
6 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,557 kB of archives.
After this operation, 346 kB of additional disk space will be used.
Do you want to continue? [Y/n]

During the update process, I get error saying mosquitto is unable to start.

Setting up mosquitto (2.0.13-0mosquitto1~buster1) ...
Job for mosquitto.service failed because a fatal signal was delivered to the control process.
See "systemctl status mosquitto.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mosquitto, action "restart" failed.
● mosquitto.service - Mosquitto MQTT Broker
   Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: signal) since Tue 2021-11-16 00:15:38 GMT; 182ms ago
     Docs: man:mosquitto.conf(5)
           man:mosquitto(8)
  Process: 12160 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
  Process: 12162 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
  Process: 12165 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
  Process: 12166 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
  Process: 12170 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=killed, signal=ILL)
 Main PID: 12170 (code=killed, signal=ILL)

Nov 16 00:15:38 ms1 systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
Nov 16 00:15:38 ms1 systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 1.
Nov 16 00:15:38 ms1 systemd[1]: Stopped Mosquitto MQTT Broker.
dpkg: error processing package mosquitto (--configure):
 installed mosquitto package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (241-7~deb10u8+rpi1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10+rpt2+rpi1) ...
Errors were encountered while processing:
 mosquitto
E: Sub-process /usr/bin/dpkg returned an error code (1)

Update: Seem like someone had reported the issue over at github. Temp solution is to downgrade back to v1.5.7.

Try setting PREF_RSSI_IGNORE_BELOW -75 in the behavioral_preferences

No change :frowning:

Can you post the output of one of the mystery messages. go to integrations, choose mqtt configure, enter # and hit listen or mqtt explorer if you use that. Then run the scan with the phone off.

topics are lr/myphone and lr/scan/depart

11/16/2021 6:50:12 PM
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:50:11 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:50:08 PM(-4.58 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:50:06 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:57 PM(-10.69 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:55 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:56 PM(-0.33 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:51 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:48 PM(-8.94 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:43 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:33 PM(-14.06 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:32 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:26 PM(-7.13 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:25 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:23 PM(-3.07 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:22 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:49:08 PM(-15.71 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:49:06 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:48:51 PM(-16.83 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:48:50 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:48:46 PM(-4.28 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:48:46 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:48:38 PM(-8.13 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:48:30 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:48:37 PM(-1.71 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:48:33 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:48:27 PM(-10.01 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:48:25 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:48:15 PM(-11.23 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:48:14 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:47:31 PM(-43.96 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:47:31 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:47:27 PM(-4.2 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:47:26 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:47:18 PM(-9.73 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:47:03 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:46:11 PM(-66.68 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:46:10 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:46:06 PM(-4.87 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:46:05 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:45:55 PM(-10.71 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:45:53 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:45:18 PM(-37.62 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:45:13 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:45:10 PM(-7.85 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:45:09 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:45:00 PM(-10.25 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:44:58 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:44:22 PM(-37.26 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:44:21 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:44:17 PM(-4.92 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:44:16 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:44:07 PM(-9.88 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:44:04 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:43:48 PM(-19.01 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"0","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:43:48 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:43:44 PM(-4.33 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"45","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:43:43 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:43:23 PM(-21.44 seconds)
{"id":"0C:C4:13:XX:XX:XX","confidence":"90","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:43:21 GMT-0500 (EST)","version":"0.2.200"}
{"id":"0C:C4:13:XX:XX:XX","confidence":"100","name":"myphone","manufacturer":"Google Inc","type":"KNOWN_MAC","retained":"true","timestamp":"Tue Nov 16 2021 18:37:33 GMT-0500 (EST)","version":"0.2.200"}
11/16/2021 6:50:06 PM
{"identity":"lr"}
11/16/2021 6:49:43 PM(-23.08 seconds)
{"identity":"lr"}
11/16/2021 6:49:22 PM(-20.62 seconds)
{"identity":"lr"}
11/16/2021 6:48:46 PM(-36.79 seconds)
{"identity":"lr"}
11/16/2021 6:48:25 PM(-20.5 seconds)
{"identity":"lr"}
11/16/2021 6:47:26 PM(-58.68 seconds)
{"identity":"lr"}
11/16/2021 6:46:05 PM(-81.76 seconds)
{"identity":"lr"}
11/16/2021 6:45:09 PM(-55.99 seconds)
{"identity":"lr"}
11/16/2021 6:44:16 PM(-52.9 seconds)
{"identity":"lr"}
11/16/2021 6:43:43 PM(-33.19 seconds)
{"identity":"lr"}

You have 2 nodes? There is no node name in the topic? They both report or is it just one of them?

I have a second one (br) running with -tad -x further away from the entrance. It doesn’t show the same behavior (just decays to 0% confidence) and also didn’t send out any departure scans.

I wonder if this is because of the way -tr works. I individually address each node and don’t use the relay function.

You could try setting both to -tad and adding to the automation to call both nodes to scan. When setting monitor in the mode that you want it to use, add the -u flag.

I was wondering if the node reacts to its own sent out departure scan. I am still confused why the confidence would be 90% again when I am not in range (I turn on airplane mode to test). BTW, the same thing (multiple scans) happens an arrival as well (but since confidence then is 100% it’s not having any impact).

I can use the door sensor to trigger departure scans, but for arrival I want to be registered before I reach the door. I will give it a shot.

Thanks for all the effort :slight_smile:

Running the first node with -td -x and triggering a sequence of departure scans with the door sensor seems to work.

Thanks again

I have 3 nodes (rpi zero w) setup. All have identical settings. When I issue either arrive/ depart scan, one (always the same one) lags in detecting what devices are presence or not. It usually happens 2 mins longer. I looked at mqtt explorer as the scan is happening and it running. The status: online time changes to the time I issue the scan, but for whatever reasons, it thinks either the devices are still presence or not. It takes a few minutes after, then it realizes those devices have changed presence.

Anyone knows what I can do with my current situation?

Hi

I’ve just installed a bunch of esp32’s around my house with espresence on them. I’m getting location data for my phone now, but in certain rooms where I have another esp32 on the floor above or below, I can get my phone showing as jumping between these rooms.

I’ve been looking for something that can help eliminate or reduce this issue, but I wondered if monitor can help with this or if there is another tool I can use in home assitant to achieve this?

Any help would be much appreciated.

Andy

Hi,
are any of you guys using the new RPI ZERO 2 have you noticed any difference?

Hey sorry for the incredibly late reply. I ended up using flags -tad and set up a door sensor to trigger MQTT messages every time it opens. I have arrival scan attempt set to 1 and departure scan attempt set to 2. On the Home Assistant side, I have a departure script that triggers the MQTT message on door open if Monitor currently thinks I’m home, and then again after 30s, again after another 35s, and then a final time after another 2 mins. On arrival, again I trigger the MQTT message on door open if Monitor currently thinks I’m not home, and then again after 15 mins. Has been pretty reliable so far, but I only have one node and live in a small apartment. Hope this helps!

1 Like

I’m trying to use this alongside Passive BLE monitor (homeassistant component that logs ble devices). It took me some time to realize doing this was causing things to not work. Monitor was seeing my devices as being dropped and then coming back over and over.

Is there a way to do what I’m trying to do? I think I know the answer unfortunatley.

Is this all on the same pi? Monitor needs exclusive use of the bt antenna