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

There are a few open issues that may relate to this. I’m working them through trying to debug.

So i have been running monitor for a week now and its a hit and miss for me.
Setup:
Hassio on ubuntu server host
Pi Zero W with rasbian buster lite with Monitor installed trough the github installation page.

Run Monitor with sudo bash monitor.sh -tad -u and it picks up the devices i added to: known_static_addresses. Use HA device tracker route and get a nice tracker in HA to use with my automations.

So technically its working perfectly… Until i reboot my HA host… Now it looks like my automation cant trigger the mqtt arrive/depart message I got running in an automation used with my front-door sensor.

Automation:

  - alias: Monitor - Door Scan
    trigger:
    - platform: state
      entity_id: binary_sensor.xiaomi_door_sensor_1
      to: 'on'
    action:
      - service: mqtt.publish
        data:
          topic: monitor/scan/arrive
      - delay:
          seconds: 120
      - service: mqtt.publish
        data:
          topic: monitor/scan/depart

Devtools - mqtt and doing a manual monitor/scan/arrive or monitor/scan/depart doesn’t work neither.

Only way i can fix it is running the sudo bash monitor.sh -tad -u command on the pi zero again.

Any tips to fix this? I want it to scan when the front door opens and when HA restarts.

caaa is at {"id":"FC:58:RA:1B:28:B4","confidence":"0","last_seen":"1583500481","retained":"false","timestamp":"Fri Mar 06 2020 13:15:57 GMT+0000 (GMT)","version":"0.2.200"}

Just a query about the device_tracker preference, seems a bit odd to me, doesn’t seem to be working? Have I possibly given the config file the wrong topic?

asdasdas

I have installed Monitor on a RPi3, it is pushing messages to my MQTT broker which i have setup in a docker, however it appears that home assistant is not discovering the devices and adding them into the system. anyone run into this or have any suggestions?

I don’t believe monitor supports mqtt discovery. You will have to add them manually.

You can try my app @greenspace10 Home (Monitor) Presence App V2

awesome i will give it a try this evening! thanks!

Trying to get this setup with Home Assistant. From the monitor side (Raspberry Pi 4) it seems to always report a confidence of 0. Even though my phone has Bluetooth turned on and is within a few meters of the RPi. Any idea’s?

[+] 0.2.200 08-03-2020 08:43:34 PM [CMD-INFO]	**** started arrival scan [x1 max rep] **** 
[+] 0.2.200 08-03-2020 08:43:35 PM [CMD-SCAN]	(No. 1) xx:xx:xx:xx:xx:xx arrival? 
[+] 0.2.200 08-03-2020 08:43:40 PM [CMD-MQTT]	monitor/pimon1/alias
 {
    "id":"xx:xx:xx:xx:xx:xx",
    "confidence":"0",
    "name":"alias ",
    "manufacturer":"SAMSUNG ELECTROMECHANICSTHAILAND",
    "type":"KNOWN_MAC",
    "retained":"false",
    "timestamp":"Sun Mar 08 2020 20:43:40 GMT+0100 (CET)",
    "version":"0.2.200"
 }

Any update on this? I have monitor.sh running on a RPi 3B (buster), 3B+ (stretch) and 4B (stretch). Monitor stops working on all three in less than an hour. I am using monitor version 0.200. I have been running with the verbose flag, but not seeing any errors. The output of monitor just stops updating.

No update, as I can’t duplicate the behavior on my end. When you say “stops updating” do mean that monitor stops providing MQTT output no matter what happens? If you are expecting monitor to periodically send the same status, I’ll note that’s not intended behavior of the script.

Just wanted to quickly check if this works with Apple devices that randomize the BT macs?

It does with mine, at least if you pair the phone. I did that for RSSI reporting, not that I actually use that :man_shrugging:

I have been running monitor.sh from the command line with following command:

sudo bash monitor.sh -V

The output from that command stops in under an hour. I expected to see log messages for arrive and departure scans periodically, but eventually the output stop and my phone status no longer changes.

Thanks
Chris.

Have you tried monitoring the broker side of things? Sending verbose logs may be causing the issue inadvertently.

I tried using it via systemd with the default options and it has worked for over 24 hours. My issue seems to be with the verbose flag. Thanks for the suggestion. The only thing I see now is:

./support/btle: line 399: printf: write error: Broken pipe

However, it still seems to work even with this error.

Chris.

1 Like

Hi guys,

Monitor is working great, the onlything is when I reboot HA all monitor sensors have the stats on unknown. They don’t update until I leave the house because the arrive/depart scan made it 0.

Is there anyway to restart Monitor trough a mqtt message or is there a other solution for this problem?
Found it:

monitor/scan/restart

That’s a known error that lots of users are experiencing, but I’m having difficulty duplicating. Working on it!

Let me know if there is anything I can do to help you debug. Thanks for the great software.

Chris.

Sorry for the noob question but ive set up monitor on a spare rpi3b and have Hassio running in docker on another machine. I’ve ran the script and monitor finds my iPhone with w confidence level of 100 but when I was the below in home assistant I can’t view the sensor? Any help appreciated.
‘’‘platform: mqtt
state_topic: ‘livingroom/monitor/matt_iphone’
value_template: ‘{{ value_json.confidence }}’
unit_of_measurement: ‘%’
name: ‘Living Room’
‘’’

Hi,

Tyring this script. It correctly detects when i turn on my bluetooth and go out of range. However, when coming back in range, it is not detected untill I restart the script.

I’ve run monitor without any arguments, and with -b.

What should I do to have it also detect the phone when it comes back ?
hcitool name returns the name.