Virtual Presence Device - Control from SmartPhone

@kevintierney absolutely! A few other community members are already using SharpTools + Tasker along with the Simulated Presence Sensor to achieve more powerful/accurate presence.

The Simulated Presence Sensor exposes the methods arrived() and departed() which you can control through SharpTools.

Let me know if additional details are needed.

If it just me or is the Simulated Presence Sensor icon all messed up?

@joshua_lyon - can you show me the Simulated Presence Sensor source? I’d love to see how those commands are implemented.

The Simulated Presence Sensor icon was messed up for me as well. (Stretched out beyond the bounds of its container). I ended up just using a picture as the icon.

I’m not sure where the Simulated Presence Sensor source is as it doesn’t show up under ‘My Device Types’ > ‘New’ > ‘From Template’. Perhaps someone from ST could help with this request?

Where did you find out the methods arrived() and departed()? I’d like to use some of the other simulated sensors, but I don’t see their code available in the templates, so I’m not sure how to use them.

1 Like

Through reflection of supportedCommands in a supporting SmartApp.

1 Like

Someone created a smartapp that will display device capabilities. Install that and you can see what commands/attributes are available

2 Likes

That is brilliant! Thanks

OK cool - I pulled that down the same way too. I was hoping the source was out there

Kristopher

Source here:

https://graph.api.smartthings.com/ide/device/example/0d8244b9-e242-4e38-8f30-834b0753a239

So the interesting thing about that is the command is just “instanced” in the definition. I wasn’t really aware you could do that – so that’s pretty sweet.

1 Like

That’s the way SmartThings works, … If not exactly, but in effect:

The SmartDevice Type is used by the factory to create instances of the Device Class appropriate for each Thing.

Just an FYI - I noticed that ST recently deprecated this functionality. Intentionally or not.

1 Like

@Kristopher which functionality are you referring to that may have been unintentionally deprecated? I just tried an existing Simulated Presence Sensor and created a new Simulated Presence Sensor and they both seem to work fine using the arrived and departed commands.

I got a notification from SmartThings that some users are experiencing issues connecting and controlling their devices - might your concern be related to that?

20150317 - Device Control
Incident Report for SmartThings

New Incident Status: Identified
Some users may be experiencing issues connecting and controlling their devices. We have identified the issue and will update when it is resolved.
Mar 17, 08:29 EDT

This virtual presence sensor is perfect for the nanny/guest in the house scenario. My mom was visiting and when my wife and i left the house it went dark :slight_smile: instead of creating new modes just toggle the presence sensor and i’m done.

Hi

I’ve successfully installed the built-in ST Simulated Presence Sensor. It is currently attached to no other Things or SmartApps; also, for the record, using Android.

The Simulated Presence Sensor thing does NOT appear to be firing the DEPARTED command…

From the Live log:
11bf6995-86a1-44fa-bff0-b430b8253343 10:49:14 AM: trace Executing ‘arrived’ -> Manually set to Not Present, ie. I clicked the button/tile for the 2nd time
11bf6995-86a1-44fa-bff0-b430b8253343 10:49:06 AM: trace Executing ‘arrived’ -> Manually set to Present, ie. I clicked the button/tile for the 1st time.

I tried this with a second instance of another Simulated Presence Sensor, and again, for both the present (on) and not present (off) button press it fires the “arrived” method. It is never firing “departed”…

Thoughts?

Thanks in advance.
J

To answer my own question…

I found the answer in this topic:

Subject to correction, I believe this is the code that gets installed when one installs the built-in ST Virtual Presence Sensor; please correct me if I am wrong.

Based on the above assumption being correct, it looks like the correct commands are indeed firing depending on the present/not present state, BUT that the log reports it incorrectly:

// handle commands
def arrived() {
log.trace "Executing ‘arrived’"
sendEvent(name: “presence”, value: “present”)
}
def departed() {
log.trace "Executing ‘arrived’"
sendEvent(name: “presence”, value: “not present”)

Question: how would I go about fixing the built-in code?

Thanks
J

So, I have the virtual presence sensor setup as a widget w/ Sharptools, but the problem is, i need a seperate widget for present and away, is there anyway to code this as a toggle instead of like with light switch on/off function?

Yes see the code in the first post, that what it does, toogle presence with a switch like functionality.

Yeah, it works like that within the app, but for some reason, not with Sharptools. Maybe @joshua_lyon can help. :slightly_smiling:

@nomisr you could create a custom Device Type Handler (DTH) with a custom toggle() command, then change your existing simulated presence device to use the new DTH:

https://raw.githubusercontent.com/iamcanadian2222/SmartThingsPublic/master/devicetypes/smartthings/testing/simulated-presence-sensor.src/simulated-presence-sensor.groovy

Edit: Updated the method definition to togglePresence()… for some reason toggle() would work in the simulator, but not from other SmartApps.

Awesome! It works now! Thanks!