Using iPhone as a presence sensor

Correct on both accounts. As suggested if HomeKit Arrival flips a linked virtual switch that talks to Hubitat you can have the switch state trigger lock/unlock on the Hubitat side but that could still be problematic from a security perspective.

Out of boredom Iā€™m trying to see if I can mitigate some of the potential security issues by finding the right combination of authentication factors I feel safe to initiate an auto-unlock.

To be safe, right now none of my rules actually involve my door lock at all, just have hubitat sending me different text messages based on events so I can determine how fast, how reliable, and how precise different variables are for a few weeks. If it doesnā€™t work then no biggie but if I can find a good combination I am not opposed to taking it live during specific hours of the day.

A few examples of things Iā€™m tracking include:

When iOS determines I have arrived home a virtual switch is turned on in hubitat which sends a text to my phone saying ā€œPresence Arrivalā€, and an additional virtual switch turns on in Hubitat for 3 minutes before turning itself off.

When iOS determines I have left home the original virtual switch is turned off in hubitat which sends a text to my phone saying ā€œPresence Departureā€.

When my Nest Hello doorbell recognizes my face, it turns on a child presence sensor for just me which I use as a trigger for a fourth virtual switch telling Hubitat to send the text ā€œYour Face Recognizedā€.

When my iPhone is connected/disconnected to my home wifi, yet another virtual switch is toggled and Hubitat texts ā€œconnected to homeā€ or ā€œdisconnected from homeā€

When the face switch is activated by my Nest doorbell recognizing me, a rule looks to see if the 3-min arrival switch is also active, then it looks to see if the Wifi connection switch is Also active. If all three items are true then Hubitat texts me ā€œAuto Unlockā€.

Anyway thatā€™s only a couple of the things Iā€™ve been monitoring/tweaking the last two weeks.

Assuming I find a good combination 4-5 of fast and reliable factors Iā€™ll monitor the ā€œAuto Unlockā€ texts for an additional 2-3 weeks straight with no changes and if the results are solid Iā€™ll open a few small windows of time during the day that actually triggers a real unlock.

Might require a few iterations before I feel comfortable turning it on officially but we are pretty serious about our social distancing at my house so Iā€™m in no rush as Iā€™ve got nothing better right now. Haha.

Wasted some time this afternoon starting the conversion of all these virtual switches over to hubitat-generated local endpoints instead. Was able to get state changes of devices in Apple Home to trigger the local endpoint on my network through custom iOS personal shortcuts/automations.

Even though the url is not exposed externally I was able to set it up in a way that even if Iā€™m not connected to my network, the endpoint call gets sent from one of my HomeHubs (Apple TV, HomePod) that are on my network so it works regardless of my location.

Probably wonā€™t keep that active if I ever get to real door unlocks but makes my life a lot simpler in my text message testing and eliminates a bunch of other virtual switches I was using to communicate between Hubitat and Homebridge.

I've been doing this for over a year now and haven't had any issues. The automation I'm using is only enabled between 8 am and 10 pm.

1 Like

First off itā€™s super small on my phone but, love the vette icon photo. I assume itā€™s yours? what year is that? Feel like itā€™s 76-78ish? Ive owned my C3 for ~20 years now. Sometimes it feels like itā€™s nothing but problems but I love it nonetheless.

Anyway, back to the original topic...

Do you mind sharing what you are using (or have tried using) between 8-10 to trigger your auto-unlocks? Be curious to hear what youā€™ve found works best for your situation as Iā€™m figuring out how to do it myself.

It's a 73 Vette and it has been parked for a long time.

I have a virtual switch setup in Hubitat that triggers a rule to unlock the door. The virtual switch is triggered by an automation setup in HomeKit.

I have this setup for both mine and my wife's phone and it works great. As an added safeguard I have another rule setup to auto lock the door after it has been unlocked for 10 minutes.

Yea, that makes sense.

I donā€™t know if you want to mess with what is already working but yesterday I learned we can eliminate the need for virtual switches to do this.

Technically, as long as someone had a homehub (Apple TV, Homepod, iPad) this should work without Homebridge either...

If you use rule machine and set your trigger to be ā€œlocal endpointā€ instead of a virtual switch and then setup the actions as normal, you can take the local endpoint url hubitat generates for the trigger and use it in an Apple Home Automation.

Iā€™ll post some screenshots below but basically when iOS detects Iā€™ve arrived home, it hits the url on my local network behind the scenes that tell hubitat to trigger the actions in the hubitat rule tied to that end point trigger.

Best part is, even though itā€™s a local url that canā€™t be accessed off my network, even if Iā€™m not home when the automation runs, my home hub (on network) is the one triggering the action so it works without creating a cloud endpoint that can be accessed externally by anyone/everyone.

Anyway, now I can finally get rid of the dedicated ā€œfake switchesā€ room I have in my Apple Home App thatā€™s filled with a bunch of toggles my wife or son could accidentally click and mess up.

Today Iā€™m trying to figure out how to pass a variable in the url to see if I can minimize the number of HomeKit automations I have to maintain.

1 Like

Thanks for the tip! This shortcut functionality wasn't available when I first set this up.

This is something I donā€™t think Iā€™ve seen before... How do you get to the screens you show in the scheenshot?

This may help:

The video above probably has the right info but just to be safe Iā€™ll list out the instructions as best I can below.

Thinking if I have time later tonight Iā€™ll collect some screenshots and post a more detailed walk-thru in a new thread.

Anyway, let me know if this works for you:

  1. Open Apple Home App
  2. Click the ā€œAutomationā€ tab in the bottom nav.
  3. Hit the ā€œ+ā€ icon in the top right of the Automations screen
  4. Setup the trigger event settings
  5. After, when it asks to select a scene or accessory to automate, youā€™ll want to scroll all the way to the very bottom of the list and you should see a section called ā€œAdvancedā€ with a link for ā€œConvert to Shortcutā€
  6. Once youā€™re in the shortcut flow you can delete the empty accessory placeholder sitting at the top by pressing the ā€œxā€ icon in the top right of that module. (Unless you want to ALSO control an accessory in this flow, then you can keep it).
  7. Hit the ā€œ+ā€ icon and search for ā€œurlā€
  8. The first result in the list will literally be called ā€œurlā€
  9. Paste the local (or cloud) endpoint here.
  10. Click the ā€œiconā€ and search for ā€œurlā€ again. This time you are looking for a green icon with a white arrow named ā€œGet contents of URLā€
  11. Change the field ā€œMethodā€ from the default value of ā€œGetā€ to ā€œPostā€
  12. Hit the drop down for ā€œHeadersā€ and ā€œadd a new headerā€
  13. In the ā€œKeyā€ field typeā€Content-Typeā€
  14. In the ā€œTextā€ field type ā€œapplication-jsonā€
  15. You can leave the ā€œRequest Bodyā€ section empty for now, just hit ā€œNextā€ on the top right to advance.
  16. You should see a summary of your automation. The trigger will populate but the shortcut might look empty. Thatā€™s ok.
  17. Hit done in the top right corner and thatā€™s it.

Or try the ā€œTest this automationā€ link at the bottom to validate if itā€™s working.

When I initially created my local endpoint trigger in Hubitatā€™s Rule Machine I set the action to just turn on my office lamp as a test then swapped it out after with other things once I made sure it was working.

2 Likes

Thank you so much for this! Your explanation is perfect. Tried it out and it worked. :grinning:

For fire safety you might want to add a trigger to unlock all doors when smoke alarm activates. Since you have it set to auto lock after 10 minutes.

1 Like

Too bad there is no integration with Nestā€™s smoke detectors (as far as I know)... It would be useful for this also.

I have a rule setup that unlocks all of my doors and disables the auto lock rule if any of my smoke alarms are triggered.

1 Like

Nest protect can be integrated via HomeBridge.

Thanks! I think it requires a Pi though... I donā€™t have one, but maybe I should see if my son would want to set this up on his...

HomeBridge can also be setup on an always on Mac or Windows machine as well.

Well, I do have one of those (Windows machine)... Maybe something to look into! :smile:

Never messed with this before but you could always try recording a false alarm in iOS and then using that as a trigger for an unlock event.

1 Like

How do you do this without homebridge? Using a cloud endpoint from the video above or something else? Any advantages/disadvantages of one approach over the other?

Also, I only see options to let the Home app use my location while using the app. It doesn't give me the option to let Home use my location always. Makes me nervous that it won't do a good job, but I assume this is the case for everyone?

Man...this is a great topic...I'm a beginner and this looks like something I could spend a lot of time making mistakes on and getting frustrated...

Cant wait to give it a shot!

1 Like