Virtual temperature sensor to show average of two other temperature sensors


#23

Still no luck.


#24

Hmm I loaded your piston and used my devices, it worked for me. I added a Log to console task before the setTemperature just to debug the output.

11/26/2017, 9:20:07 PM +43ms
+1ms ╔Received event [SugaBloom].temperature = 65.5 with a delay of 153ms
+93ms ║Runtime (38044 bytes) successfully initialized in 44ms (v0.2.0fe.20171109) (91ms)
+94ms ║╔Execution stage started
+129ms ║║Executed virtual command setVariable (3ms)
+140ms ║║65.8
+141ms ║║Executed virtual command [Avg Temp].log (1ms)
+302ms ║║Executed [Avg Temp].setTemperature (156ms)
+305ms ║╚Execution stage complete. (211ms)
+390ms ╚Event processed successfully (390ms)


#25

Woke up this morning and it’s working. I really want to thank those helped me - much appreciated!


#26

I did something like this the other day - up to the point of creating/setting the global variable - I’ll use it later. However, quick question…I used the format(’%.0f statement, and in the expression it prints nice as a whole number (image 1 below). However in the Variables output below the code window it prints a very long decimal (image 2). Should I be worried about that?

image

image


#27

I’d suggest setting the value of your @PorchTemp variable to the output of your Expression.


#28

That is actually exactly what I am doing here.

The first image above with the expression is the expression in this ‘set variable’ statement.


#29

I have mine setup slightly different format('%.2f',avg([tempDevices:temperature]))


#30

a) Your approach = Much cleaner! Nice
b) It seems to have self-corrected. When I went back to change it to use avg instead of sum/divide it was right, and when I average the sensors myself I get a 52.5, where now both the expression and the global = 53.

Thanks for helping.


#31

I’m looking at doing something similar, except I’d like the max or min of two physical sensors. Does WebCore has a function that give you max or min? Thx!


#32

Maybe someone can help me here. All I’m trying to do is turn on a light when Lux reaches 0.16 say.
But i can’t for the life of me put
“If Lux drops below 0.16” because the piston can’t seem to accept a decimal…
I’ve tried using an Expression, but it rounds 0.16 to Zero for some reason.
what’s the trick?


#33

Do you have one of those zooz 4 in 1 sensors?


#34

No, actually it’s the custom zigbee module designed by Iman, and he’s made Lux decimal in the DTH. I think it helps with the Smart Lighting App maybe. Anyway i’m just trying to do a sunset piston for a light, using Lux instead of time.
Any idea how and I can trigger at 0.16 Lux?!!


#35

This one worked…
image


#36

I’ve made a variable called “Lux” that is a Number (decimal) with a value of 0.16.

But the piston doesn’t show it, when i say if Luminance sensor drops below variable “Lux”.

The variable “Lux” isn’t available from the drop down menu…


#37

I always thought webCoRE didn’t accept decimals too but it seems to be a bug issue because if you copy and paste them into webCoRE they’ll work fine.


#39

Where do you copy and paste it in? I don’t get it.
This variable should say 0.16, but it says 0.


#40

I used expression to convert the device:illuminance to decimal before it let me choose the lux variable.

decimal([device:illuminance])


#42

Hi eibyer,

I loaded this device handler into SmartThings and have created a Virtual Temperature Sensor. I also have a WebCoRE piston that calculates the average of 3 temperature sensors and saves this to a Global Variable. I just can’t figure how to get the Virtual Temperature Sensor to have the same values as the Global Variable.

Could you help me with an example piston?

Thanks,

John


#43

I’m not at a PC right now but in the same piston that you are using to set the value of the global variable, you can just add another task right after it but using the virtual device you created and then use the setTemperature() command to set the value you have calculated.


#44

Thanks eibyer.

I’ve tried that and if I select “set temperature ()” I then can’t choose the proper variable. It only lets me chose integer or decimal variables that I had already set up. The average temperature is set up as a Dynamic Variable. Should it be set up as a decimal variable?