Pulling Temperature reading to Virtual Temperature Device

Tried everything on the forum but nothing is working. Any ideas on how to achieve this? I tried most methods and best I got so far was with custom Device Handle and Child/Parent app. All works but the value never updates the temp reads 0.

If you only have a simple, single or few manually created “Virtual Temperature Device” instances, then the simplest solution is to just add a trivial SmartApp that subscribes to your source device(s) and runs a Command on the Virtual Device to have it update it’s own Temperature Attribute.

Can you describe your full real-world use case in more detail?

I’ve done this before by creating a virtual temperature device and a SmartApp that let’s you use 1 or many physical devices (which averages them).

Here’s the code for the virtual device:


Here’s the SmartApp:



Create your virtual device first, and then install the app. This worked for me for years. As soon as any of the physical device(s) updated the temp reading, the virtual would update as well.


You are right this method works. I just needed to wait a couple of hours for it to update.


Hi, i do it but dosnt show the temperature, any idea?

It is not compatible with alexa, someway to do it with alexa?


If you set up the child and parent smartapp correctly, and the virtual device, everything should work as soon as an of the sensors update their temperature in ST.

What do you mean by compatible? The virtual device is just for temperature, and right now ST’s integration with Alexa doesn’t support just temperature devices.

1 Like

Hello, finally it works perfect it’s greatgreat.

There are some way to Alexa recognize the temperature?, I need Alexa show xx° , I want to do a routine, if sensor great than x° do something. It’s possible?.


Yup, that is possible. You can modify the code for the virtual device handler and add the following bit of code: (you’ll know where)

capability "Contact Sensor"

After you do that, go back to the Alexa smartapp in ST and add that to your list of Contact Sensors, and then ask Alexa to discover your devices.

After you do that you can then ask her for the temperature of that device, but I don’t know about using it in a Routine. I do all my Routines in ST, not Alexa.

Would you have a similar virtual app with temp and humidity?

Hi @Brant_Fischer, no I don’t sorry about that. It shouldn’t bee too difficult to modify the 3 pieces of code to do that. You’d just need to replace the temperature capability with humidity. I could probably add this to my ST project list I’m working on, but it will be a few weeks out.

unfortunately I did not understand how to do it! first do I create a device handler? and then a smartapp? and why are they mother and child?

unfortunately I did not understand how to do it! first do I create a device handler? and then a smartapp? and why are they mother and child?

come si impostra la smartapp sia bambino che genitore? non riesco a farlo, gentilmente mi puoi aiutare a configurarlo? grazie mille

It doesn’t matter. Save and publish the DTH and parent app, and just save the child app. Once you do that you can get things started.

Primarily for organizing and reducing clutter in your smartapp list.

I installed the dh, created the device and installed smartapp, but then I can’t configure smartapp and in addition on the created device the icon is not temperature. you can help me step by step thank you very much

No problem. I haven’t used this for a couple years now, so I’m going from memory.

  • Save and publish the code for the DTH.
  • Create a new device in the IDE. Be sure to use the DTH code you just created and saved.
  • Save and publish the code for the parent app.
  • Just save the code for the Child app.
  • In the mobile app, tap on “+”, then SmartApp.
  • Scroll down to the Custom section and find “Virtual Temp Device”
  • Tap on “Create Virtual Temp Device…”
  • Where it asks "Choose a target virtual temperature device… ", find your virtual device you created above.
  • Where it asks "Choose one or more source temperature sensors… ", select what sensors you want to get the data from.

As soon as any of the source temperature sensors update, the virtual device will update.