[RELEASE] Combined Presence

Hi @jwetzel1492,
I am confused with the above statement.
I created 1 virtual sensor as output by going to Add Virtual device and selecting Virtual presence as device type. I installed the Combined presence sensor app as instructed on the hub.

When I go to click Add a new combined presence sensor, I see
-my wife's iphone and my phone that use the 'iphone Wifi Presence Sensor' app and
-Oneplus 7 pro as a presence sensor (I believe this is created by Hubitat itself).

I dont see alexa as presence sensor. Moreover,do I create 3 virtual sensors? From the below screenshot, how do I create the setup you have provided in your example?

I really like the implementation of this combined presence app. @jwetzel1492 would there be any chance to add the option for a number of devices threshold to the app? I have three different ways to detect my presence but I would like the option to choose how many of them to have depart or arrive before it chances the virtual device instead of the current all or nothing system. This only be especially nice for departure tracking where only a few of the detection devices show that I have left. Thank you for your consideration.

Hi @breindl2005! That would be a major change to how the logic works. However, your case is exactly why I put in the advanced combined presence option. Have you tried that yet?

If not, try using the advanced option, and set it up like this:

In my case, my Alexa and Homekit presence sensor sometimes get stuck. Not both at the same time, but sometimes Alexa doesn't update for a day or two, but Homekit still will. And my Wifi sensor is very accurate for arrivals, but not for departures. (Because iPhones put their wifi to sleep.)

With this configuration, Advanced Combined Presence never ever misses an arrival or departure.

1 Like

I will certainly give this a try and see if it works for my situation. Thank you.

Hi @jwetzel1492,

Any advice for my query?

Getting presence from Alexa is a separate topic from combining presence, but here's the basics:

  • We need a virtual presence sensor for "Alexa Presence". But the Hubitat-Alexa integration doesn't integrate presence sensors, only switches. So I created my own driver that implements both PresenseSensor and Switch, and exposes it as a switch to Alexa. You can download it here: Hubitat-Miscellaneous-Drivers/EnhancedVirtualPresenceSensor.groovy at master · joelwetzel/Hubitat-Miscellaneous-Drivers · GitHub
  • So create one of those virtual presence/switch sensors and name it something like "Shivu - Alexa Presence" .
  • In the Amazon Echo Skill app on Hubitat, add your new virtual sensor to the list that is integrated with Alexa.
  • In the Alexa app on your phone, you need to add two routines:
    • When your phone arrives at home, turn the virtual switch on
    • When your phone leaves home, turn the virtual switch off

That's it. Now when you arrive and leave, the Alexa app on your phone should cause that virtual presence sensor to change state.

(And if you have HomeBridge set up to integrate with Apple HomeKit, the steps for integrating HomeKit presence into Hubitat are essentially identical.)

4 Likes

Thanks so much for the detailed explanation @jwetzel1492!
Much appreciated!

I had no clue on the Alexa setup till now.
Hopefully it should help someone else as well.

1 Like

Mind going into more details on how this works and what your hack is?

Here's the link on Reddit:

1 Like

Hi @neonturbo, does your 3rd rule work well? Shouldnt it be 'All of these not present' instead of 'Any of these depart'?

It has been like a year, I can't remember why I chose that. I haven't looked at it basically since I set it up. Maybe I need to revisit! Too many cocktails when I was setting it up? LOL

:woozy_face: :tropical_drink:

I think you are correct, it probably should be all rather than either. jwetzel1492's post (post 35?) right after mine, shows a graphic of the logic much better than I explained it.

I will dig into my rule a bit and see if I can remember why I did it that way...

I am using HE on a Samsung Galaxy S10e and now trying to turn off the Enable GeoFence switch.
But I cant seem to...am I missing something?

One thing I've noticed after using this for a while: While the advanced setup is what I use to solve all my presence combining, the way I configure the advanced combiners is always identical. I'm tempted to make a "Best Practices" combiner that has the same underlying logic as the advanced one, but has a simplified UI that guides the user into using it the way I think works best. I need some free time though. :slight_smile:

3 Likes

That would be great.. looking forward to it!

IMPORTANT UPDATE: This package can now be installed from Hubitat Package Manager. This is the best way to make sure you keep up-to-date with bug fixes and new features.

4 Likes

I only just started using combined presence and your iPhone WiFi Presence Sensor driver. I combined phone location and wifi presence into a virtual presence sensor; one for me and one for my wife.

I noticed that in the log, if just one of the two combined sensors changed to departed, the log will say it arrived. Then when they both change to departed, the log says departed. But the first arrival only shows in the log, it doesn't show in the device events.

image

The arrived here is when I first setup the virtual device.

Just started using it though, so I'm not sure if that will actually impact anything. I imagine it won't if there's no event happening for the false arrival, but it was a little confusing when I was looking through the log.

1 Like

Hi @waterboysh, yes it doesn't show in the events because the state didn't actually change. Are you using the normal Combined Presence or the Advanced Combined Presence?

Normal combined presence. Here's some more info. This is the log for the combined presence sensor. The first arrival is when her phone connected to the wifi the second is from the hubitat geofence.

image

Here are the events for the combined presence sensor.

I'm not really familiar with the coding environment in HE, but it looks like the code responsible for writing in the log is this

def oldPresent = outputSensor.currentValue("presence")
	
	if (present) {
		outputSensor.arrived()
		
		if (oldPresent != "present") {
			log "${outputSensor.displayName}.arrived()"
			
			if (notifyAboutStateChanges) {
				sendNotification("Arrived: ${outputSensor.displayName}")
			}
		}
	}

I don't really know what calling the arrived function on the sensor does. I assume this function is built into HE for type presence sensor. I don't see any issues with the code, so I am also assuming this is where the extra line in the log is coming from, because oldPresent should be true and the rest of this code skipped. Any reason to not change it to

if (present && !oldPresent)

and then get rid of the second if statement?

Ok, the basic one is good if you want to combine two truly reliable sensors. I ONLY use it to do booleans of entire people. So for example, I'll do a basic combiner on both my sensor and my wife's sensor to answer the question "is anyone at all at home?". For presence of the people themselves, I recommend using the advanced version, and here's how it should be set up:

Every sensor goes into "ANY of these arrive". Everything EXCEPT wifi-based sensors goes into "ANY of these depart". (Because wifi disconnecting is not indicative of actually leaving the house.)

My dashboard shows how I use two advanced and one basic combiner:

2 Likes

IMPORTANT: I have just release V2.0 of Combined Presence. I've updated the description at the top of this thread. The best way to get the update is to install via Hubitat Package Manager, but you can also install directly from GitHub.

It should be fully backwards compatible and not break any existing combiner instances.

The most important update is the new "Standard Combiner". This instance has the optimal logic for detecting presence of a person using multiple geofencing and wifi-based presence sensors. You don't have to think about the boolean operations involved. It just does it the best way based on the performance characteristics of the different sensor types.

1 Like