Virtual temperature sensor to show average of two other temperature sensors


#1

1) Give a description of the problem
Unsure how to create piston or if it’s even possible to do what I’m looking for.

2) What is the expected behavior?
Would like to take two multi sensors and average their temperatures to feed into one virtual temperature sensor.

3) What is happening/not happening?
Nothing

**4) Post a green screenshot

5) Attach any logs (From ST IDE and by turning logging level to Full)
`None to show’


How to use a simulated temperature sensor in WebCore
#2

I use this to make a lux value that is the average of two lux sensors.
I save the value to a global variable which I then use in several pistons.
image

The {format(’%.0f part gives you how many decimal places. 0f for none, 1f for one etc.


#3

If you already have the average temp variable in a local or global form, you can feed that information to a virtual device using this device handler by @whoismoses.

Call the setTemperature() task with your variable as parameter.


#4

Thanks for your input, but if you can help me out with the variable part itd be appreciated. Is that an expression you’re using?

And earlier when you set the variable- what type did you use - dynamic?

Thanks in advance!


#6

Yes to both questions.
It’s a dynamic variable and I’m using the expression field.


#7

Hey sorry to bother you some more about this but I’m struggling with what to use for he expression. Basically I know I need to create a variable which indicates the average of the two sensor’s temperatures. But how do I put it all together?


#8

Here you go.
Import this and replace the sensor names with yours.


#9

Thanks for your help, but is there a way to check he output? Do I need to do anything above in the setting local variables section? Sorry I’m totally spacing out this weekend!


#10

If are only going to use the reading in this variable, they configure a local variable.
How to…
Open your piston in edit mode.
Click on the x2 button at the top to allow you to configure a variable.
Click on define.
image
Define your variable a a dynamic one.
Now enter the information for your variable as below.
image

When you have defined the expression it should evaluate the value so you will know if it working or not.


#11

I hate even coming back to you on this one but I’ve always sucked at variables so no choice. I’m getting errors…


#12

These are the names of my Fibaro motion sensors that also do lux and temp.
The text that is in red needs to be the exact text that you you for your temp sensor.
Replace the text that I have with your text.
If you wish you can give me a screen shot of your device names but what i would suggest you do is this.
From the screenshot above you will see this expression.
format(’%.1f ', decimal(sum([Bedroom - Fib2. FS.:temperature][Bedroom - Fib3. BS.:temperature])/2))
The bold italic is the name of MY devices.
These need to be replaced with your device names.
If you delete my bold italic text and start to type yours in, it should complete it for you. Hopefully.


#13

Oh my gosh thank you! Must’ve been that tryptophan from Thanksgiving!


#14

In the (’%.1f ', part of the expression, the 1 denotes how many decimal places you publish. If you want no decimal places, replace the 1 with a 0. If you want 2, replace the 1 with a 2, and so on.
Just for your information.


#15

Ok onto the next step…

How is it you’d go about doing this? Here’s the piston I’ve got so far and already created a virtual temp sensor called Living Room Windows, but what do I change within your dry?


#16

Use your Virtual Temp Sensor as device, then call the setTemperature() task/action. In my example below, Avg Temp is my virtual device and avgTemp is my variable.

Based on your piston, you can add it directly after the set variable, in your case, you can

with
    Living Room Windows
do      
    setTemperature({Housetemp});
end with;

13 PM


#17

Like this? The device isn’t showing the temperature the way I’ve got it now.


#18

Is Dimmer 1 the virtual temperature device? Since the device handler is expecting a string, try enclosing the variable in string().

setTemperature({string(Housetemp)})


#20

What do I select for this menu? Value? Variable?


#21

Ah, try Expression, then enter string(Housetemp)


#22

And to answer your question - yes “dimmer 1” is the virtual temp sensor. It’s not really called dimmer 1, but the anonymizer called it that.