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

1 Like

Hi Mike - was this intended as a reply to my query? Cheers

yes sir , iā€™m sorry for the slow reply. mqtt lense will let you monitor mqtt traffic on your network as well as send mqtt messages. i think thats what you are wanting to do right?

ah, no, :slight_smile: thank you, though!
Iā€™m trying to diagnose why some ESP-like devices cycle between connected and disconnected from my wifi and pinpoint exactly whatā€™s failing:

  • My overall/overarching WiFi stability
  • DNS lookups
  • Mosquitto broker
  • The server hosting Mosquitto
  • Their connection to the cloud (Particle.io cloud)
  • My router
  • My powerline connected wireless AP
  • My connection to the internet
    etc etc etc

I just started using bluetooth earbuds with my iPhone that I use as a known device. When arriving home, most often connected with the earbuds, my HA does an ARRIVE mqtt scan with a door sensor. But it very rarely finds my iPhone. But if Iā€™m not connected to the earbuds or disconnect them it works just perfect when scanning. Any idea how to solve that?

Just out of curiosity, do you notice interference on your earbuds, like broken up/stalling sound when you arrive home?

I have also noticed that when my iPhone is connected to a speaker via BT, the status is often set to Away.

Hi, after a long while Iā€™ve tried again to activate precence detection with bluetooth. I bought a Tile for my Dog and tried to use the App from the company on an android tablet, thats always on. But inside home assistant, the tile detection wonā€™t work (Dog state was ā€˜homeā€™, as we where on a walk).

Next try was to buy a bluetooth usb dongle for my Synology NAS, which runs Home Assistant OS/Hass.io within docker. I was positively surprised, that the bluetooth dongle was working out of the box. Also docker container received the bluetooth informations.

First, I tried to install room-assistant. Used custom config, reinstalled it and used default config. Wonā€™t work. Same error:
Error: dns service error: unknown

Then I installed the recommended Hass.io-Add On from Limych and the Mosquitto broker. It starts like a charm and begins to show some devices, but after that, there comes this message:
value too great for base
It stops. It also disables the bluetooth usb dongle. Silence. Hmmmā€¦ but without that, it seems like a good start. It worked for 5 Minutes or so.

After that I tried the appdaemon version, looks promising, but it needs monitor.sh to run seperatly. I donā€™t know, how to start monitor.sh on a Synology NAS. I donā€™t want to run it directly on my NAS. Iā€™ve found a docker image of it, but it cannot start. Seems like an error, that it runs in a wrong docker container.

It seems, that I have to buy a raspberry pi zero or has anybody a hint for me to run monitor on a NAS within docker container? The next Days I will try to build my own Docker Container, that brings monitor.sh to Synology. I hope, somebody did it before, because Iā€™m a noob in things like that :smiley: Help :smiley:

Not really, for some days it has been working just fine. But then thereā€™s that one day, same exact scenario as the day before as I can see it, and then it doesnā€™t work.

Does someone know this bluetooth dongle?

LM842-8425: (1 onboard metal frame antenna and 1 external sma antenna (not included)
https://www.top-electronics.com/en/bluetooth-5-0-2t2r-usb-combi-adapter-1

With Antenna it will have a range of 100m. For me with 2 walls and dingle in middle of the house the radium around will be max 15m will this cover my whole house?

Iā€™m really starting to struggle on this one. I have an RPI Zero W and have followed the installation instructions, but I canā€™t seem to get ā€˜monitorā€™ to find my Honor Play phone.

Iā€™m just getting:

14:D1:69:12:60:83 confidence topic: monitor/zero1/deans_honor (has not previously connected to hci0)
> [-] 0.2.200 06-06-2020 03:58:18 pm [CMD-MQTT]   monitor/zero1/deans_honor { ... confidence : 0 ... }

Iā€™ve done various scans just using some hcitool commands and not found the phone eitherā€¦ but it does find a bundle of other devices.

Iā€™ve tried switching bluetooth on and off, scanning, connecting to some headphones, pairing with a TVā€¦ all nothing.

Iā€™d be pulling my hair out if I had any.

Can anyone point me in the right direction, please? Thanks in advance!

D

What phone do you have? iPhone? Android?

Iā€™ve bought a raspberry pi zero w and installed monitor on it. Iā€™ve started it with the following arguments: -a -x -b -tadr and updated the service with this arguments with -u. The tile was set as known device and the mqtt broker connection works. now, the monitor says things like that, when we leave:
monitor/storeroom/tile { ā€¦ confidence : 0 ā€¦ }
monitor/storeroom/tile/device_tracker : home
how can device_tracker information be updated?
It works better, when the mac address is set in the known beacon trackers and when the preference PREF_DEVICE_TRACKER_REPORT is set.

Itā€™s an Honor Play; an android. Tried with my wifeā€™s Vodafone Android too.

I have two RPIs, and they seem to behave a bit differently, even though Iā€™m running default settings on both. What is the duration of time it takes for the script to start a depart scan without any MQTT commands? One of my RPIs seems to register departures faster than the other. Where can I set this time duration in the config?

Hey,

How do i discover the MAC of Bluetooth iBeacons?

I use an app to find the UUID-Major-Minor values

Thanks

Hello there. Iā€™ve been trying to get this to work - given all the rave reviews. However, I keep geting HCI0 errors. As it turns out, my setup using a Linux VM with Home Assistant Supervisor + Monitor Addon does not work (sharing the bluetooth from host to VM), as Monitor requires a dedicated bluetooth device. I hadnā€™t read this thread at the time, so I figured Iā€™d try getting a Linux compatible USB dongle. I settled on the USB Plugable BT4 device as it has been vetted to work with Linux. I can confirm it works after getting the finicky drivers setup. That said - it only works for about 15 minutes before it hangs. According to this thread, apparently many USB dongles experience issues with handling duplicate BTLE advertisements. Running ā€œHCITOOL LESCANā€ I can see a few duplicates. That said, I searched the thread - but has anyone found a working USB BT Dongle? Thanks, J

Unfortunately I canā€™t really help with your errors, but Iā€™d like to propose another idea: get yourself a PiZero with Bluetooth and you are good to go. Bring your monitoring to itā€™s own ā€œmachineā€. And the PiZero should be more cost effective, itā€™s normally around 10.-ā‚¬, a lot less than another USB dongle.
Just my two cents :slight_smile:

1 Like

Iā€™ve been investigating the /status topic to see how reliable it is as a heartbeat indicator. Hereā€™s the sensor Iā€™m using:

sensor:
...
  - platform: mqtt
    name: 'Monitor Status Raw'
    state_topic: 'monitor/{path}/status'
    expire_after: 240
    unique_id: '[UniqueID]'
    force_update: true

I included an expiration to attempt to keep the sensor reasonably up to date. Because the only data thatā€™s passed under the /status topic is online, Iā€™ve created a template sensor that looks for the online state:

sensor:
...
  - platform: template
    sensors:
      monitor_status:
        friendly_name: "Monitor Status"
        value_template: "{{ is_state('sensor.monitor_status_raw','online') }}"

Looking at the last 7 days, sensor.monitor_status is not online 70% of the time, but Monitor continues to work as expected.

My current Monitor config is: -x -b -tad

Is /status meant to be a heartbeat, or is something else?

Iā€™ve got a couple RPiā€™s in my house; one for HA, one for my 3D printer, and another for RetroPi. Instead of deploying (and buying) some Pi Zeroā€™s, can I use these and just install the necessary components?