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

I am running owntracks on MQTT in my HA and works well. After adding the hostname in MQTT preference, the monitor.sh, display hang there.


          *** BETA/DEV BRANCH ***


===================================================

> starting monitor.sh (v. 0.2.200)...
> warning: for security purposes, please consider changing 'username' in: mqtt_preferences
> warning: for security purposes, please consider changing 'password' in: mqtt_preferences
> warning: operating in anonymous and unprotected mode for mqtt broker at  **xxxxxxxx** .dlinkddns.com
> 88:75:98:FB:E9:E8 confidence topic: DRRM/Dir_Room/s9_avi (has previously connected to hci0)
> 44:18:FD:B2:6F:3C confidence topic: DRRM/Dir_Room/i_avi (has not previously connected to hci0)
> E0:AA:96:07:D9:59 confidence topic: DRRM/Dir_Room/n8_rama (has previously connected to hci0)
> A8:87:B3:9D:D8:13 confidence topic: DRRM/Dir_Room/a10_dilan (has not previously connected to hci0)
> C4:93:D9:B3:B3:5F confidence topic: DRRM/Dir_Room/a7_james (has not previously connected to hci0)
> 34:8A:7B:02:F4:83 confidence topic: DRRM/Dir_Room/j7_james (has not previously connected to hci0)
> FD:51:A1:48:4C:AF confidence topic: DRRM/Dir_Room/instinct_apac (has not previously connected to hci0)

Did anyone manage to overcome these issues?

Is there a way to tell what flags I currently have running? Trying to setup another pi and want to know what my other one is set at.

ps aux|grep monitor
2 Likes

As is is very time consuming to maintain,

Set and forget.

2 Likes

I am having strange issue now. this was working fine few days back.
Have a ble which the monitor detects and sends mqtt message. I can see the message being sent both in monitor log and mqtt log but i dont see any event registered ifor the sensor defined in homeassistant. Couldnot troubleshoot why homeassistant is not getting updates. Any ideas?

2020-02-04 15:59:12 INFO (MainThread) [homeassistant.setup] Setup of domain automation took 0.8 seconds.
2020-02-04 15:59:12 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to monitor/Entrance/vishnu
2020-02-04 15:59:12 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.legacy

MQTT log

1580834897: No will message specified.
1580834897: Sending CONNACK to Entrance8725 (0, 0)
1580834897: Received PUBLISH from Entrance8725 (d0, q2, r0, m1, ‘monitor/Entrance/vishnu’, … (161 bytes))
1580834897: Sending PUBREC to Entrance8725 (m1, rc0)
1580834897: Received PUBREL from Entrance8725 (Mid: 1)
1580834897: Sending PUBCOMP to Entrance8725 (m1)
1580834897: Sending PUBLISH to Entrance30252 (d0, q2, r0, m33, ‘monitor/Entrance/vishnu’, … (161 bytes))
1580834897: Received DISCONNECT from Entrance8725
1580834897: Received PUBREC from Entrance30252 (Mid: 33)
1580834897: Sending PUBREL to Entrance30252 (m33)
1580834897: Received PUBCOMP from Entrance30252 (Mid: 33, RC:0)
1580834957: Received PINGREQ from Entrance30252


monitor log

Feb 04 11:47:15 raspberrypi bash[30143]: }
Feb 04 11:47:15 raspberrypi bash[30143]: [+] 0.2.200 04-02-2020 11:47:15 am [CMD-PUBL] 18:04:ED:51:91:62 Vishnu unknown -77 dBm
Feb 04 11:47:15 raspberrypi bash[30143]: [+] 0.2.200 04-02-2020 11:47:15 am [CMD-MQTT] monitor/Entrance/vishnu
Feb 04 11:47:15 raspberrypi bash[30143]: {
Feb 04 11:47:15 raspberrypi bash[30143]: “id”:“18:04:ED:51:91:62”,
Feb 04 11:47:15 raspberrypi bash[30143]: “confidence”:“100”,
Feb 04 11:47:15 raspberrypi bash[30143]: “name”:“Vishnu”,
Feb 04 11:47:15 raspberrypi bash[30143]: “manufacturer”:“unknown”,
Feb 04 11:47:15 raspberrypi bash[30143]: “type”:“GENERIC_BEACON_PUBLIC”,
Feb 04 11:47:15 raspberrypi bash[30143]: “report_delay”:“0”,
Feb 04 11:47:15 raspberrypi bash[30143]: “observed_interval”:“0”,
Feb 04 11:47:15 raspberrypi bash[30143]: “rssi”:"-77",
Feb 04 11:47:15 raspberrypi bash[30143]: “flags”:“0x06”,
Feb 04 11:47:15 raspberrypi bash[30143]: “movement”:“stationary”,
Feb 04 11:47:15 raspberrypi bash[30143]: “retained”:“false”,
Feb 04 11:47:15 raspberrypi bash[30143]: “timestamp”:“Tue Feb 04 2020 11:47:15 GMT-0500 (EST)”,
Feb 04 11:47:15 raspberrypi bash[30143]: “version”:“0.2.200”
Feb 04 11:47:15 raspberrypi bash[30143]: }
Feb 04 11:47:16 raspberrypi bash[30143]: [+] 0.2.200 04-02-2020 11:47:16 am [DEL-RAND] RAND 73:B0:CF:E3:10:50 expired after 188 seconds
Feb 04 11:47:35 raspberrypi bash[30143]: ./support/btle: line 399: printf: write error: Broken pipe
Feb 04 11:47:56 raspberrypi bash[30143]: [+] 0.2.200 04-02-2020 11:47:56 am [CMD-MQTT] monitor/Entrance/426C7565-4368-6172-6D42-6561636F6E73-3838-4949
Feb 04 11:47:56 raspberrypi bash[30143]: {

First stable release of Presence Monitor Hassio Add-on

https://www.patreon.com/posts/first-stable-of-33765917

3 Likes

What would be the most lightweight implementation of Monitor when used with a single device?

I’ve read through the thread here over the course of the last week, and although I have been able to get Monitor up and running against my single phone, I have a feeling I have extra processes running that are not needed.

My setup is:

  1. A single Samsung Galaxy S10. I have it’s MAC entered in known_addresses
  2. A single rpi zero w loaded up with monitor
  3. A motion sensor to trigger the arrive and/or depart payloads

I’m running with the default Monitor config, only putting in the broker information. Messages are posted based on the BT status of the S10 (I flip it on and off, and also am out of the house sometimes), those are reflected in Home Assistant.

Are there pre-filters I should apply since this 1 phone is the only one I’m going to monitor? Meaning put those filers into on of the conf files? Also, since the motion sensor is my “check if the phone’s around” trigger, do I not need to monitor for bt changes? Meaning I only need to rely on the Motion Sensor to say when the phone should be polled so therefore monitor.sh should be run with certain flags?

I’ve not been able to make full sense of the -h information and the information here and on the github page. I think that’s a “me” problem, since this thing clearly appears to be doing what it’s supposed to do.

Hey guys, does anyone know if there is a way to send newly found bluetooth addressess upon arrival scan? I have Monitor working for over a year now and it’s pretty great! However I would love to detect when guests arrive.

The basic idea of this is if a new bluetooth address that doesn’t have ana alias is detected uppon arrival scan it can send mqtt message or a sensor can update that unknow bluetooth address was detected

This would be great for alarm, or airbnb where guests can be greeted. Would this be hard to achieve?

1 Like

Is there a way to use this without Hassio?

There’s only very recently been an add-on for this, you’ll find most folks use it without Hass.io :wink:

Just follow the install notes.

Hi,

Thanks for making this project, appreciate the effort you’ve gone to.

I’m just trying to work out the best way to implement this into my home automation system. I’ve got a raspberrypi and my home assistant server running on a NUC, I have bluetooth on both of them and have set up monitor on the raspberry pi and bluetooth presence monitor on home assistant.

I’ve put the raspberrypi in the garage and envision using my front motion sensor to trigger arrival scans (and I guess I can’t really have it triggering depart scans as well?) My goal is to consistently open my garage, unlock the door and turn on the garage light when we pull into the driveway. I can do this now with location tracking but it is too inconsistent, and using wifi connection for home presence detection is also a bit inconsistent.

So what are the recommendations for setting this up? I have my iphone, apple watch and my wifes iphone and apple watch on both machines detecting presence, I’ve tried setting up a bluetooth tile but am not having any luck getting the confidence level > 0, so have just shelved that idea for the minute and will focus on getting the phones/watches working.

What ‘extra-parametres’ should I be running on each machine. How do I make the pi default to the extra parametres?

Sorry for the long post!

Yes! I need this too.

Hi,

I have some issues setting this up here. Following scenario : I have a long driveway. The idea is to have two Pi Zero W’s, one at each end of the driveway. Each of our cars here have a USB BTLE beacon connected to the cars USB port and set to a rather low tx power. Leaving or arriving is then determined by signal detection order by the two Pis. I’m only interested in tracking beacons, no phones or similar. Right now I’m trying to set this up with one Pi and a beacon sitting on my desk here.

  1. I start monitor with the V and b flags. PREF_BEACON_EXPIRATION is set to 30 secs. PREF_MINIMUM_TIME_BETWEEN_SCANS is set to 5 seconds. I need pretty high frequency scans, so that the system doesn’t miss the beacon signal from a car passing by. When I plug in the beacon, it is detected and a mqtt message is sent, confidence 100%. Good. However, shortly before the beacon expiration time is reached (30 secs), several messages are sent with decreasing confidence, to reach 0 confidence after roughly 30 seconds. Then a few seconds later, another message is sent with 100% confidence again, as if the beacon was newly detected, only to reach 0% confidence after 30 secs again. This repeats indefinitely. During all this time, the beacon is sitting happily next to the Pi on my desk, sending its advertisements. I tried the r option too (I added the beacon mac to known beacons), but it does not change anything.

  2. I would like to do only passive scans for the beacon advertisements, so to avoid interference on high scan frequencies. No name requests, or any kind of active communication with the beacon. Basically like the --passive option on hcitool. How can I configure this ?

Thanks a lot for your help !

I’ve been trying to figure that out as well.
That’s the main reason I wanted this, but I cant seem to find how to automatically populate the known_static_addresses, or otherwise.

same here, did you figure it out?

Everybody, have a look at the new appdaemon app Monitor-App
Makes monitor a lot better with auto-reboot if connection lost, devices can appear in HA as device_tracker etc

2 Likes

I’ve just recently moved my HA instance onto a NUC, and repurposed the RPi to be one of my Monitor nodes. I added my phone and the wife’s (both iphones) to the known static list, and additionally registered both for rssi readings.

Both phones work flawlessly for the confidence level detecting. And my phone works for the rssi feed. But the wife’s rssi feed works only while near the node, and as soon as she leaves the house, I see the rssi strength dropping, then it shoots back up to -99dBm when signal is lost (but confidence shows 0 correctly), and stays there until she returns home.

I’ve removed her address and re-added it but it doesn’t resolve it.

Any ideas?

Per the docs, -99dBm is what monitor will report when the device is not present and an RSSI value cannot be obtained.

So, when my iphone is closer to the RPi, I get closer to -100 dBm. Further away it is, I get closer to 0 dBm? Correct? So if there is no signal, device not present (I’m not home), -99dBm is used…hence indicating I am close to the RPi? So I need to use the confidence level in conjunction with the rssi value…