Virtual Presence Question

This is the main Locative presence thread. This should help get you started...

1 Like

Thanks I'll check that out.

Geofency, which works basically the same way as described in the Locative thread, is another option. It’s a few bucks, unlike Locative, which is free, but Geofency is still supported. And I’ve actually found it to be a little better than Locative, which for some reason is usually good but sometimes drops arrival/departure events for me.

The specific person/s that created Locative has moved along, allowing anyone else to pick it up.

Under the heading of Hearsay: I have read that someone recompiled it and verified that the existing code still worked under the latest mobile OSs. I got the impression the writer would have attempted to fix any problems found.

And Oh By the Way... if you use iPhone, it supports multiple geofences, which I found out a week ago.

In Hubitat - can I make a virtual switch that is updated from ifttt and use that switch to change presence in hubitat?

i.e i use google wifi on off ifttt trigger to turn on switch in smartthings right now. WHich i have a webcore rule setup that sets presence to home away etc...

thank you

You can actually do two in one. With the following driver, turning the switch on makes it Present and Off makes it not-present.

/*
 * Virtual Presence with Switch and delay
 *
 * 
 *
 *   
 * 
 */

metadata {
    definition (name: "Virtual Presence with Switch + Dealy", namespace: "ryancasler", author: "Ryan Casler") {
        capability "Sensor"
        capability "Presence Sensor"
        capability "Switch"
		

    }   
}

preferences {
    section() {
        input name: "departDelay", type: "bool", title: "Enable Delay for Departed", defaultValue: false
		input name: "delayDeparted", type: "integer", title: "Number of mins for departed delay.", defaultValue: "0"
		input name: "arriveDelay", type: "bool", title: "Enable Delay for Arrival", defaultValue: false
		input name: "delayArrival", type: "number", title: "Number of minutes to delay arrival", defaultValue: "0"
	}
}

def arrived() {
	sendEvent(name: "presence", value: "present")
}

def departed() {
	sendEvent(name: "presence", value: "not present")
}

def on() {
	unschedule()
	sendEvent(name: "switch", value: "on")
	if (arriveDelay){
		def delay=(delayArrival.toInteger())*60
		runIn (delay, arrived)
	}
	else{
		sendEvent(name: "presence", value: "present")
	}
}

def off() {
	unschedule()
    sendEvent(name: "switch", value: "off")
	if (departDelay){
		def delay=(delayDeparted.toInteger())*60
		runIn (delay, departed)
	}
	else{
			sendEvent(name: "presence", value: "not present")
	}
}

def installed() {
}
2 Likes

awesome thank you - is that app code youve posted like a smartapp in smartthings?

No, a driver, like a DTH in smartthings.

awesome ok.

right now i'm using this guys lovely app that creates end points to update via a url command

It seems like i should be able to trigger this switch in a similar way via a curl command?

> /**
>  *  Camera Motion
>  *
>  *  Copyright 2015 Kristopher Kubicki
>  *
>  */
> definition(
> name: "HTTP Motion Endpoint",
> namespace: "KristopherKubicki",
> author: "kristopher@acm.org",
> description: "Creates an HTTP motion endpoint for your camera or other device",
> category: "Convenience",
> iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/intruder_motion-cam.png",
> iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/intruder_motion-cam@2x.png")
> 
> 
> preferences {
> page(name: "selectDevices", install: false, uninstall: true, nextPage: "viewURL") {
> 	section("Allow endpoint to control this thing...") {
> 			input "motions", "capability.motionSensor", title: "Which simulated motion sensor?"
> 			label title: "Assign a name", required: false
> 			mode title: "Set for specific mode(s)", required: false
>     }
> }
> page(name: "viewURL", title: "viewURL", install: true)
> }
> 
> def installed() {
> 	log.debug "Installed with settings: ${settings}"
> }
> 
> def updated() {
> 	log.debug "Updated with settings: ${settings}"
> 	unsubscribe()
> 
> }
> 
> 
> 
> mappings {
> 
> path("/active") {
>     action: [
>         GET: "activeMotion"
>     ]
> }
> path("/inactive") {
>     action: [
>         GET: "inactiveMotion"
>     ]
> }
> }
> 
> void activeMotion() {
> 	log.debug "Updated with settings: ${settings}"
> motions?.active()
> runIn(15,"inactiveMotion")
> }
> 
> void inactiveMotion() {
> 	log.debug "Updated with settings: ${settings}"
> motions?.inactive()
> }
> 
> 
> def generateURL() {
> 	
> 	createAccessToken()
> 	
> 	["https://graph.api.smartthings.com/api/smartapps/installations/${app.id}/active", "?access_token=${state.accessToken}"]
> }
> 
> 
> def viewURL() {
> 	dynamicPage(name: "viewURL", title: "HTTP Motion Endpoint", install:!resetOauth, nextPage: resetOauth ? "viewURL" : null) {
> 			section() {
>             generateURL() 
> 				paragraph "Activate: https://graph.api.smartthings.com/api/smartapps/installations/${app.id}/active?access_token=${state.accessToken}"
>             paragraph "Deactivate: https://graph.api.smartthings.com/api/smartapps/installations/${app.id}/inactive?access_token=${state.accessToken}"
> 
> 			}
> 	}
> }

That app won't work in Hubitat. It uses smarthings cloud links.

You can use this device along with the MakerAPI. That allows for control of any device via a web-link. There is more documentation on it here:
https://docs.hubitat.com/index.php?title=Maker_API

1 Like

all good just showing an example of what i use. will check the docs out thank you! EDIT: Seem pretty straight forward.

1 Like

Most welcome. Good luck!!

Thanks to Ryan's driver I don't need this ability right now but is there a way to change a virtual presence devices state using Rule Machine? I haven't been able to find a way yet.
Thanks.

If you use @ogiewon's Virtual Presence with Switch as the virtual presence driver, then it is is easy. You can control the switch in RM to change presence status.

1 Like

Yes, you can directly change the status of a virtual presence sensor in RM 4 using a "Custom Action" as shown below.

2 Likes

Thanks!

Since when did presenceSensor need for us to define the "arrived" and "departed" commands? Perhaps I've been living under a rug or was it a change in Hubitat recently that required it?

The Capability has never had commands.

Screen Shot 2022-06-05 at 7.54.21 AM

What in the world :flushed:. I'll go back under my rock.

1 Like

A purely Virtual Presence sensor does need a way for apps to change its state. This is why Hubitat has added the arrived() and departed() commands to its virtual presence driver.

1 Like