Virtual Presence Device - Control from SmartPhone

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!

@joshua_lyon curious, I noticed you’ve defined arrived and departed - are these ST required interfaces or custom interfaces?

Anyone noticed that the Simulated Presence Sensor code is no longer available in the sample codes or GitHub.
@jody.albritton do you have any insight into why it was pulled?

I’m sorry to “hijack” the thread, but I created a device type That allows you to control presence with a switch. It works with SharpTools.

I can no longer manually toggle my simulated presence devices in the mobile app… I can still do it via SharpTools.

1 Like