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

Only taken me a few hours but finally got this working. As I’m pretty much totally ignorant of all of this home assistant stuff and I am learning as I go along I would like a tiny bit of advice please.

So three bed house, typical UK size, living room, kitchen.

I have a pi zero running Monitor upstairs in my bedroom on my desk, where I tend to be most of the time. I have Monitor through the docker container on my hass instance downstairs in the living room. Both are in suitable proximities to anywhere in the house on that level. Don’t feel I need more monitor instances. I am just tracking three phones, myself, my partners and my sons.

So far I have not changed any behaviour preferences I am just looking at MQTT Explorer’s topics and I have set up device trackers for my hass monitor but not my pi zero monitor.

I have run monitor.sh with no extra arguments. I have read most of this thread, all 1992 posts but to be fair my eyes glazed over at one point.

Should I have any extra arguments? All I want to do is track home or not home, for quite rudimentary reasons - making sure all the lights have been turned off if we go out for a dog walk, or turning the heating off if it’s on and we’re out all day. Without any extra arguments, am I effectively spamming and causing inteference with the 2.4ghz wifi (so mgiht have zigbee issues?)

I said tiny bit of advice…

edit: I’ve been out, and zero monitor correctly reported my departure and arrival but the hass instance of monitor did not. same settings as far as I can tell

The answer is … complicated

I have it so that it does arrival scans automatically (and on demand), but departure scans only on demand. I use a door sensor (and some other logic) to trigger those.

So, you can use extra arguments to control that, but you don’t have to.

This is my setup as last documented, though I do need to do a minor update.

1 Like

If I don’t have to and it won’t degrade the system too much then I won’t bother. I don’t have 1000s of automations running anyway so one would hope I won’t slow anything down too much. I’ll check your config out, probably will change my mind haha

Anyone ever experienced their Monitor script go sort of haywire? Mine’s done it once or twice, today at 14:38 the script started posting declining confidence for both me and my wife, and soon set us to ‘0’ confidence and we were marked as not_home by Home Assistant.
Over the course of the rest of the afternoon the bluetooth dongles which are normally steady (so long as we’re home) have gone up and down in confidence like a yoyo.

Worked out (I think!) what was going on…

My MQTT sensors are sensors not binary sensors and when in a group Home Assistant sets the group status to unknown if the monitor sensor goes to unknown even if there is another group member home within the group.

Has anyone worked out a way to avoid this problem?

Thanks!

3 posts were split to a new topic: Enabling AppDaemon in HACS

Hi guys,
I’m running into some confusion to get multiple monitors setup.
I have 1 currently, using defaults from the github page.
mqtt_address=127.0.0.1
And the normal sudo bash monitor.sh
How do I make my first floor the main monitor?
And how do I add other monitors to my home?
I read stuff about different arguments like -b and so on, but not sure which to set and where to even set them?

I have it working for 1 node and 2 devices currently.
And its reporting in HA 100% for both devices when im close enough and 0 when i disable bluetooth.
But I’d like to make it more expansive and add more Rpi’s next week for better coverage

Is there any good guides on how to easily setup multiple Rpi’s for monitor and get them all talking to each other and to HA?
(sorry new to this)

Hi all, i’m using monitor now since a few months.
I trigger ARRIVAL and DEPART scans only via MQTT from a Fibaro Home-Center with Door-Sensors.
There are 3 Devices in the known_static_addresses file.

It does trigger Arrivals and Departs of all 3 devices correctly, but when only the 3rd device (3rd in list of known_static_addresses File) comes home (ARRIVAL, no other Devices home yet) there is a Delay of about 20 secondy until monitor detects the Device.
For the first Devices (first in list of known_static_addresses File) the delay is only about 2 seconds, sometimes faster.

Is it somehow possible to speed up the detection? Maybe by lower the delay between detecting the devices in the known_static_addresses list?

Thank you in advance for your help.

EDIT: I just took a closer look to the monitor.sh script and tried the command "hcitool name " by myself.
Even if i terminate the hcitool with Ctrl+C after e.g. 2 seconds of scanning a not present Device and immediately start a new scan of a present device, the present device will be discovered only after about 4 more seconds.
So i think that there is a 5 second timeout between every “hcitool name”-Scan.

Is this by design and hardware-related or can this somehow be changed?

EDIT2: i now have downloaded an old blueZ Library (5.40) where hcitool was included and changed the timeout there to 2.5 seconds and recompiled it. Now an Arrivalscan is much faster. I will look at my logfiles the next days if everything is working as expected.

All,

Quick question: Does Monitor handle Clusters where you have overlapping regions, and hence prioritizes leaders (through Weights for example) ?

Monitor isn’t like Room assistant. It doesn’t care about where you are, simply that you’re home, or not, and publishes to unique topics for each instance of monitor. It’s up to you how you handle the multiple sensors.

TL/DR: No

What kind of iBeacons are people using here?

Just wanted to give my recommendation for AprilBeacon N01. It has an integrated acceleration sensor and it can change advertising interval based on the acceleration. So when it’s on the move (in your pocket with keys), it can advertise e.g. every 700ms. When it’s lying still in your key-cabinet it can advertise e.g. ~5000ms. This will give the best detection speed when arriving home, and the best battery life when you don’t need the fast detection anymore.
People at AprilBeacon have been very supportive and actually this changing advertising interval was requested by me on their forum. They built a special fw-release for me based on my requirements. And these requirements were based on the iBeacon usage with Monitor-project. Good job!

What I’d like to know from you, would you see a benefit if the Tx Power could be also changed based on the iBeacon acceleration sensor? E.g. +4dB / 700ms when on the move and -8dB / 5000ms when sitting still? I can only imagine the battery life improvements achieved with these settings. We’re talking about years maybe (CR2032)?

I’m currently trying to convince the AprilBeacon staff to investigate if they could make the Tx Power automatically adjust based on the acceleration:

What are your thoughts? If more people than just me would be interested, maybe the company is more supportive to new requests.

I’m using a couple nut minis. One on each of our keychains and it’s been a rock solid way of detecting if anyone is home or not.

I’m using three Gigaset g-tag beacons. :slight_smile:

Sorry guys, I am new to this topic, I just want to know what the real advantage of using Monitor vs Room Assistant and if there is no one-size-fits-all, when is best to use which ?

Much appreciated!

Can’t get device info: No such device

I have the same message as you. What rpi you are running that works? I am using a rpi3 b+ as well.

This is my mqtt credentials installed with HA not with the rpi3.

# IP ADDRESS OR HOSTNAME OF MQTT BROKER
mqtt_address=192.168.1.20

# MQTT BROKER USERNAME
mqtt_user=username

# MQTT BROKER PASSWORD
mqtt_password=password

# MQTT PUBLISH TOPIC ROOT
mqtt_topicpath=monitor

# PUBLISHER IDENTITY
mqtt_publisher_identity='hallway'

# MQTT PORT
mqtt_port='1883'

# MQTT CERTIFICATE FILE
mqtt_certificate_path=''

#MQTT VERSION (EXAMPLE: 'mqttv311')
mqtt_version=''

Update: I figured it out. It was a combination of things.

–The bluetooth service was not running.

sudo service bluetooth start

–There was No default controller available

sudo systemctl start hciuart.service

IMO if you want to have a rough idea of where your phone is, Room Assistant is a good option. If you just care about home/away then both work.

Monitor.sh is for a simple detection of presence. Normally you use monitor.sh near your “gateways” like the front door, the garage, the balcony door and so on… It is simply for knowing, if someone is there or not (is in or not).

RoomAssistant is to detect where exactly you are, even in a room, it should be able to tell, where in that room you are. You use this, to switch on lamps when someone enters the room. It is more detailed and uses other techniques, that are more exact, but not as wide ranged.

There are a number of people that use both together, as these are very different approaches on different problems. :slight_smile:

Hi, I want to install Monitor on a rPi4 running HASSIO.
In HASSIO, how do I overcome the inablity to do git clone git://github.com/andrewjfreyer/monitor

Welcome to the community! :slight_smile:
If you want to use monitor.sh you might want to read the first post. :slight_smile: There are some explanations around the system, that you should get before deciding how or where you install it.

There you will also find the link to the Hass.io-AddOn from Lymich, or click here.

Hello. Need some assistant. Learning as I go. I am testing to see if I can trigger an arrive and depart using the developer tool. Nothing is happening in the tail log when I publish any of these topics. Is there something I am missing?

monitor/scan/depart
monitor/scan/arrive

2021-01-25_19-35-41

2021-01-25_19-46-04