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

I think @ryanrdetzel wants to know the Bluetooth mac addresses which would not be available via router or wifi.
The Bluetooth mac address is available in iOS under Settings - General - About in the “Bluetooth” section.

1 Like

oh doh! you’re right…

That is very odd behaviour.

I would suggest to try to determine the problem on each machine you insert the SD, boot and then

which mosquitto_pub
mosquitto_pub --help

to make sure that you are using the same mosquitto_pub on both machines (rather than something which is architecture specific, maybe) and that the version is indeed >1.5.

It is perhaps also worth checking that you can publish to your broker from both machines.

Thanks for your interest! So this is what happens when I put the card in each machine:

Raspberry Pi 3B:

pi@raspberrypi:~ $ which mosquitto_pub
/usr/bin/mosquitto_pub
pi@raspberrypi:~ $ mosquitto_pub --help
mosquitto_pub is a simple mqtt client that will publish a message on a single topic and exit.
mosquitto_pub version 1.6.6 running on libmosquitto 1.6.6.

Publishing is clearly working since Monitor is running and publishing to my broker.

Raspberry Pi 0 W:

pi@raspberrypi:~ $ which mosquitto_pub
/usr/bin/mosquitto_pub
pi@raspberrypi:~ $ mosquitto_pub --help
Illegal instruction

I’m baffled…

Hi everybody, i want to try monitor on my setup, i following the installation instructions, i actually have mosquitto run in my rpi but it’s inside a docker, really need to install another mosquitto directly on raspbian, or what need change on monitor.sh to connect to my mosquitto container

You only need one mosquitto/mqtt setup. Just point monitor at it.

What should I configure, to use my container?

on mqtt_preferences actually configure to connect to my container but when i tried to start the script show me this

Anotaci%C3%B3n%202019-09-25%20183718

There is an issue open on the Mosquitto github with identical symptoms:

1 Like

Thanks for letting me know. I’m still learning Linux and have some, but not a lot of, experience with Mosquitto, so I’m always ready to blame myself when things don’t go as expected. I didn’t think to look at the Mosquitto github! For now, I’m using the Pi 3B that wasn’t currently being used for anything else.

Here’s another question…when I run
ps aux

I see 12 instances of monitor listed, for example (some but not all):

root     22564  0.1  0.4   5764  3824 ?        Ss   16:32   0:21 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22645  0.0  0.2   5412  2536 ?        S    16:32   0:00 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22646  0.0  0.2   5412  2412 ?        S    16:32   0:00 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22647  0.1  0.3   5756  3000 ?        S    16:32   0:16 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22649  0.0  0.3   5700  2952 ?        S    16:32   0:05 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22651  0.0  0.2   5516  2724 ?        S    16:32   0:00 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22652  0.1  0.3   5588  3388 ?        S    16:32   0:22 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22655  0.0  0.2   5412  2768 ?        S    16:32   0:00 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &
root     22670  0.0  0.2   5416  2420 ?        S    16:32   0:00 /bin/bash /home/pi/monitor/monitor.sh -td -b -x &

Is this as it should be, or is there something I should do/change?

I also have multiple instances of Monitor listed when I run ps aux on my Pi 3B.

1 Like

Thank you for checking and letting me know! I appreciate your interest and your help.

1 Like

Just got an iPhone 11 & updated the mac address accordingly & now monitor doesn’t see it. After trouble shooting I ended up adding my 2nd mobile which is an Android for now as I take it with me as well.

I believe the issue maybe that in iOS 13.1 they have the feature where bluetooth is locked & you have to explicitly tell the OS to allow. Not sure really… Anyone else had an issue with iOS 13.1/iPhone 11?

@jaraeez
Did you pair your iPhone with something else?

My phone doesn’t seem to automatically broadcast an anonymous Bluetooth advertisement … what can I do?

Many phones will only broadcast once they have already connected to at least one other Bluetooth device. Connect to a speaker, a car, a headset, or monitor.sh -c [address] and try again.

Good point & thinking about it yes I did. I also have an Apple watch which I paired back after the restore from an older iPhone. It was later that that day I altered the monitor config.

Still no luck with the Nut Mini. It does show up from time to time under the CMD-RAND but I cant ever get it to show up in HA.
I have the MAC in the known beacons and I tried running monitor.sh with -b.

Two questions:

  1. What should the monitor.sh output look like when a beacon is properly configured and successfully scanned?
  2. Is there some way for me to monitor the mqtt data so I can see if there’s something going wrong on that end?

I have just recently (2 days) set up Monitor and am using a Nut Mini. I do NOT have the MAC in the known beacons file. I am running with the -b flag.

You can see the MQTT data in the MQTT tab of the Developer Tools page in HA. Subscribe to #, which will give you all topics, and click Subscribe. You will see the messages as they come through.

Here’s the monitor.sh output showing my beacon being marked away, and then returning home. Some random MAC addresses (blacked out), and then my Nut Mini (MAC whited out) going to confidence 0 (=marked away) and then returning home (confidence 100)

Mine shows up as PUBL (public), as I believe all beacons should.

Hope that helps…

Thanks! The output helps. However I’m not clear on the MQTT subscription process. On my MQTT tab in Dev Tools I don’t have a subscribe button to click. I’m not sure how to subscribe to #. Also, where would I be looking for these messages? On that same tab?

I removed the mac from the knows beacons and ran monitor.sh with -b. Same results as before. But it looks different from yours. Mine shows up as RAND

0.2.015 10:50:42 am [CMD-RAND] [passed filter] data: F2:1F:A3:2D:BE:3C pdu: SCAN_RSP rssi: -69 dBm flags: none man: unknown delay: 1

But my living room tv shows up as PUB
0.2.015 10:51:00 am [CMD-PUBL] D4:6A:6A:E1:EB:4C Living Room TV Hon Hai Precision Ind CoLtd -75 dBm

I never get anything that shows a confidence level though.

I’m not sure why you don’t have the subscribe part of that screen…what broker are you using? I’m using the Mosquitto add-on for Hass.io, and mine looks like this:

Also, have you disconnected the Nut mini from the app on your phone? I don’t think it works with Monitor if it’s connected to the app.

I am also using the mqtt add on. What version of HA are you running and what version of mosquitto? I notice you have some different dev tool tabs than I do.

I’m currently using HA 0.99.2 and Mosquitto 5.0. I’m going to be away from my computer for a while, I’ll check back later :slight_smile: