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

> Blockquote

I don’t know if you ever resolved this, but thought I would respond albeit much too late in order to help anyone else that runs into this issue. My wife’s iPhone 7 did the exact same thing because it apparently doesn’t advertise outside of the pairing screen unless it is paired to at least one device. I paired her phone to a random speaker and then disconnected and viola, it works perfectly now.

Chris

Edit:. Complete coincidence that this was again the topic at hand when I posted to an ooold topic

2 Likes

I’ve been away for a while & would like to update ‘monitor’ to the latest version. Normally I would just do a git to bring it up to date though as my version is quite old (v. 0.1.481) just wanted to make sure doing a git will still work?

Thanks

We’re on the same boat, sadly. None of my three Android phones available for testing advertise anything.

Monitor keeps stopping for me.

This is what i get, last action 9 hours ago, only run 1 day and 4h since last reboot.:

pi@bt_monitor:~ $ sudo systemctl status monitor.service
● monitor.service - Monitor Service
   Loaded: loaded (/etc/systemd/system/monitor.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-11-27 18:17:11 UTC; 1 day 13h ago
 Main PID: 510 (bash)
   CGroup: /system.slice/monitor.service
           ├─  510 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  629 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  630 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  631 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  632 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  634 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  635 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  636 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  639 hcidump -i hci0 --raw
           ├─  646 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─  649 /usr/bin/mosquitto_sub -v -h 192.168.xxx.xx -p 1883 -u btmonitor_kitchen -P xxxxxxxx -t kitchen/scan/# --will-topic kitchen/btmonitor_kitchen/status --will-pa
           ├─21192 sleep 35
           ├─21249 sleep 15
           ├─21283 /bin/bash /home/pi/monitor/monitor.sh -r -a -x &
           ├─21284 timeout --signal SIGINT 30 hcitool -i hci0 lescan
           └─21285 hcitool -i hci0 lescan

Nov 29 00:10:37 bt_monitor bash[510]: 0.1.675 12:10:37 am [CMD-SCAN]        (No. 1) 94:65:2D:29:80:12 arrival?
Nov 29 00:11:05 bt_monitor bash[510]: 0.1.675 12:11:05 am [CMD-SCAN]        (No. 1) 60:AF:6D:75:18:86 arrival?
Nov 29 00:11:33 bt_monitor bash[510]: 0.1.675 12:11:33 am [CMD-SCAN]        (No. 1) 00:1E:B2:3A:FB:5D arrival?
Nov 29 00:12:01 bt_monitor bash[510]: 0.1.675 12:12:01 am [CMD-SCAN]        (No. 2) 94:65:2D:29:80:12 arrival?
Nov 29 00:12:30 bt_monitor bash[510]: 0.1.675 12:12:30 am [CMD-SCAN]        (No. 2) 60:AF:6D:75:18:86 arrival?
Nov 29 00:12:58 bt_monitor bash[510]: 0.1.675 12:12:58 am [CMD-SCAN]        (No. 2) 00:1E:B2:3A:FB:5D arrival?
Nov 29 00:13:26 bt_monitor bash[510]: 0.1.675 12:13:26 am [CMD-INFO]        **** Completed arrival scan. ****
Nov 29 00:13:26 bt_monitor bash[510]: 0.1.675 12:13:26 am [CMD-NAME]        94:65:2D:29:80:12 OnePlus3T  OnePlus Technology (Shenzhen) Co., Ltd
Nov 29 00:13:26 bt_monitor bash[510]: 0.1.675 12:13:26 am [CMD-NAME]        60:AF:6D:75:18:86 Asa  Samsung Electronics Co.,Ltd
Nov 29 00:13:26 bt_monitor bash[510]: 0.1.675 12:13:26 am [CMD-NAME]        00:1E:B2:3A:FB:5D TV  LG innotek
lines 1-32/32 (END)
1 Like

Awesome! She will be here tomorrow so I’ll be able to give it a try. So did you need to just disconnect the phone from the speaker or unpair it?

Leave it paired but you can disconnect. I guess that way it is constantly advertising so it knows if device is trying to automatically reconnect.

Known bug. Working through it in the beta, but it’s challenging to chase down. There’s a rare sequence of events that causes the BTLE listener to loop, either running out of memory or running the processor to capacity. I’m still trying to figure out the sequence of events that causes it, which is why the beta branch has taken so long to incorporate back into the master.

3 Likes

what Bluetooth LE device would you recommend please? happy to buy something but I didn’t think you could pair to BLE devices?

I have several iBeacons and you cannot pair with them

Cheers
Mark

Could be very well out of topic, but now that Google Home bluetooth tracking is added, is there a way we could benefit from that into this in any way?

Also I noticed, Google Home bluetooth tracking is giving a rssi value for iphone without pairing.

1 Like

Using an undocumented private api that could change or be removed without warning… leaving that wel alone for a few months

1 Like

The only device I ever paired with was v2.1

I apologize if I missed it but is there a mqtt topic that can be published to to force a status refresh. Since depart and arrive publish status change, they don’t force a refresh if I restart home assistant so I stick at unknown until a status change or restarting the service on the pi(s) Thanks.

Here you go:

alias: Update MQTT sensors on startup
trigger:
  - platform: homeassistant
    event: start
action:
  - service: mqtt.publish
    data:
      topic: "location/scan/restart"
1 Like

Or you can run it with the Retain flag, so it keeps the settings in the MQTT server for you, so HA will always read them on restart too,

monitor -x  retain mqtt status messages

I just wanted to point out that Google home is able to track rssi values from iPhone.
I was just wondering if we can do something to get rssi working on Monitor as well, that way it can also function as a room-presence detection platform.

I’ve been reading this thread for the past hour now and I’m confused about using mosquitto and multiple rpi-zeros and HA. Do I run mosquitto on each pi-zero as well as the instance I have running on the HA server? Or do I just need the one on the HA server? My HA is running on a rpi3b+ with rasbian and HA in venv. Mosquitto also runs on the same pi.

Another question. Can I run monitor on the HA server as a slave? I have a big house that would need a monitor node at both the front and back of the house. Since my HA pi is at the back of the house I wondered if I could run monitor there as the slave.

One mqtt server.

Yes I can’t see why you can’t run as slave

Thanks for the quick reply/answer.

One more question if I may. What type of range are people seeing with the pi-zero? I know walls and such limit the range but I would like to detect presence when my wife or I pull up to the house.

Maybe a stupid question, but would Monitor create any wifi interference during scans? Is it purely passive? Asking because I used a similar program like this in the past and wifi in the area of my RPiZeroW suffered, although I’m not sure why.

1 Like