Page 1 of 1

Presence detection with homebridge-indigo and iOS

PostPosted: Wed Jan 18, 2017 4:40 pm
by justin_vt
I was looking for a way to do presence detection / geofencing with my iPhone and Indigo. HomeKit does a little of this itself, but its automation rules are pretty primitive compared to the power of Indigo. Here's one way you can do it - and so long as you're already using homebridge-indigo, you don't have to add any plugins, apps or additional software at all!

You'll need the following setup for this to work:

Indigo 6/7 (Pro)
Homebridge: https://github.com/nfarina/homebridge
Homebridge-indigo: https://github.com/webdeck/homebridge-indigo

We'll use Bob for this example.

- Create a variable "isBobHome".
- Create an action group "Bob Arrives Home". Configure it to set the isBobHome variable to true.
- Create an action group "Bob Departs Home". Configure it to set the isBobHome variable to false.
- Create a virtual device in Indigo (of type "Virtual On/Off Device") indicating Bob whether at home and call it "Bob at Home".
- Configure the virtual device to fire the "Bob Arrives Home" action group when turned on, and "Bob Departs Home" when turned off. Check the "Supports Status" checkbox and select the isBobHome variable.
- Expose the virtual device to homebridge-indigo in your homebridge config.json and restart homebridge.
- In the iOS home app, set up a trigger (under "Automation") to activate the virtual device when Bob arrives home, and deactivate when you Bob departs home.

That's it! You now have both a variable and device status in Indigo that indicates whether Bob is home or not. Since it's a variable, you can use it in all sorts of combinations to create more advanced rules (in my case, I'm using it to activate/deactivate my IP cameras depending on whether both my wife and I are home.)

JP

(For another way you could approach this without using the Home app, check out the Locative iOS app in the app store. It supports webhooks and could be used with homebridge-people-geofence.)

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Fri Jan 20, 2017 2:49 pm
by echiang
Thank you for outlining this technique. I have been playing around with using iBeacons for presence detection, but have been finding them unreliable. I've been miles from home before getting a notification that I've actually left home.

I've just started testing but using Homekit and your technique appears to be more reliable.

Ed

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Fri Jan 20, 2017 7:38 pm
by nev
Thanks for this idea! I have also been thinking of setting it up that way. The only thing that I wasn't sure about is working with multiple iPhones on that home kit home. If you create a switch for every location and every iPhone designated by the Name (Bob and lets say Lisa), then will the iOS action know that Lisa's iPhone should only trigger the Lisa switches and not the Bob switches and vice versa?

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Wed Jan 25, 2017 10:56 am
by justin_vt
As nev pointed out, there is a problem with multiple iPhones. HomeKit (aka the Home app) treats doesn't create automations on a per-device level, but rather on a per-Home level. Any device that is associated with the home shares the same automation, so if Lisa comes home, she activates the isBobHome switch just like if Bob comes home. (Note: for invited users to use the automations at all, they need the "Editing" permission in the Home app.)

The real question is whether homebridge is aware of any sort of device-id that we could pass along to Indigo (which should be achievable since you can set variables using Indigo's REST API.) I'm looking into this.

In the meantime, this technique is still working great for me as a solo user, but you can't have any invited guests with the "Editing" permission or things will get confused. (You can't disable automations on a per-device level, either, except by removing that permission - bollocks!)

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Wed Jan 25, 2017 6:11 pm
by justin_vt
Those interested in the multi-device issue can follow this issue here (HAP-NodeJS is the HomeKit library Homebridge uses.)

https://github.com/KhaosT/HAP-NodeJS/issues/393

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Wed Apr 26, 2017 7:56 am
by rbdubz3
This is a pretty cool technique.. I am thinking of trying out the fingscan plugin in conjunction with this technique in order to handle multiple users in a household.. Basically, let fingscan do the ping checks already for determining whether or not a device is on your network.. Then use this virtual device on/off for relaying the state to homekit. I haven't tried it yet though

One question that is more HomeKit/Homebridge specific but related to this topic - Is there a way to setup a particular device in homebridge/homekit to have 'Notifications' ? I have a Schlage lock and in HomeKit application it has a separate checkbox for 'Allow Notifications'. As a result any time the lock is opened/closed I get a nifty message on my iPhone.. It'd be great if this could be done with the devices from Homebridge.. Maybe I just need to set these to 'treatAsXXX' settings in the homebridge config.json

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Sat Sep 23, 2017 10:33 pm
by nwykes
ios11 seems to fix a couple things here. You can now setup the automation triggers in the home app for individual iPhones. I was also able to do this without the virtual device. Exposing the actions to Homebridge and using them as the accessory in the Home app did the trick.

Re: Presence detection with homebridge-indigo and iOS

PostPosted: Fri Oct 13, 2017 9:06 am
by virgahyatt
nwykes wrote:
ios11 seems to fix a couple things here. You can now setup the automation triggers in the home app for individual iPhones. I was also able to do this without the virtual device. Exposing the actions to Homebridge and using them as the accessory in the Home app did the trick.


iOS 11 does offer a lot more options to trigger the automations. However, currently the default home location that you have to use if you want it to trigger when "Anyone" arrives home doesn't have an adjustable geofence, and whatever is being used as the radius value is way too small. I have already contacted Apple about it and they are investigating.