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

Quick question I know it’s a long thread and this might be already answered but my question is can monitor work like room assistant? It’s only because I am using an android and room assistant doesn’t work with android yet I believe. Thanks.

No, it’s not designed to tell you which room.

However, RA works with any Bluetooth device… it doesn’t not work with Android.

1 Like

the comment above mine and a few previously to that mention issue with connections after updating to the recent release.

I’m having problems getting monitor to work after both my wife and I got ourselves new iPhones. I’ve replaced the old BT MAC addresses in known_static_addresses, but they aren’t detected at all. I get a blank when running hcitool name 00:MAC:00.

The addresses have been copied from Settings/General/About. I’ve also made sure to pair the new phones with other BT devices as has been advised in this thread.

Any ideas on how to troubleshoot?

It’s said that stupid questions do not exist, but I might have found one…

I have three pi’s: at the frontdoor, at the backdoor and at the second floor. All three of them are running fine, messages are visible as expected in MQTT explorer. So far so good, thanks to the well written install guide on https://github.com/andrewjfreyer/monitor.

I want my frontdoor Pi to monitor with the flags -tr -b and the other pi’s with the flags -tad, just like in the ‘example with home assistant’ on the page mentioned above.

Here’s the question, since I’m not a debian genius:
How or where do I set these flags? My goal is that whenever I reboot my pi monitor will automagically start with the desired flags. Have read quite a good part of this topic, but didn’t find the answer. Probably because it’s a stupid question…

Funny enough, I checked the github page, as I was sure, the options are listed there, but I couldn’t find them. :open_mouth:

Anyway, the script does show the commands, if you call it with option -h.

pi@pihallway:~/monitor $ sudo bash monitor.sh -h
> starting monitor.sh (v. 0.2.200)...


monitor.sh

Andrew J Freyer, 2018
https://github.com/andrewjfreyer/monitor

GNU General Public License

usage:

        monitor -h      show usage information
        monitor -R      redact private information from logs
        monitor -S      silent operation (no logging)
        monitor -c addr create connection to bluetooth device
        monitor -C      clean retained messages from MQTT broker

        monitor -V      print verbose/debug logging messages
        monitor -v      print version number
        monitor -d      restore to default behavior_preferences
        monitor -u      update 'monitor.service' to current command line settings
                        (excluding -u,-V, -F, and -d flags)

        monitor -r      repeatedly scan for arrival & departure of known devices
        monitor -s  report all mqtt messages to a single topic with
                                $mqtt_topicpath/$mqtt_publisher_identity  (defined in MQTT preferences file)

        monitor -f      format MQTT topics with only letters and numbers
        monitor -a      report all known device scan results, not just changes
        monitor -x      retain mqtt status messages
        monitor -b      report bluetooth beacon advertisements (e.g., generic beacons, ibeacons, and so on)
        monitor -t[adr] scan for known devices only on mqtt trigger messages:
                                a $mqtt_topicpath/scan/ARRIVE (defined in MQTT preferences file)
                                d $mqtt_topicpath/scan/DEPART (defined in MQTT preferences file)
                                r send ARRIVE or DEPART messages to trigger other devices to scan
        monitor -D [dir]        use alternative directory for configuration files

As you can see, there is an option to save the used parameters, -u specifically.

So, what you want to do is as follows:

  • log in with SSH to the corresponding Pi
  • go into the monitor folder (cd monitor/)
  • call monitor.sh with the parameters/options you want and add the -u option, like so
sudo bash monitor.sh -tad -u

monitor.sh will give you a confirmation message, that monitor.service has been updated. Repeat for all Pis you have running.

You can always change that by calling the script again, choosing different options.

2 Likes

Thank God the question wasn’t that stupid. I checked monitor -h, but missed the monitor -u flag.
Thanks!

Hi, how can i force an arrival scan from HA. becasue actually it could take up to 4mn to detetc presence (iPhone or BLE devices) ?

run monitor on PI3

Thxs

Try with these options. :slight_smile:

EDIT: Or here in the documentation: GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

I made a nodered flow that is similar to Odianosen25 home presence app if anyone is interested the details are in this thread.

Anyone have added the Tile Mate and does it work?

Tried it. But HA didn’t pick up the tile soon enough for me to make people presence at home.
When its dark outside and we came home it took 1-3 minutes before we went on in HA as HOME.

I use Geofency and Locative with a radius around my house to become HOME or AWAY.
Work for 3 years now without any problem. When we come home in the dark, the lights are already on :smiley:

Is anyone having issues with Monitor oscillating between 0, 45, and 90 for about 5 minutes after a departure before it finally settles on 0? It detects arrival pretty consistently, but for some reason it has problems with the departure. I’m just using it with the -r flag, and it seems to register “0” pretty quickly, but it takes a while to settle. I’m thinking about picking up a door sensor to trigger arrival and departure scans, but if it’s fluctuating even when I’m no where within range, I’m not sure if that would help.

First of all many thanks to Andrew J Freyer for creating such a brilliant solution for presence detection. As a newbie to HA, and after many disappointments with GPS tracking of iPhones, I bought a Raspberry Pi zero and have been absolutely delighted with the reliability of [monitor].

In order to reduce the time to detect changes (mainly when leaving home) I would like to set up a trigger to run a ‘depart’ scan. Using MQTT Explorer I can successfully run, and see immediate results, when I publish commands such as monitor/KNOWN DEVICE STATES or monitor/scan/restart however publishing either a monitor/scan/arrive or monitor/scan/depart command doesn’t seem to be working.

One other (again probably a newbie) question is can the output from [monitor] be ‘converted’ into device_tracker format to allow it to be selected as one of the options for user tracking in HA?

Do like this:

device_tracker:
  - platform: mqtt
    devices:
      bluetooth_svh: 'monitor/heime/stig_vidar_sin_telefon/device_tracker'

  - platform: mqtt
    devices:
      bluetooth_it: 'monitor/heime/ingunn_sin_telefon/device_tracker'
1 Like

Many thanks for this Stig.

Is there anything else that I need to do in order to be able to see the option within the “Select the devices that belong to this person.” list?

I am not quite sure what you are asking here. But you can add this device tracker to a person in the settings. Click on the person you want to edit and add one or more device trackers to that person.

1 Like

Hi Stig,
Yes, that’s exactly where I was trying to add the tracking. After a bit of investigation I found out that it looks like I had got the coding slightly wrong.
For my setup this works:
bluetooth_jw: ‘monitor/johns_iphone/device_tracker’

I am delighted to report that the option can now be added to my person entry:
image

Unfortunately it’s reporting that I’m away at the moment so it looks like there’s one final challenge.

Many thanks for all your help - very much appreciated :slight_smile:

I’m still trying to find it… somewhere ive found information that newer Tile Mate doesnt broadcast any name - I need to find “clear” space w/o other bluetooth beacons to find it MAC

Make yourself a little tinfoil head. :wink: :smiley: Just kidding, place your phone and the beacon in two or three layers of tin foil (aluminum foil :D) with just enough space for you to take a look at it. Like putting them in a tin foil bag. :slight_smile: