Tutorial: Home Assistant Presence Detection with iOS and [monitor]

First, I need to acknowledge that there’s numerous methods to get presence detection with Home Assistant, each with their own pros and cons. When evaluating the various detection methods, I focused on three key aspects:

  1. The detection needs to be reliable and consistent. When I’m home, I’m home. I did not want incorrect arrivals/departures if my phone disconnects from Wifi or Bluetooth or if I walk out in the backyard.
  2. The detection needs to be nearly instantaneous. I use the detection to unlock my front door and I wanted the door unlocked as I’m walking up. This requires detection within seconds, not minutes. I did not want to wait for my phone to connect to my Wifi or Bluetooth network.
  3. The detection must not significantly impact battery life. I did not want an always on GPS app running in the background that would be necessary for the detection.

I’ve been inspired by multiple ideas and projects from members of the HA community which I’ve combined into this tutorial here. Hopefully this helps or inspires someone else for their own presence detection.

Implementation

My implementation of presence detection uses [monitor] by Andrew J Freyer. [monitor] is “reliable, multi-user, distributed Bluetooth occupancy/presence detection”. If you haven’t heard of the project, you should definitely read the great write-up on the motivation and background of the project. However, for our purpose, we are going to use [monitor] to rapidly detect our presence by detecting our phones Bluetooth:

  1. When arriving within the proximity of my home, a HomeKit automation is triggered to turn on a linked input_boolean from Home Assistant.
  2. This input boolean triggers an automation to instruct [monitor] to begin actively scanning for our phone’s Bluetooth advertisements.
  3. When my phone is detected by [monitor], a MQTT message is sent to Home Assistant to unlock my front door.

Required Items

  1. iPhone — As this uses HomeKit, an iOS device with cellular is required.
  2. AppleTV, an at home iPad or HomePod — To act as a home hub (base station) for remote HomeKit control and automations.
  3. A Raspberry Pi (Recommended model, Zero W) — To run the [monitor] Bluetooth based presence detection.

Step-by-Step Guide

1) Input_boolean Setup

2) HomeKit Setup

3) [monitor] Setup

4) Node-RED Automation Setup

Conclusion

Hopefully this guide can help or inspire you for your own presence detection. Let me know in the comments the ways you are detecting presence in your own home!

3 thoughts on “Tutorial: Home Assistant Presence Detection with iOS and [monitor]”

  1. Hi,

    You write:
    I had to pair my iPhone with a Bluetooth speaker after a restore to enable the Bluetooth detection.

    Do you mean you have to also place a bluetooth speaker near front door, when your iphone get closed to your front door, it first connects to your bluetooth speaker and then it starts to broadcast every time you get home? If this is the case does monitor fast enough to detect your iphone and cause node red call zwave lock unlock?

    Reply
    • Hello, no you do not have to have a Bluetooth device like a speaker next to your door. iOS has a quirk that if the phone has never been paired to a Bluetooth device before, then it won’t broadcast its Bluetooth connection which means [monitor] won’t be able to pick it up. Hence why I had to pair my phone with just any Bluetooth device once (and can even unpaid it after), before the detection would work correctly.

      Reply
  2. Hey there, have you designed a good flow for automatically locking when leaving? I’d imagine you’d trigger a flow when the HomeKit switch turns off, then scan for departure then lock? What if you’d only want to lock if both people are gone?

    Reply

Leave a Comment