HomeKit as a Presence Sensor

Hey Jon,

You can create a template sensor from the input_boolean.

  - platform: template
    sensors:    
      mike_home_sensor:
        friendly_name: Mike
        value_template: >
          {% if is_state('input_boolean.mike_home', 'on') %}
            home
          {% else %}
            not home
          {% endif %}

not sure if it will appear/disappear based on presence, but it will at least show home and away instead of on/off

1 Like

awesome thanks! I was able to get this implemented but I wanted something more like the attached photo. where the stats shows up under the icon of the sensor.

hapresence

Ah, those are device tracker entities. I don’t think there is a template device tracker available. I personally use the Home Assistant iOS app for to actually show location in HA. But use the HomeKit input boolean for triggering automations, as it has been much more reliable.

great thanks for the info!

are you using any other ways to detect presence? Home/Away?

just the HA iOS app. I just use that for information purposed only, and don’t rely on it for automations.

Hi, when you use the HA iOS app, are you using it via SSL to access your instance outside of the network? I am curious, as I am considering doing just that (plus Homekit) instead of cloudMQTT/Owntracks if it accomplishes the same thing. At the moment I am using a combo of homekit, cloudMQTT, and bluetooth for presence detection with varying success… and by varying, I mean barely.

Right, your HA instance needs to be eternally accessible by the iOS app in order to make real use of the gps. I am using a reverse proxy setup, but you could also do something like duckdns.

The HomeKit setup has been rock solid for me. And the iOS app has been working great as well.

1 Like

That sounds perfect, thank you. I have setup DuckDns and have it working, although I had to install Dnsmasq to access the instance locally.

I am interested in the reverse proxy idea though, would the “NGINX SSL proxy” add-on be the correct way to go about this?

edit: Through a bit of trial and error, its up and running wonderful. Using the dnsmasq on the phones that I want tracking enabled outside the home, other than that the proxy is great to still use my hassio local on computers not tied to the device_tracker. This thread has been a great help.

Can someone clarify how this is supposed to be set up for multiple people? I’m finding the wording to be a bit vague. I’ve followed the instructions for adding the settings in configuration.yaml, (I literally copy/pasted the OP settings because they fit my goals), and I’ve used the PIN to connect HA with the Home app on my phone. Now I have two input_booleans on my phone which is where the confusion comes in. Wouldn’t I need only one input_boolean on my phone?

Also, how do I add my wife’s phone into the mix? Are we supposed to share an Apple ID for this to work?

No sharing of AppleIDs (never ever do that, btw).

You invite your wife to your “home” in HomeKit then you both will see both input booleans (because they are just 'switches" to homekit).

Make two rules in homekit for each input_boolean: One that turns input_boolean 1 off when you leave and on when you arrive. Then one that turns input_boolean 2 off when your wife leaves and on when she arrives.

You can use either phone to make the rules (or the Home app on a Mac for that matter).

Just follow the directions in the first post starting at “Add other people to your home”

OK, I think I understand now. I create all of the automations in Home and by sharing my “Home” with my Wife, she too will have access to the automations.

Correct, but you need to invite her first or she won’t appear as a trigger option.

Thanks. I figured out the Invite prerequisite the hard way. :slight_smile:

I like the sound of this and will be looking to implement. But how do you protect from “Hey Siri, turn everything off”. Won’t that set my presence as away also?

I have no idea - I’ve never asked Siri (or Alexa) to “turn everything off” - I have scenes set up to do that. I would imagine if you have anything in HomeKit that’s not a light, “turn everything off” is probably not what you want (i.e., water valves, heat, garage doors, etc.)

My use case is I use HA to control everything and Alexa to control HA. I needed some more reliable presence than the iOS was giving me, so I came up with this method. Even though I have the HomeKit component active with most of my HA stuff exposed to it, I rarely ask Siri to do something.

I basically have two scenes: one is called “Bedtime” which has all of my lights and TVs off; the other is called “Away” which adds in the ceiling fans and thermostat to Away. The latter is activated automatically by HA when our phones are gone.

I am having a problem with homekit due to adding the filter to the homekit section.

What happened is that I lost all the switches/sensors that had been mapped to homekit, and only have the presence detector sensors defined above. Previously, my homekit section in configuration.yaml was empty.

What do I need to add to the filters section to bring all of them back? I have been searching home-assistant and google for examples, and have come up empty for a solution to adding back everything.

Thanks!

The filter section is completely optional, you can just delete those lines. It sounds like your configuration before was just the "homekit: " line, and that’s all you need - it will show everything by default.

Filter option is basically for restricting which things show up in the Home app. You can read more about how it works here.

Agreed, regarding it being optional, and I removed the information above for presence detection, and got all the sensors back.

However, I would like to find a solution where I can use the sensors for presence in addtion to all the other sensors/information.

Any ideas to have both choices? I really want to have the cake and eat it too!

What you did should have worked. Without the “filter” code in place, it should show everything including your input_boolean presence detection stuff too.

Perhaps you need to restart Home Assistant, or maybe the input_boolean presence detection switches got added to a different room (in the Apple Home app, check the “Rooms” tab and swipe through it - mine are in the “Default Room” which is not immediately visible unless you swipe).

If that doesn’t work, I’m not sure, maybe someone else can help.