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

Thanks, I’ll give it a shot!

1 Like

didn’t mean for anything to bash so I do apologize for that. I just know a lot of work has gone into this. Yes he does need to improve documentation but I feel the same way about the entire HASS project. Documentation on every component is lacking. I just felt you were asking a lot but ill keep that to myself. I just dont want the dev to get mad and stop developing because this is literally the only bluetooth detection that actually works consistently IMHO. Anyways we are all here to help each other, if you need any help we got you. (not that im an expert by ANY means lol)

I would say to find out what your goals are with this project and then you can see what parameters you need. Personally I think im using monitor -trd on all of my pi’s this way once my door opens a departs sequence is started (multiple sequences actually). I do departs ONLY on a trigger just in case my phone dies at home.

2 Likes

@andrewjfreyer

Question. If I send multiple depart scans does monitor Queue them up OR just rejeect if its in the middle of a scan.

I keep getting an issue where ill have two pi’s at 0 confidence and one will be at 100. So i have to go and vpn to my home and run a depart scan again. Yeah I ould make a rule that fixes this but hoping there is a better way.

It’ll reject a scan if one is scanning. Increase the delays between your triggered scans. As a general rule, a worst-case scenario takes 5 seconds per scan plus whatever your inter-scan delay is. Default is three. So, if you have four devices, you’re looking at 29 seconds per ‘depart’ scan if all four of your devices leave at the same time (e.g., 4*5 + 3*(4 - 1)). If only one device leaves and three remain home, you’re looking at maybe 14 seconds (5*1 + 3*3).

I have two devices and I’ve put about 20 seconds between each of my depart scans.

1 Like

hmmm. I have done that initially but that MAC address is not showing in the scanned devices. it shows some mac address for other devices and everything is showing as unknown

is there any special setting to change?

I had really reliable results the first days but I must have done something or something else happened. Because now this is what I got yesterday when I was home + this night. What could I do to make it more or less perfect as it was before? Before sometimes the only things that happened was 100% to 50% now it’s more unreliable as you can see (:

Using this to scan an iPhone if that matters. Wasn’t low on battery and the night hours I had it charging.

1 Like

I’ve managed to get this up and running, but I’d like to connect it to my existing MQTT server which is running on the same laptop as Home Assistant (Monitor is running on a separate Pi).

I’ve tried entering the MQTT server details of the laptop and that didn’t work, and neither did attempting to bridge the laptop’s MQTT server to the one running on the Pi.

Has anyone had success with this kind of setup, who’d be kind enough to post their config?

Morning all. I’ve been using Monitor for the past few weeks with the default settings but I’ve notice that the script takes approx 3-5 mins to recognize both an arrival and a depart, any suggestions to speed this up? Previously i had been using the Presence script and it only took 5-10 seconds to connect.

Thanks

Yes mqtt_preferences

# IP ADDRESS OF MQTT BROKER
mqtt_address=192.168.X.X

# MQTT BROKER USERNAME (OR BLANK FOR NONE)
mqtt_user=iamauser

# MQTT BROKER PASSWORD (OR BLANK FOR NONE)
mqtt_password=myuserpassword

# MQTT PUBLISH TOPIC ROOT
mqtt_topicpath=monitor

# PUBLISHER IDENTITY
mqtt_publisher_identity='ha-monitor'

# MQTT PORT
mqtt_port='1883'

# MQTT CERTIFICATE FILE (LEAVE BLANK IF NONE)
mqtt_certificate_path=''

Did you restart Monitor?

I want to stop extraneous scans i.e. just regularly scan for 3 known mac addresses. Is this possible? I continue to be getting what appear to be general scans even with (what I think) is everything switched off. I only have 1 PiZW as that covers my house.

1 Like

I had it set up as you said, but it turned out there was a problem with the routing tables on my Pi.

For anyone who happens to have the same problem, I solved it with

sudo arp -s laptop_ip_address laptop_mac_address

Did you end up figuring this out? I’d like to use this together with my current GPS tracker and I’m not quite sure how to go about it.

No I have figured it out, still waiting for input that might help set it up.

Couple of questions:

  1. Does anyone here have a working setup with two entrances/exits covered by two Pis? My “hack” (that I haven’t actually put into practice but it’s just an idea in my head) is to have the most central of the two Pis setup in HA to report incomings and outgoings, but have the more remote of the two Pis linked to an automation to ONLY report incomings. That way the settings on the Pis would be more or less identical, but I just wouldn’t do anything in Home Assistant with the information provided by the more remote Pi for devices having left.

  2. Does anyone running esp8266 or other IoT wifi modules have problems with bluetooth interference? I am experiencing a LOT of WiFi drop outs for my IoT devices and I’m wondering if it’s the Pis bluetooth module querying causing it. Not sure. (This is monitor not presence).

Thanks

1 Like

How many pi nodes do you have running? How far from your pi is your phone?

Monitor can certainly still cause 2.4GHz interference if your settings result in frequent scanning. Adjusting settings can help.

Thanks mate. I’m using the default settings and am tracking four BT entities so I guess I should be OK! :slight_smile: Looks likely my interference is coming from another source!

1 Like

With four entities, monitor still could be the culprit, especially if only a subset of the group is home at any given time. I’d suggest following the logs for a while to see what is triggering ARRIVE/DEPART scans to see if you can minimize them.

MQTT Trigger-only depart scan are working great for me.

I am trying to get this to work, but it is not detecting my iphone while standing next to the PI.
this is what I get if I run from command directly.


and this is my known_static_addresses with one entity only
image
the iphone I am trying trying to monitor.

Am my missing something?

1 Like

What options are you using? Is bluetooth turned on on your phone?