[RELEASE] Combined Presence

https://github.com/joelwetzel/Hubitat-Combined-Presence

Combined Presence app for Hubitat

An app for Hubitat to combine two or more presence sensors to control an output Virtual Presence Sensor.

There are 3 types of combiners:

  • Standard Combiners (Use this for combining wifi and gps-based sensors for a single person. It is optimized for that.)
  • Boolean-OR Combiners (Example: If Person1 OR Person2 is home, then the virtual SomeoneIsHome sensor should be home.)
  • Advanced Combiners (All logic options. It is a superset of what the Standard and Boolean-OR combiners can do, and you can re-create their functionality or do other boolean operations by configuring it correctly. But almost no one will need this.)

Use Case 1

You have several geofencing sensors on your phone (Alexa, Homekit, Life360, etc) and you also use a sensor that detects when your phone is on WiFi. You can use the Standard Combiner for optimal logic of deciding whether you are home or away.

Use Case 2

If you have presence sensors for two people, you can use a Boolean-OR Combiner to set a third Virtual Presence sensor for "Somebody is home", then use the departed event from it in Rule Machine to trigger events for when the last person has left the house.

Use Case 3

I have documented the advanced bindings here: ([RELEASE] Combined Presence - #35 by jwetzel1492)

Daisychaining

This app is entirely virtual and on the Hubitat hub, so it runs very fast. This means you can daisychain multiple combinations.

An example with 3 combiners:

  • "My iPhone Alexa" + "My iPhone WiFi" --> "My combined, reliable presence"
  • "My wife's iPhone Alexa" + "My wife's iPhone Wifi" --> "My wife's combined, reliable presence"
  • "My combined presence" + "My wife's combined presence" --> "Somebody is home"

Now I can make RM rules based on individual people arriving. And if I want a rule for when the last person leaves the house, I just trigger on "Somebody is home" changing to "not present".

It's nice because it keeps the combination logic outside of Rule Machine.

Installation

Prerequisites:

  • Input sensors already exist
  • You've added a Virtual Presence sensor to be the output

The best way to install this code is by using Hubitat Package Manager.

However, if you must install manually:

  1. On your Hubitat hub, go to the "Apps Code" page
  2. Click "+ New App"
  3. Paste in the contents of combinedPresence.groovy and click "Save"
  4. Go back to the "Apps Code" page
  5. Click "+ New App"
  6. Paste in the contents of combinedPresenceInstance.groovy and click "Save"
  7. Click "+ New App"
  8. Paste in the contents of advancedCombinedPresenceInstance.groovy and click "Save"
  9. Click "+ New App"
  10. Paste in the contents of standardCombinedPresenceInstance.groovy and click "Save"
  11. Go to the "Apps" page
  12. Click "+ Add User App"
  13. Choose "Combined Presence"
  14. Click "Done"
  15. Click on "Combined Presence" in your apps list
  16. Click on "Add a new standard combiner"
  17. Choose your input presence sensors
  18. Choose your Virtual Presence sensor as the output
  19. Click "Done"
12 Likes

Isn't that what Cobra's Presence Central already does? Or am I missing a nuance here?

Cobra's Presence Central is awesome. This is like a "Lite" version, stripped down for my most common use case of "My presence sensor is only 90% reliable when I drive up to my house. How can I make it respond faster?"

That's what I found with any kind of geofencing presence on my iPhone. On arrival, it would trigger quickly 90% of the time. But 10% of the time, I'd be awkwardly waiting and it would take up to a minute to trigger. By using Combined Presence along with my https://community.hubitat.com/t/release-iphone-wifi-presence-sensor/9075/47 sensor, I can fill in that last 10%.

3 Likes

Actually Cobra's app doesn't do any of this. @jwetzel1492 solution enables you to filter multiple presence sensors logic into a single output presence sensor. BIG difference which now could be used with any app.

Ummm... Presence Central can do that too.

In fact, that's exactly how I use it. Group 2 presence logic with multiple sensors, action is driving a virtual switch I use as an aggregate presence sensor...

But I do see that if you were going to cascade a bunch of presence outputs into other presence filtering logic to make a final presence output, that this may take fewer virtual sensors than Cobra's.

Cool app, regardless.

1 Like

Definitely multiple ways to accomplish varying goals.

Other than Presence Central having a lot more options than this, the other big difference is that:

  • Presence Central: Presence sensors are the inputs. Actions are the outputs.
  • Combined Presence: Presence sensors are the inputs. Another presence sensor is the output. It leaves it to Rule Machine (or other apps) to handle further logic and actions.
2 Likes

Ok... But if the Action drives a virtual presence sensor, that is the same as the output being a presence sensor...

1 Like

This is also a lot easier to understand which helps me and my little brain cell. :wink:

6 Likes

@aaron
This was why I created PC in the first place.
I just added additional ‘actions’ as the output as people asked for additional features.

I have multiple presence sensors ‘combined’ into one (using my virtual presence plus driver which is a presence sensor and switch combined.)

It’s always a user choice, use my apps/drivers or not.
I don’t force anyone to use anything :slight_smile:

Andy

2 Likes

Andy,

I am a huge fan of your programming. I extensively use your driver and apps.

+1 recommend @cobra's Virtual Presence Plus driver. It fills a cool use case: Alexa doesn't know what to do with presence sensors, but it does know what to do with switches. So make a VPP sensor and expose it to Alexa. Then use Alexa routines to do geofencing on that sensor. Converts Alexa geofencing into Hubitat presence in one step!

1 Like

It's great to have TWO such competent solutions that are really providing accurate presence sensing.

Thanks guys.

3 Likes

Let me show my work on why I settled on a simple Boolean-OR for combining inputs.

Any "boolean-like" sensor is going to have a false positive rate, a false negative rate, and characteristic times to detect changes between true/false.

In terms of our presence sensors, we have two steady states to consider: Staying away for a long time, and staying at home for a long time.

And we have two transitions to consider: Arriving, and departing, and how long it takes the sensor to detect that transition.

I characterized my geofencing (through the Alexa app and the SmartThings app) experience, and also characterized WiFi detection of my phone. Here are my results:

Next, I had to decide what events I wanted to trigger on. This will vary for everyone. For my personal case, it's important that Steady Away be accurate, and I'd like good detection of arrivals. I don't care as much about detecting departures. So I started looking at different ways to combine the multiple sensors. The two easiest would be with a Boolean-OR, or a Boolean-AND.

Bingo! If I want accuracy for Steady Away, and guaranteed detection of arrivals, then I need to use a Boolean-OR. The downside is that departures are only detected as fast as the slowest sensor.

However, if I was only interested in triggering on departures and didn't care about arrivals, I might make different choices - both in terms of sensors, and how to combine them. The WiFi has too many false negatives during Steady at Home, so I might switch it out for a SmartThings presence fob instead.

Maybe one day we'll get a sensor that's so fast and accurate that it'll "just work" for everyone. Fingers crossed!

(Edit: If I wanted faster detection of departures, I could trigger off of the departed event on JUST the geofencing sensor. It doesn't throw false negatives, so it should be fine. Basically, use the combined sensor to detect arrivals, but only the geofencing sensor to detect departures. Of course, this is more complication. So it's a tradeoff that YMMV.)

2 Likes

That is what I did. I use your combined presence with my Life360 and your WiFi presence to detect arrivals and I have a RM rule to set the combined presence to 'departed' based on a Life360 departure. Seems to work very well so far.

Thanks.

2 Likes

Another +1 for VPP!, and for the Alexa geo-fencing idea. I set that up last night, along with this: [RELEASE] iPhone WiFi Presence Sensor. I haven't tested it yet, but I'm hoping that between the two of them (and the ability to easily merge those sensors with Combined Presence), Hubitat will accurately know when nobody is home except the dog. :slight_smile:

I took out my RM rule to set the Combined Presence as 'departed' when the phone departs as I realized it already did that when both the input sensors are 'departed'. I am putting in a delay after the output sensor is set to 'departed' of one minute because I am getting that my phone left, so the combined sensor is changed to departed and I get a Pushover message, but the WiFi re-connects before it is actually out of range so the combined sensor changes back to 'arrived' and I get another Pushover message until the WiFi finally disconnects and the combined sensor changes to departed again (and I get another Pushover message).

I think I am getting this because at least one of our phones WiFi changes from ONLINE to OFFLINE very frequently and it almost always seems to happen after the combined presence is changed to 'departed' and then the phone WiFi goes to ONLINE before it is far enough ways to drop back to OFFLINE.

Oh that’s interesting. That almost sounds like your WiFi’s range is larger than your geofencing radius?

Several factor for this may be: 1) We have almost no 4G LTE signal at our house, so I have a 4G LTE network extender that then connects to our internet to connect to the carrier (Verizon). 2) We cannot isolate our network extender to just our phones so the neighbors can use it too and there are a limited number of connection available, so I have lowered the power on the network extender so we still have good coverage in the house, but not much farther.

I believe what is happening is that we get outside the network extender range and that connection drops, so Life360 is notified that we are 'departed', however our WiFi is still connected for a short time. If one of our phones switches from OFFLINE to ONLINE in that window of time we get the 'arrival', then when the WiFi finally really disconnects because we are out of range we get another 'departed'.

I am NOT a network engineer (not even close) so this is all just a guess.

What is your Geofence preference established for Home in L360? You may need to just increase it by 50 ft.

I have not tried that ... but I don't think it will help. Here is why I think that ...

We are in a 4G LTE dead zone around our house. I believe what triggers the Life360 'departed' is leaving our small Network Extender coverage area. Once we leave the Network Extender area, there is a dead zone until we get close to the nearest 4G LTE tower. Even if I extend the range in Life360, the phone app GPS will detect it, but since there is no 4G LTE signal there is no way for the app to communicate that to the Life360 servers and then to Hubitat, so Hubitat still thinks I have departed even though the Phone App may say otherwise. As you suggested I could boost the power of our 4G LTE Network Extender to broaden the range .... but that has the downside impact of providing coverage for our neighbors and potentially blocking our connection because there are a limited number of connections available in the Network Extender. If the neighbors are using the Network Extender, we may not be able to.

Again, not a network engineer and just guessing at this.