Triggering presence events

Does anyone know of a way to trigger presence? I’ve had times where is says someone is home but they aren’t or vice versa & I would like to manually override that.

Plus I have some ideas on using Tiles or BT + Raspberry Pi’s etc for presence detection.

1 Like

Ok, so I tried a few little hacks that I thought might work but they didn’t. I tried calling a sendEvent on a presence devices with the value not present. To see if I could get it to toggle:

presence.each { sendEvent(it, [name: "presence", value: "not present"]); };

But that seems to do nothing… I’d really love to be able to trigger these events, anyone have a clue?

1 Like

I think you’ll need to use a Simulated Presence Sensor to do that instead of a real device. This is one of the device types that you can select in “My Devices”. You could then write a SmartApp to tie the simulated device to the real device.

1 Like

I don’t see any docs on the Simulated Presence Sensor, nor does it show up when creating a New Device. I’m not overly-thrilled with having to create a custom device for this. I just want to “correct” where ST is wrong. Currently my son is at school, he’s been there all day. However, while my wife and I were out shopping today the house unlocked itself because it said that he arrived. It still says that a few hours later, even tho he is not here. I’m not sure how setting up a virtual one will actually solve this problem.

I see it when I go to “My Devices” then “New Device”. It is one of the options under “Type”. Once you have a simulated sensor, you can set it to present or not present in the SmartThings app (just tap it) or from a SmartApp. So you can write a SmartApp to set the presence based on the real sensor, but when its wrong, you can change it manually.

3 Likes

Ok, I see it under “My Devices”. I was looking at “My Device Types” so I could see what it does/supports/etc. I’ll have to play with it, seems like a lot of hoops to jump just to correct their mistakes…

More optimistic way to look at it: At least SmartThings provides the hoops and let’s you jump through them (and the Community here is good at demonstrating great ways to jump…).

SmartThings could reasonably argue that your desired functionality of the Smart Presence is not due to a “mistake” … it is a missing feature. It was explicitly engineered that way. “Things” that are directly mappable to a Physical Device should not lie about their status. Thus, the concept of “Virtual Devices”, for which status, etc., is completely subject to the programmer’s definition.

That I understand, but the reverse is also true. I can tell a switch to be on or off. The presence device should also allow me to toggle that state as well to correct it.

Don’t get me wrong, I love the hackability of the system. In fact I’m working on a very detailed blog post for them :smile:

When you “tell a (physical) switch to be on or off”, you actually make the switch change it’s “physical” state (i.e., the light turns on or off as requested – well, most of the time, cross-fingers).

If you were to be able to command a real-life physical Presence Sensor to be “present or not-present”, then you will have to invent teleportation first.

i.e., As I said earlier … lying about the State of real-life physical devices is not an appropriate paradigm, as it runs into all sorts of paradoxes.

2 Likes

I’m not disagreeing with you, but it’s also not “lying”. I see it as “correcting the invalid state of the device”. There is no way for me to forcibly say “That last event was wrong, it needs to be updated”.

Maybe it’s more like a “refresh” command. I know the state is wrong, but ST needs to “re-evaluate how it determined that” and try to reset the state to the actual state of it.

Again, this stems from the very poor presence detection that is all over this forum. But this little glitch actually unlocked my home when no one was home. Luckily I have push notifications enabled for this event and was able to lock it down again remotely.

I’ve almost given up on presence usage to do anything at this point as it’s never really reliable.

2 Likes

That is an astute observation.

Without doing a rigorous analysis, I can’t say for certain, but I guesstimate that a huge proportion of SmartThings dissatisfaction comes from inconsistent behavior of the two official Presence Device Types (the fob, and the mobile app / phone).

And, yes … I concur that some sort of “override-correct-in-place” mechanism does seem like a reasonable and expedient way to help simplify integration with various improvements.

The thing is, once you put an improvement in place (e.g., manually refresh the sensor or link the sensor to some other measure of presence such as checking DHCP on the router for a WiFi connection), then you’ve opened a can of worms. In the former, how long is the duration of the manual override or refresh? If the sensor failed to register as “present”, then what’s to prevent it from spontaneously reporting “not-present” again, immediately, in fact? In the latter (WiFi DHCP or some other presence method), you’re already writing code for enhanced presence, so adding a Virtual Presence is a trivial addition to that overall solution.

1 Like

It all depends on how you do it.

I think most people who are unhappy with smart things presence detection are unhappy for the very simple reason that it is unreliable for them. I have tried both the phone and the zigbee fob. The zigbee fob works better for me but still isn’t good enough on its own. In particular, it just randomly drops on and off the network several times a week.

I majored in computer information systems in college, I worked for IBM as a network engineer, and I’ve worked on multiple commercial installations using zigbee. All long before I ever came to Smartthings. The point being I know how mesh networks work, I know how the devices work, and I know that “all home automation is local” meaning what works for one person in one building may not work for someone else.

But I really wanted some of the advantages of the presence sensor (as someone in a wheelchair with limited hand function, it’s really nice if my house can respond to my arrival.)

So I have now taken a different approach, which validates the presence sensor indication with a second device like a contact sensor, motion sensor, or pressure Mat.

It’s working well for me, but it’s not a set up that will work for everyone, nor will everyone want to go to the trouble. And I still always have a Plan B, so I don’t get locked outside in the rain If smartthings fails altogether.

But I do think it’s clear that while the basic presence indicators work well for some people, they don’t work for everyone. So considering alternatives is perfectly reasonable.

2 Likes

I took some advice from some other threads about using Life360 instead of OOTB ST for presence. Many said it has its own problems and doesn’t solve anything, but it has been much more reliable for my wife’s iOS phone.

Not the reason I bring it up here though… @davglass asked for a refresh command and there seems to be an inadvertent way to do that with Life360, it worked for me the very few times a presence event was missed. If you go to settings of Life360 Connect from labs, click Next and click Done to update your settings it seems to refresh everybody’s location, and in my wife’s case, fire off the presence event that it missed.

Again, not getting into the whole stock vs Life360 vs tasker vs write your own code vs use your dog, three guitar strings and some handlebars (sorry just saw a McGuyver spoof), but at least I can tell Life360 to “check again” and it seems to work, so I feel like I now have a “refresh” command.

1 Like

Sorry for digging up such an old thread. I’ve used a modified version of @zpriddy https://github.com/zpriddy/SmartThings/tree/master/House%20Sitter to do what @davglass was asking for. I have just taken out the code that required a “Virtual House Sitter” switch to be activate/deactivated. I’m not using his Device Type either, and chose to use Smartthing’s own Virtual Presence Device. This is so that I can manual set presence and away if I want. My modified app is able to set presence properly, but generates an error when trying to activate away (as the virtual presence device looks for). It seems that my modified app is trying to set “notPresence” as the state. Any ideas to correct this, or will I have to use the zpriddy device type?

I am having a hard time understanding what you are trying to do? Can you please explain what the goal here is?

Thanks

@zpriddy, thanks for such a quick response. I would basically want your House Sitter App, without the additional virtual house sitter switch AND for it to trigger the stock Smartthings Virtual Presence. Or alternatively, an ability to use your device type with the option to manually (by tapping the device in the interface) be able to set presence or notPresence.

I haven’t tested this yet but I think this is what you are looking for:

What I have done is made it so that you will treat a virtual presence sensor as the actual presence sensor… and the switch will be another way to control the virtual presence sensor.

When the real presence sensor shows up as present - it turns the virtual switch on and the virtual presence to present. Same idea when leaving…

If the virtual switch is off and you manually turn it on… it then will set the virtual presence sensor to present and same when turning it off…

Let me know if this is what you are looking for.

/**
 *  House Sitter Enable
 *
 *  This uses a SmartThings SmartPresense Sensor and a virtual switch and a
 *    ZP Virtual Presense Device.
 *
 *    This allowes you to have a SmartPresense Sensor that you can give to a 
 *    house sitter so that your house will react to them. 
 * 
 *    The ZP Virtual Presence is what you use for HelloHome actions and presence 
 *    based actions. The presence sensor will be the same as the SmartPresence 
 *    sensor when the enable virtal switch is on. It will display as away all 
 *    the time when the enable switch is off. This allowes HelloHome actions to
 *    work as normal when you have no house sitter and leave the tag on your 
 *    key rack. 
 */
definition(
    name: "Presence with manual overrise",
    namespace: "zpriddy",
    author: "zpriddy",
    description: "Enable a Smart Presence Sensor with manual override",
    category: "Convenience",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Categories/presence.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Categories/presence@2x.png"
)

preferences {
    section("Select Real Presence Sensor") {
        input "presenceReal", "capability.presenceSensor", title: "Real?", multiple: true
    }
    section("Select Virtal Presence Sensor") {
        input "presenceVirt", "capability.presenceSensor",title: "Virtual", multiple: false
    }
    section("Select Presence Virtual Switch") {
        input "presenceSwitch", "capability.switch", title: "Presence Switch", multiple: false
    }
}

def installed()
{
    subscribe(presenceReal, "presence", presenceHandler)
    subscribe(presenceSwitch, "switch", presenceHandler)
}

def updated()
{
    unsubscribe()
    subscribe(presenceReal, "presence", presenceHandler)
    subscribe(presenceSwitch, "switch", presenceHandler)
    log.debug "App Updated"
}

def presenceHandler(evt)
{
    log.debug "Event presenceHandler"



    if(evt.value == "on" | evt.value == "off")
    {
        //Switch Triggered Action
        if(evt.value == "on")
        {
            presenceVirt.present()
        }
        else
        {
            presenceVirt.notPresent()
        }
    }
    else
    {
        if(evt.value == "present")
        {
            presenceSwitch.on()
        }
        else
        {
            presenceSwitch.off()
        }
    }
}
2 Likes

Wow @zpriddy thank you. That was quick.

1 Like