Virtual Devices

I would like to create a virtual device type which would ask the user to select a physical device and then subscribe to events of the physical device and generate “duplicate” certain events.

For example, the virtual device would act like a temperature sensor taking temperature measurements received from the physical device.

Has anyone done this?

Check out my AverageThings SmartApp at It should do what you want. You have to create a virtual temperature device then using the app, link the virtual device to the physical device.

Totally unrelated to the answer so graciously provided here but ST needs to gather all the amateur coders at places like github and place (or link) their code with descriptions in a repository for the layperson to search and access. It would save all these requests for apps that have been already developed and tested privately. Maybe a forum category where everyone can advertise their goovy accomplishments.

@notoriousbdg thanks for the link. I will have a look at it.

I really would like to have a virtual device without helper app. I tried to to use an ‘input’ statement like input “temperature1”, “capability.temperatureMeasurement”, but ran into the following problems:

(1) the simulator does not seem to support the input statement in the device

(2) when running the device in iOS, it does allow me to search for a new temperature sensor, but it does not allow me to select an existing temperature sensor

Is this because I try to do something which is not supported or is it a problem of my coding?

@daven it would be nice to have a repository of code, but rather than complete code for an application, I would be interested in a cookbook, small snippets of code which shows you how to accomplish things.


In your SmartApp, you call the parse() method of your virtual device directly:"temperature: ${average}")

What is the difference with calling parse() directly or using sendEvent()? What would be the preferred way?

sendEvent(target, [temperature: ${average}])

Anyone, I just need to pass the temperature from the multi-sensor to the virtual device. Having a SmartApp just to pass a value, seems like an overkill. Is it possible to “link” the virtual device directly to the physical device?

The virtual temperature tile that I’m using had the parse command builtin, so that’s what I used. I actually didn’t even try sending the event instead so I don’t know if that works or not.

Sending an event to the device will call the parse() method of the device. That’s how I do it. You are a bit restricted with argument. SendEvent expects a map and passes that to parse(Map evt).

@notoriousbdg Thanks for your app contribution. Would there be a way to show each temperature your getting?

So if I was to tap the gear icon on the tile for the virtual temp, then it takes me to the tiles for that virtual device. Is there an easy way to have a tile for each real device it’s pulling from?

you’ll need a smartapp to read from one device to write to another device.

@urman thanks for the feedback. Can I clarify the above statement?

(1) it is not possible to select a connected device in an input statement in the device type preferences?
(2) It is not possible to use sendEvent(device, Map) in a device handler?

I have now written 3 device type handlers and I had to write 3 different helper apps because I couldn’t figure out how to do it in the device type handler :frowning:

One more question related to device handlers. Is it possible to change the location mode from within a device type handler?

  1. Nope :frowning: SmartApps only
  2. A device can do sendEvent, but it only sends events to itself.

You need something like this.

Temp Sensor > SmartApp > Virtual Device

SmartApp would take the input of a temp sensor and set the state of the virtual device.

Thanks @urman. Can a device type handler change the location mode or does this need to be done by a SmartApp as well?

that is a good question, to which I’m sure there is an answer.

I’d totally tell you, but uhhhh my moms calling me so I totally have to go…


I had trouble locating the VirtualThings code at first but found it on your GitHub. I created a new device type and then eventually created a new device in the IDE using the Virtual Temp Tile and it created the tile. The tile currently shows no tempurature. I can point average things to the Virtual Temp Tile but I am not sure how to get it connected so that the temp will adjust based on the average temp. Ultimately I want to map this to my Nest thermostat that I have disabled the learning features on.



Nest doesn’t allow you to provide temperature from an external sensor. You could use something like to run the HVAC fan to even out the temperature.

I thought that KeepMeCozy II could look at an external temp sensor and set the Nest based on that. In this case, I would use the virtual sensor to pick up the average from AverageThings. Remember that I have turned off the learning function of the Nest so it stays where it’s set and it does not have its own schedule anymore. This is how I have KeepMeCozy II configured. Wouldn’t this work with Nest?