Bluetooth LE Tracker issues

Little update:

  • On my primary HA installation on the NUC renaming the knowndevices did not do anything to help, new wifi devices get populated in to the file, but no new Bluetooth devices, and it will track only the first Bluetooth device to anything close to accurate, and the 2nd BT device appears to only be tracked if the 1st BT device is home.
  • on my old installation on my RPi I upgraded HA in the end, from 0.80.4 to 0.88.1, this appears to have had no impact on Bluetooth, with Bluetooth still working pretty flawlessly and very accurately on the RPi.

So only conclusion out of that, HA version does not appear to be the cause, so I guess it would have to be hardware related.

Thanks for the update. I was wondering if maybe btle would work on the new version. I ha have some tags that I wanted to try for the longer range.

1 Like

I might try out btle see if I have any better reliability with that on my NUC

I broke down and bought a Pi, will try to use this: https://github.com/andrewjfreyer/monitor - it will add a whole bunch of complexity, since I also have to install MQTT, but at least I don’t have to maintain another HA instance.

Will let you know how it goes :slight_smile:

good to know.
I started looking at something involving a 2nd instance of HA and linking via MQTT, but I failed to get anywhere with MQTT as my knowledge on this is pretty much zero.

Same here with MQTT :smiley:

I am still not quite sure what kind of voodoo is involved with it, buuut, I got it to work last night!

So far I’ve tested the fact that is sees me at home all night without marking me Away and that I am marked Away when leaving the apartment (or, rather, my gf was marked when she left for work this morning)…now the only remaining unknown is how quickly it marks us Home when arriving, will test that tonight and if all is well will post a mini-guide.

great stuff
a mini-guide would be very much appreciated. would the mqtt bit work with HA? I have HA running on my Pi with Bluetooth perfectly and I don’t really want to disturb that. but if I can get the HA BT devices and states in to my main NUC HA that would be ideal.

I was testing more on my NUC and found that using the command line and bluetoothctl this will monitor as it should, so it appears to be HA working with the Bluetooth system on the NUC does not.
the behaviour in HA appears to be:

  • First BT device in KnownDevices is tracked perfectly
  • the next 4 or 5 devices are tracked as long as the 1st devices in the list is home
  • If the 1st device is turned off / goes away from home, then all BT devices show as away
  • The all BT devices after the 5th or 6th BT device in knowndevices are never tracked.
  • The NUC wont discover new BT devices either (**edit)

To me this now sounds like a bug in something related to what HA uses but closely tied in to the hardware. Maybe 64bit implementation of Bluetooth on Linux. Maybe its Ubuntu (my NUC) vs Debian (Pi)?

1 Like

OK, so I’m cautiously optimistic that this is my long-term solution :slight_smile:

Here’s what I did:

  1. On a Raspberry Pi (3B+ in my case), I followed the steps described here: https://github.com/andrewjfreyer/monitor - specifically, the sections “Installation Instructions for Raspberry Pi Zero W” and " Configuration and Setup", right up until point 10 “Edit mqtt_preferences file:”, which I did not follow

  2. Created a new user in HASS.IO for MQTT purposes

  3. Installed the MQTT addon in HASS.IO and started it

  4. Restarted HASS.IO

  5. Installed the MQTT integration in HASS.IO, using the Discovery option

  6. Went back to the Pi and did Step 10 from the guide (“Edit mqtt_preferences file:”) with the user and pass I created in HASS.IO for this purpose

  7. DID NOT FOLLOW STEP 11 TO ADD ANY KNOWN MAC ADDRESSES (because when I did, it would just see my Tile twice when scanning, once home and once not_home, thus rendering the whole thing useless)

  8. Edited the behavior_preferences file on the Pi to add the line “PREF_DEVICE_TRACKER_REPORT =true” (thus the system will work as a device tracker, not just with the percentages initially described by the author, saves you from creating template sensors if all you want is home/not_home)

  9. Edited configuration.yaml to add a new device tracker:

The device address mentioned here is its MAC address and “first floor” is whatever you configured in the mqtt_preferences file

  1. Type on the Pi “sudo bash monitor.sh -b”

That’s it! Works great so far.

3 Likes

Hi,

Thanks for this, it looks good, I will try and find time to have a play and get this up and running, things have got a but busy lately with work.

Is there any particular reason the Bluetooth implementation doesn’t use the Bluez D-Bus interface?
Running external commands such as hcitool and parsing the output seems a bit flaky.

do you have the tile connected to your phone as well?

Nope, if the app is installed and Bluetooth on the phone is activated, it will always connect to my phone and not be available to the Monitor script. Thus, I don’t keep the app installed (I have BT always active on the phone because of my smartwatch).

Thanks, that’s what i figured was the case. Did you have it paired originaly? if so will uninstalling the app prevent the tile from connecting to the phone? I got mine yesterday and wanted to test it out and then started messing around with monitor.

Yeah, I had it paired to the app originally, updated its firmware, then uninstalled the app.

Thanks for the reply :slight_smile:

Is this solution still working well for you? I’m looking at buying a tile to attach on my dogs collar.

1 Like

Yep, working just fine since last year :slight_smile:

Hi

i’m having some issues that this stops working after a while
i run
sudo bash monitor.sh -b
but i think it stops when i close my ssh client.
it also gives me some false “aways” for a few seconds.

anyone care to share their config files?

H

sudo bash monitor.sh -b is a foreground command and thus closing your ssh client terminates all tasks attached to that login session. You’d have to install the command as a service and enable it so it runs in background. Once the service is enabled it will automatically start at bootup. After installing/enabling the service, systemctl start [service_name], or reboot…

I am stuck here…

I’m not seeing device_tracker.feasy_beacon in HA…

device_tracker:
 - platform: mqtt
   devices:
     feasy_beacon: 'presence/raspi-pi-1/DC:0D:30:03:51:2D/device_tracker'

  • Never mind…it’s there now.