Homey Community Forum

[Howto] set a value to a virtual device

How to set a value to a virtual device.

There is a lot of questions about the virtual sensors and a lot of peeps don’t get it to work so here’s a little tutorial on how to set a value on a virtual sensor.

Add the device.

When making the virtual device be sure to pick the correct capabilities. In this example i took a virtual thermostat and used the "Virtual devices" app from Arjan.

So we add a new device, pick “Virtual devices” and then click “Device”. Hit “connect” in the next screen. In the next screen u give the new device a name of ur choise and hit next.

In the next screen u can pick an icon or upload ur own. I picked one from the list.
Then we hit “Thermostat” because that’s the device i choose to make in this example.

In the next screen u can select the capabilities u need. I chose “Target Temperature” and “Measure temperature”. This is important for every other device so make the correct choises! Then we hit next and the device is added.

chrome_2021-04-07_18-05-24

Then we go set a value for the Virtual thermostat we just created. In this example i wanna show the temperature of the bed from my 3D printer.

Make the flow.

We make a flow. The trigger part and the AND part is free to pick, the THEN part is important in this case so am gonna show u just the AND part.

For the AND part we pick the Virtual Devices app and pick the Virtual thermostat u just created, then hit “Set a virtual sensor value”.

And here is the most important part where it goes wrong every time…

In the first field (sensor) we wright down “measure_temperature”. We don’t use tags here or anything other then the capabilitie we need. And we need to type them!
All capabilities are found here.

In this example i wanna show the temperature so i picked “measure_temperature”. When u wanna show other things like power or gas or something else then look at the link and pick the correct capability.

Do not fill in anything else then a capability here!!

chrome_2021-04-07_17-51-51

In the next field u can pick a tag from a device which u wanna show the temperature of. In this case my 3D printer. Hit the little tag on the right side of that field and search for the tag u need.

chrome_2021-04-07_17-52-32

Ur AND part of ur flow should look like this now:

chrome_2021-04-07_17-52-47

When u run ur flow the temp will be shown on ur virtual device now.
U can add the device to ur favorites and show them on Homeydash.com for example.

A tutorial in Dutch.

Disclaimer.
Please don’t react with “better pick the virtual devices native in Homey” or something like that, this tutorial is just to help peeps getting their virtual devices up and running.

10 Likes

Love this!

2 Likes

Hi,

thx for the tutorial.

Any idea what is wrong here?


The flow can read the real temp out of the sensor but isn’t able to set this value.

thx
Daniel

And what is the actual temperature from that tag? Because it looks like something with 26.31275432 or something like that.

The Tag is 14.1

You need to change your step size during pairing, by default this is only 0.5, measure temperature uses 0.01 usually

Not sure the step is changeable for the virtual target temperature.

if not then:
Normally (regular) thermostats target temperature need to be rounded to *.5 or round numbers, so you’ll have to calculate your value(s) ({{ round(value * 2) / 2}}) first, then send it to the thermostat.

question to @Martijn_Hoogenbosch - how do you get the temp value shown in the icon/device? I get it working but not shown in the icon (only shows the value/temp when I long press the icon in my homey app).

my flow looks like:

If: Temp changed
And: empty
Then: see screenshot

And I do have the 0.5 rounding. I don’t believe 0.1 works. At least I can’t get it working during the adding of the virtual device.

target_temperature

target_temperature

2 Likes

Unfortunately something still is not working properly. I am using a Aqara temp sensor outside (not a thermostat). My flow below:
first issue is an execution error on target_temperature. I saw in the capabilities that UI component is Thermostat and not sensor (will this work on a Aqara sensor?)
second issue: no value still shown on the device (like in the screenshot of Martijn H), only after long pressing the device. This is my goal - get the value/temp shown in the device without having to long press it.

Don’t think u can set a temperature on a sensor.

Please check if there are no spaces around the calculation. Should do the check with the webapp

Well, that depends on the way he has created the virtual sensor. It should at least have the following capabilities as you have mentioned:

  • Targettemperature
  • Measured temperature

And on top of that the minimum and maximum should be altered. Hes measuring an outside temp, you will probably want to change the minimum temp to -15 and max to 50 or so.

there was a space, removed it. Error stays the same


If I look at the capabilities below it seems like target_temperature is not applicable to a sensor, only thermostat!?

Right, then that’s what @Rocodamelshekima means! I’m using thermostats indeed! My apologies to both, didn’t notice that. But the virtual device should be a thermostat for the view I’ve created.

thnx! made a new Virt Device with thermosat instead of Sensor, now see another device with temp indication. Will recreate the flows…
update: got it working, thnx @Martijn_Hoogenbosch :ok_hand:

1 Like

Geniaal dank je wel!!

1 Like

image
You missed a ( after round, these things always come in pairs :wink: