Virtual Presence Device

@impliciter, you are definitely on the right track. Here is a rough overview of how I’d approach it:

  1. Create a new device handler. Give it presence capabilities. This is your virtual presence device. Your code would probably look similar to the mobile presence device handler.
  2. You would want to add some sort of identifier preference setting to your custom device handler. This setting will allow you to input an id when you later add the device. The id will map from your phone’s MAC address (or network name, or whatever information your router software gives you) to the associated presence device.
  3. Create a new smart app with a custom REST endpoint. Check out this tutorial: http://build.smartthings.com/blog/tutorial-creating-a-custom-rest-smartapp-endpoint/
  4. Give your smart app a “Presence Devices” input. This is the input that you use to tell the app which virtual presence devices it should managed.
  5. You would want to interface with at least two REST API call: /myapp/{presence_device_id}/setpresent and /myapp/{presence_device_id}/setabsent. presence_device_id is the device id from #2.
  6. The two API handlers would each iterate over all the virtual presence devices set on the input from #4, pick the one where the id (the setting from #2) matches presence_device_id, and then call device.presence = “present” or device.presence = “not present” respectively.
  7. From your python script you can call: https://graph.api.smartthings.com/api/smartapps/endpoints/xxx/myapp/{presence_device_id}/{setpresent|setabsent} respectively, when the phone with presence_device_id changes status.

EDIT: After implementing the SmartApp and device handler code. You would want to go to the web IDE and add any number of devices, using your new device handler as type. Then for each one of these devices set the presence_device_id preference to the respective MAC address or network name of the phone. Then install an instance of your newly created SmartApp, and set all the virtual presence devices you just created on the “Presence Devices” input.

1 Like