Bluetooth Presence Detection "Mesh" - Multiple Units

All.

I am very interested in testing BLE Bluetooth presence detection using Rpi 3s. I am not sure if the range will be sufficient to cover my whole house. Would it be possible to have multiple “secondary” HASS installations running, which communicate via MQTT or something similar to coordinate presence information over a larger area?

For example a master HASS installation + two secondaries. If you’re “noticed” by >0 units then you’re home, otherwise you’re not_home?

Has anyone tried this and was it effective? If so, what yamn configuration did you use? I imagine the secondary units would be appearing on the master as “switches” and you could have “or” logic that determines if you’re home or not?

No experience with setting up HASS this way but I’ve experimented a lot with Bluetooth presence detection & RPi’s and have very mixed results. I used custom python & nodejs scripts to accomplish the presence detection, using MQTT to communicate between the multiple RPis:

Setup A):
House: 2-bedroom apartment, about 15 meters from one corner of the apartment to the other
Phone: iPhone 4S
Tracker: RPi 1 with 4.0 enabled Bluetooth dongle, located in the center of the apartment
Method: Using regular Bluetooth I pinged the phone, using the Bluetooth mac address, every 15 seconds. After three unsuccessful ‘pings’ the script considered the phone to be away.
Results: This worked very well. 99% success rate. Only sometimes if I was in the far corner of the house the system thought I was away. Presence was always detected before I opened the door.

Setup B) Then I bought a bigger house, moved in with my girlfriend and got a new phone:
House: 4-bedroom, 3-story house with concrete ceilings and walls.
Phones: 2x iPhone 6S, tried iOS9 & iOS10
Tracker: RPi 1 with 4.0 enabled bluetooth dongle. RPi 3 with built in Bluetooth 4.0
Method 1: Using the same method as my old house I pinged our phones using regular bluetooth pings to the Mac address. I used two RPis at different locations in the house in order to cover it all.
Method 2: I set up the two RPis as iBeacons using BTLE and assigned the iBeacons as zones using Owntracks.
Results: The ‘pinging’ method does not work with the iPhone 6s. Every couple of hours the BT in the iPhone 6S became unresponsive for a random period of time. This happens with both my and my girlfriends phones using iOS9 and iOS10. When the BT becomes unresponsive it is also not possible to auto-pair other devices to the phones so it’s not just a RPi issue. Only resetting Bluetooth on the phones fixed it. I’ve tried a much lower ping-frequency (5 minutes) and I’ve tried pairing the phones to the RPis but nothing helped.
Using the RPis as iBeacons also was not successfull. Sometimes there was an unacceptable 10-minute delay before the iPhone reported to be near the beacons. Also it reported ‘away’ every couple of hours.

So, if anybody knows a solution to the Bluetooth on the iPhone 6S freezing they would make me very happy. Until then I’ve given up and I’m using a combination of the pinging-method and geofences via Owntracks as a fallback.

G’day Dingle and thanks for the reply. It seems you’ve done a lot of testing. I’m interested in your experiences with the iPhone 6 as my wife and I both have one. I have an apple watch so I don’t think that my phone is likely to be turning bluetooth off at any stage - as they seem to communicate fairly frequently.

I will try and get some testing of my own done next week. I have a Rpi 3 that arrived yesterday,but there is a thread here which seems to indicate using the onboard BLE chip really slows down performancve of HASS, so I am waiting for my bluetooth dongle that I ordered for my current Pi 2B to arrive.

I’ve also read that using ownTracks with beacons has a bad effect on the battery performance of the phone when it’s away from the zones, but it seems to be working fairly reliably for me at the moment with no beacons, just using the geofencing for my home .

Fingers crossed a single pi with a dongle will have enough power to cover most of my (smallish house)., I guess we shall see.

I have not noticed any performance impact of using the internal BLE chip but I’m actually not using HASS, I am building my own NodeJS based application and it’s probably much lighter than HASS.

Connections that are initiated from the iPhone always still work indeed and if the iPhone does initiate a connection, it will be visible from the outside as well. I don’t know if it’s a bug or a feature (power saving?). For now my setup is also working pretty reliably but I do want to test some other things in the future:

  • Briefly pair with the phone every xx minutes to keep the iPhone from putting Bluetooth on standby (if that’s the issue)
  • Replace the iPhone with a BLE keychain. BLE has a bigger range so I would only need one beacon tracker for my entire house.
  • Play with other settings

Dingle

If you need someone to help test your nodejs app, then I’m more than willing… :slight_smile: Not sure I can convince the awfully wedded wife to carry around a BLE tracker, but it sounds like something I can look at for myself.

Do you have an example of the BLE keychain that you use?

I’m happy sharing individual solutions but I don’t think I’ll ever share the full app… I’m not a developer so I probably made major mistakes. Plus it’s very much hardcoded for my specific situation and not easy to extend to other people’s homes.

I don’t actually have the keychainholder yet but this one was recommended somewhere else: http://www.nutspace.com/products/nut3.

Here some words on how it works:
https://www.domoticz.com/wiki/Presence_detection_(Bluetooth_4.0_Low_energy_Beacon)