[RELEASE] Combined Presence

community_app

#1

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

Combined Presence app for Hubitat

An app for Habitat to combine two or more presence sensors to control an output Virtual Presence Sensor. It uses a boolean-OR to combine them.

Use Case 1

I want to make an output sensor that will be more reliable than either of the input sensors alone. It uses a boolean-OR to combine them. This means it will work great if:

  • Your input sensors only give false negatives, but do not give false positives.

I can verify that presence from the Alexa app or HomeKit satisfies this. I can also verify that my iPhone WiFi Presence Sensor (GitHub - joelwetzel/Hubitat-iPhone-Presence-Sensor: A virtual presence sensor for Hubitat that checks if an iPhone is on the WiFi network.) satisfies this.

However, if your input sensors ever give false positives, then I do not recommend this app.

Use Case 2

If you have presence sensors for two people, you can use this 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.

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
  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. Go to the "Apps" page
  8. Click "+ Add User App"
  9. Choose "Combined Presence"
  10. Click "Done"
  11. Click on "Combined Presence" in your apps list
  12. Click on "Add a new combined presence"
  13. Choose your input presence sensors
  14. Choose your Virtual Presence sensor as the output
  15. Click "Done"

[RELEASE] iPhone WiFi Presence Sensor
[RELEASE] HTTP Presence Sensor
Will there ever be a solid presence option?
Use Locative for Presence
[RELEASE] iPhone WiFi Presence Sensor
Community Apps
Geo Fencing
[RELEASE] iPhone WiFi Presence Sensor
#2

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


#3

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%.


#4

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.


#5

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.


#6

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.

#7

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


#8

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


#9

@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


#10

Andy,

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


#11

+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!


#12

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

Thanks guys.


#13

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.)


#14

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.


#15

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:


#16

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.


#17

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


#18

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.


#19

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


#20

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.