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

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

Iā€™m trying to install this but not getting very far!

Installed https://github.com/Limych/addon-presence-monitor but cannot get the add-on to runā€¦

mqtt:
  broker: 127.0.0.1
  port: 1883
  username: homeassistant
  password: [redacted]
  topic_root: presence
  publisher: ''
known:
  beacons: []
  static: []
blacklist: []

The Bluetooth Presence Monitor startup log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Hass.io Add-on: Bluetooth Presence Monitor
 Passive Bluetooth presence detection of beacons, cell phones, and other Bluetooth devices.
-----------------------------------------------------------
 Add-on version: 1.0.0
 There is an update available for this add-on!
 Latest add-on version: null
 Please consider upgrading as soon as possible.
 System: Home Assistant OS 5.10  (aarch64 / odroid-n2)
 Home Assistant version: 2021.1.5
 Supervisor version: 2021.01.7
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] monitor.sh: executing... 
[10:48:59] INFO: Updating running configuration...
[cont-init.d] monitor.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[10:48:59] INFO: Starting required services...
Starting system message bus: dbus.
Starting bluetooth: bluetoothd.
[10:49:00] INFO: Updating Bluetooth Presence Monitor to latest version...
From https://github.com/andrewjfreyer/monitor
 + 87d433b...ec0496b master     -> origin/master  (forced update)
Previous HEAD position was 87d433b Merge pull request #289 from hmmbob/patch-1
HEAD is now at ec0496b Merge pull request #353 from icouper/patch-1
Already up to date.
[10:49:01] INFO: Starting Bluetooth Presence Monitor...
> updated monitor (v. Unknown) -> (v. 0.2.200)...
> using custom config directory [/opt/monitor]
using /opt/monitor as config dir
/usr/local/bin/monitor: line 1987: [: : integer expression expected
/usr/local/bin/monitor: line 1987: [: : integer expression expected
/usr/local/bin/monitor: line 1987: [: : integer expression expected
/usr/local/bin/monitor: line 1987: [: : integer expression expected
/usr/local/bin/monitor: line 1987: [: : integer expression expected
/usr/local/bin/monitor: line 1727: public_device_log: bad array subscript
/usr/local/bin/monitor: line 1728: advertisement_interval_observation[$mac]: bad array subscript
Exited.
[10:49:36] INFO: Finishing services...
Stopping bluetooth: /usr/sbin/bluetoothd.
Stopping system message bus: dbus.
[cmd] /bin/bash exited 0
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Got farther with new config:

mqtt:
  broker: 127.0.0.1
  port: 1883
  username: '!secret mqtt_user'
  password: '!secret mqtt_password'
  topic_root: presence
  publisher: odroid
known:
  beacons: []
  static: []
blacklist:
  - '77:8D:45:A4:45:D8'
log_level: debug
extra_arguments: '-a -x -b -tdr'

New error nowā€¦

[-] 0.2.200 28-01-2021 07:15:47 PM [CMD-PUBL]	[passed filter] data: C:0D:0:3:1:DSCN_SPFS-B10 pdu: -7 rssi: UKN dBm flags: none man: 1119046 delay: 0
[-] 0.2.200 28-01-2021 07:15:52 PM [CMD-PUBL]	D8:E0:E1:B7:AA:32  amun Eecroic C. td -87 dBm
[-] 0.2.200 28-01-2021 07:15:52 PM [CMD-MQTT]	presence/odroid/D8:E0:E1:B7:AA:32/device_tracker home
[-] 0.2.200 28-01-2021 07:15:52 PM [CMD-MQTT]	presence/odroid/D8:E0:E1:B7:AA:32
 {
    "id":"D8:E0:E1:B7:AA:32",
    "confidence":"100",
    "name":"",
    "manufacturer":"amun Eecroic C. td",
    "type":"GENERIC_BEACON_PUBLIC",
    "report_delay":"1611271233",
    "rssi":"-87",
    "observed_interval":"-1",
    "flags":"x1",
    "movement":"none",
    "oem_data":"not advertised",
    "hex_data":"2001017000000000000000000000000",
    "resolvable":"PUBLIC",
    "retained":"true",
    "timestamp":"Thu Jan 28 2021 19:15:52 GMT-0800 (PST)",
    "version":"0.2.200"
 }
[-] 0.2.200 28-01-2021 07:15:52 PM [CMD-PUBL]	[passed filter] data: D8:E0:E1:B7:AA:32 pdu: ADV_IND rssi: -87 dBm flags: x1 man: amun Eecroic C. td delay: 1611271233
/usr/local/bin/monitor: line 1727: public_device_log: bad array subscript
/usr/local/bin/monitor: line 1728: advertisement_interval_observation[$mac]: bad array subscript
Exited.
[19:15:54] INFO: Finishing services...
Stopping bluetooth: /usr/sbin/bluetoothd.
Stopping system message bus: dbus.
[cmd] /bin/bash exited 0
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Hi guys,
I had a slightly annoying issue.
my wifes Iphone get picked up by monitor 5-10secs quicker than my android (S21+) does anyone else have this issue.

does it matter whoā€™s mac is stored in the known list first?

Hi All

I think the last HA update broke the mqtt for the monitor (%)


Everything worked fine before the update.
So have anyone else the same problem?
See same problems under power plugs monitoringā€¦

UPDATE: No it seems my Rasp3 Monitor just stops after a while?

I have the service set as described in this post:
image
I did theā€¦
sudo systemctl daemon-reload
sudo service monitor restart

But for some reason it just stops after a while?
I have it pointing to the MQTT running on my HA VM
Using MQTT Explorer in windows I can see its running and then stops
Then after a reboot of HA or some time I get the:
image

I think its 98% setup I just need to know why it stops :slight_smile:

It is communicating with the MQTT on Home assistant

1612550672: New client connected from 192.168.0.6 as bt_garage2086 (p2, c1, k60, u'casperse').
1612550672: Client bt_garage2085 disconnected.
1612550672: Client bt_garage2086 disconnected.
1612550672: New connection from 192.168.0.6 on port 1883.
1612550672: New client connected from 192.168.0.6 as bt_garage2090 (p2, c1, k60, u'casperse').
1612550672: Client bt_garage2090 disconnected.
1612550672: New connection from 192.168.0.6 on port 1883.
1612550672: New client connected from 192.168.0.6 as bt_garage2100 (p2, c1, k60, u'casperse').
1612550672: Client bt_garage2100 disconnected.
1612550672: New connection from 192.168.0.6 on port 1883.
1612550672: New client connected from 192.168.0.6 as bt_garage2101 (p2, c1, k60, u'casperse').
1612550672: Client bt_garage2101 disconnected.
1612550675: New connection from 192.168.0.6 on port 1883.
1612550675: New client connected from 192.168.0.6 as bt_garage2180 (p2, c1, k60, u'casperse').
1612550675: Client bt_garage2180 disconnected.
1612550675: New connection from 192.168.0.6 on port 1883.
1612550675: New client connected from 192.168.0.6 as bt_garage2191 (p2, c1, k60, u'casperse').
1612550675: Client bt_garage2191 disconnected.
1612550675: New connection from 192.168.0.6 on port 1883.
1612550675: New client connected from 192.168.0.6 as bt_garage2192 (p2, c1, k60, u'casperse').
1612550675: Client bt_garage2192 disconnected.
1612550675: New connection from 192.168.0.6 on port 1883.
1612550675: New client connected from 192.168.0.6 as bt_garage2194 (p2, c1, k60, u'casperse').
1612550675: Client bt_garage2194 disconnected.
1612550675: New connection from 192.168.0.6 on port 1883.
1612550675: New client connected from 192.168.0.6 as bt_garage2206 (p2, c1, k60, u'casperse').
1612550675: Client bt_garage2206 disconnected.
1612550675: New connection from 192.168.0.6 on port 1883.
1612550675: New client connected from 192.168.0.6 as bt_garage2207 (p2, c1, k60, u'casperse').
1612550675: Client bt_garage2207 disconnected.
1612550748: Socket error on client 4l2K61IBdHbGYGozzekq6z, disconnecting.
1612550763: New connection from 172.30.32.1 on port 1883.
1612550763: New client connected from 172.30.32.1 as 2Kh73Nw3zyV3JZO4ogYWzJ (p2, c1, k60, u'casperse').

@ casperse

I am taking a wild guess. Shouldnā€™t it be systemctl and not service?

sudo systemctl restart monitor.service

Thanks for taking the time to help! :slight_smile:
I must admit I just followed the guide and I thought rebooting the device would call the service

but maybee your right I tried and got this so maybe something is wrong in the service settings?

Run this and it will tell you what is wrong. You donā€™t need to cd into the folder to stop/start the service btw.

sudo systemctl status monitor.service

Also, I noticed my mqtt broker add-on would not connect after the last update. I restart HA again and mqtt worked again.

Okay I restored the service as listed in the above very long thread :slight_smile:
And I also switched to ethernet from wifiā€¦(Stopping after time?)

I see its ā€œONā€ but no % is shown on HA
image

Also the MQTT seem to have stopped:
image

If I just cut power to the Raspb3 I get it up and running again:
image
So the service works!