Presence Governor

Also, if you are trying to get the device type after the fact, you can try the following (it worked for me in ST but haven't tried in HE):

Assuming your input is called "myMobile"
def state.typeOfDevice = myMobile.typeName

1 Like

Not exactly no. I'm really hoping to achieve this with the same input as all other virtual presence devices.
What I REALLY need is the ability to get the type from a device, is that what you're recommending here?

def state.typeOfDevice = myMobile.typeName

That's what you appear to be saying, so I'm going to try it. That would be far less hacky than what I've implemented.

Yup, that was the ticket. Thanks @stephack!
Get the latest 1.2.3 version, and it solves the exception @mluck reported, when using the HE Mobile App for Geofencing.

3 Likes

Just re-imported (assuming it's only the child that changed). Will test.
Thanks to @doug and @stephack

1 Like

Bad news, @Doug. When I tested, my proxy sensor changes to "not present" on threshold geo-departure, regardless of whether the wifi presence sensor shows as present. As I understand it, a "present" wifi sensor should override departed geo presence sensors. Thoughts? I'm happy to continue being the guinea pig :grin: cuz I love what you're trying to do.

Thanks for the feedback. Try the latest 1.2.4

1 Like

It works, woohoo! Thanks.

2 Likes

@doug

Have to say I’m loving this app!

I’m using Life360 and webCoRE presence via ST to achieve a solid presence. I currently receive 3 notifications (for each method) when me or the Mrs leaves, whilst testing. It’s not failed as yet and in most cases I get the governor message first which is great!!

Many thanks for a great app :+1:
I’ll be disabling the other two messages now :wink:

1 Like

@Doug I'm getting some unintended behavior. My geo sensors are both firing "away" so darn quickly that the wifi sensor is still connected. Ergo, there's never any departure. Oops.

I could expand the geofence, which'd be a simple solution, but I'd like to avoid doing that for other reasons. I noticed your app has a Departure Delay parameter. How does that behave?

@mluck The departure delay happens after the Governor determines you're away. So that wouldn't help this situation since it doesn't consider you away with the WiFi driver still reporting present.

I've added the threshold check back in, when the WiFi goes offline. Now that I'm forcing all the geo sensors present when the WiFi is online, I think it'll be safe. Unless of course all you're using is the HE Mobile App (Since I can't force it present with missed events)

Pull the version I just pushed and test it for me, please.

FWIW, "HubConnect Presence Sensors" also cannot be forced present (they have no arrived() command).

Might be better to verify that the target device has the desired command before trying to force it:

def wifiPresenceChangedHandler(evt) {
	sendEvent(name:"Presence Changed", value: "$evt.device - $evt.value", displayed:false, isStateChange: false)
	switch(evt.value){
		case "not present":
			ifDebug("WiFi Offline")
			if(departureCheck()){
				departed()	
			}
			break
		case "present":
			ifDebug("WiFi Online, skip threshold check, mark all other device arrived")
			/* 	WiFi sensor present is the ultimate truth 			*/
			inputSensors.each{
			 	if (it.typeName == "Mobile App Device"){
					ifDebug("HE Mobile App, skipping forced arrival on ${it.name}")
				} else if (!it.hasCommand('arrived')) {
					ifDebug("${it.name} doesn't support forced arrival, skipping (${it.typeName})")
				} else {
					ifDebug("Forced arrival on ${it.name} (${it.typeName})")
					it.arrived()
				}
			}
			arrived()
	}
}

Excellent! hasCommand has been implemented, that's much better. Thanks for the advice.

@doug, Overall I really like this and it's nice and easy/clear to configure, so thanks! :slightly_smiling_face:. But I am curious how you use this with the WiFi presence combined with other presence sensors. For me, WiFi takes longer to detect departure but also seems to indicate not present incorrectly due to the phone sleeping. So if I use a departure threshold of 2 things work but are slow to mark me as away compared to using a threshold of 1 but just ignoring departure of the WiFi... I'm assuming you're using 2 (or more) and just letting the WiFi take longer? If so, how would you feel about a toggle allowing the app to ignore WiFi for not present?

I use two geofences with a threshold of 2 for departure and 1 for arrival.
I have a ST presence sensor fob and the WiFi driver, in addition.

You're correct, by design the iPhone sleeps the WiFi, so when the WiFi goes offline, the Governor will check your threshold selection when that occurs which prevents the WiFi setting not present by itself. I haven't noticed a big delay in WiFi detection. However, for me, the idea behind the Governor was largely to prevent false not presents more than anything. I probably tolerate the delay to the away routines for that reason. I am down the street a bit when it kicks in. Arrival is instant as it should be.

The WiFi sensor is not required. Perhaps your use case would be better eliminating it?

Got it, thanks for for outlining your usage. I'll try it a bit with departure = 2 and wifi and see how things go. Thanks for the app!

This looks really promising and I've been able to install and configure it (I think). I want to set up simple rule that says, "When I get home, turn on the living room lights". However, I find that the iOS app keeps sending exit and enter messages. This ends up turning the lights on and off while I'm home. I'm hoping Presence Governor makes it more reliable for me. It looks like Presence Governor is doing its thing but the rule to turn on the lights isn't respecting the proxy. Any suggestions?

I have Presence Governor configured as [isDebug:true, departuredelay:0, inputSensors:[myIPhone6s, myiPhone WiFi Sensor], outputSensor:myIPhone6s, arrivalthreshold:2, threshold:1]

dev:34 2019-11-15 02:02:21.595 pm info Living Room was turned on [digital]
app:93 2019-11-15 02:02:21.180 pm info Action: On: Living Room
app:93 2019-11-15 02:02:21.151 pm info Turn on test Triggered
app:93 2019-11-15 02:02:21.124 pm info Turn on test: myIPhone6s presence present
app:92 2019-11-15 02:02:21.085 pm debug Presence Governor for myIPhone6s: Threshold not met
app:92 2019-11-15 02:02:21.078 pm debug Presence Governor for myIPhone6s: 1 sensors present
app:92 2019-11-15 02:02:21.047 pm debug Presence Governor for myIPhone6s: null present
app:92 2019-11-15 02:02:21.029 pm debug Presence Governor for myIPhone6s: Arrival Check

The output sensor should be a virtual presence sensor. At least mine is. And, usually it would make more sense to make the Departure threshold higher than the arrival threshold.

Edit: If it helps, here's my setup:

1 Like

Awesome, thank you. I was missing the virtual presence device.

1 Like

@doug. Going to give this app a try. What is the Proxy? Do I need to first setup a virtual device for the proxy?

Not @doug, but the Proxy is in fact a virtual presence sensor as you have surmised. And you will use the Proxy as the presence sensor that monitors records Home/Away status.

1 Like