Physical (temp or contact) sensor synced to virtual sensor?

Is there an existing smart app that syncs the state of a physical sensor(temperature or contact) to a virtual sensor of the same type? If there is not an existing one, any ideas on how to create one, or hack something that is existing?

I have a Fibaro FGK-101 that I am using for both a contact and temp sensor. I wanting a way to display in a “room” a virtual sensor that reflects the status of one of those inputs while the physical device reflects the other for at a glance status.

Hi @ecam315. I do something similar with a virtual temperature device and controlling SmartApp. I used code from other developers and put this together a long time ago, but it still works. There are better ways to do this with just a SmartApp that creates a child device, but none the less it works.

Here’s the code for the virtual temperature DH:
https://raw.githubusercontent.com/constjs/jcdevhandlers/master/devicetypes/jscgs350/my-virtual-temp-tile.src/my-virtual-temp-tile.groovy

Here’s the code for the SmartApp:
Parent:
https://raw.githubusercontent.com/constjs/jcdevhandlers/master/smartapps/jscgs350/virtual-temp-device-parent.src/virtual-temp-device-parent.groovy
Child:
https://raw.githubusercontent.com/constjs/jcdevhandlers/master/smartapps/jscgs350/virtual-temp-device-child.src/virtual-temp-device-child.groovy

The SmartApp can use multiple sensors and calculate an average, or it can use just one.

I’m assuming you know how to create a virtual device in the IDE and SmartApps, but if you don’t please let me know, or check out this wiki:

http://thingsthataresmart.wiki/index.php?title=Using_Custom_Code

Thanks, I will give that a try, the contacts sensor is what was thinking might be simpler. I have been Cut/pasting code that I have been finding, but haven’t actually managed to make anything work correctly.

Have you had any luck yet?

I’ve added them both, and run the setup, but it doesn’t seem to be working. That being said, haven’t had a chance to mess with to see if I can tell what is going on.

In case some one comes across this forum looking for answers and is having trouble making this work.

The updated address for the parent code is;
https://raw.githubusercontent.com/constjs/jcdevhandlers/master/smartapps/jscgs350/virtual-temp-device.src/virtual-temp-device.groovy

I was able to get this to work using the parent code, child code, and device handler code provided above. Here’s what you have to do… (or at least how I got it working)…

  1. In you Smartthings IDE account go to “My Devices”
  2. on the upper right corner click on “+ New Device”
  3. Make up a Name and Label for your New Virtual Device (these 2 fields can be anything)
  4. “Zigbee Id” remains blank
  5. “Device Network Id” Can be anything as long is it has not already been used by your hub for another device. I used “VirtualTile01”, “VirtualTile02”, etc.
  6. “type” will be the Device Handler you created using the code above. (I used one that I created myself)
  7. all the remaining options can be filled by using the drop down lists. (be sure to select PUBLISH)
  8. Click on “Create” and you should be able to see the new device you created in your smartthings app
  9. Now in the smartthings app, go to Marketplace -> SmartApps -> My Apps -> Virtual Temp Device Child
  10. select the virtual device that you created as your “target” virtual temperature device
  11. select the temperate sensor that you want to duplicate

And you’re done… I may take a second for the temperature to updated, as I believe it may need to change +or- 1 degree to show the new temperature

Hope this helps :).