Calculations based on weather


#1

Is there a way to calculate average max temperature and low temperature for the last or next 3 days?

I found the syntax to generate max and min temperatures for the next 3 days. But how do I perform calculations on it? The max/min results are like 72, 52, 42, 60. How do you add, subtract a string.


#2

In an expression field you can use basic mathematical operators:

Set variable {averageTemp} = (Value1+Value2+Value3)/3


#3

Not sure how to do that. I have assigned dynamic variable for max and min F. How do I use that to find average? When I try to create expression it says variable not found.


#4

The expression editor will not find a new variable until you save and reopen the piston.

(variableMin + variableMax) / 2 = variableAverage


#5

OK. Got it. Another issue is that $weather.forecast10day.forecast.simpleforecast.forecastday.high gives out results as [74, 54, 42, 61]. When I do avg(max,min) the results are 60423447. All the 4 temperature are combined a 1 number. My goal is to find avg(max, min) for next 3 days. Then find avg(day1,day2,day3) and then avg(day1,day2) And finally avg(avg (day1,day2,day3), avg(day1,day2)).

If I could get max/min of individual days that would fix my problem.
example:$weather.forecasttoday.forecast.simpleforecast.forecastday.high
$weather.forecasttomorrow.forecast.simpleforecast.forecastday.high


#6

Unfortunately Wunderground’s api is not always ideal (as I have learned with my roof heater piston) … so…

using what is available here: https://wiki.webcore.co/Weather I through this together … I only did two days but should get you going … and I am postiive there is a more elegant way to do this :slight_smile:

in the brackets can be 0-9
0=today
1=tomorrow
2=next day … etc

Hmmm actually i think 0 may be tomorrow with this call…
Will fix and repost in a sec


#7

Today:
$weather.forecast10day.forecast.simpleforecast.forecastday.high.celsius[0]

Tomorrow:
$weather.forecast10day.forecast.simpleforecast.forecastday.high.celsius[1]


#8

Thanks. I think I got the calculation to work. Now I want the piston to run and send me a text if the final average is above 52F.

example: Temperature is 54.1F.

My piston has this message saying ‘This piston does not subscribe to any events. Unless executed by other means, it will never run on its own’


#9

Perfect. I dont suppose there is a syntax for yesterday, day before max/min?


#10

Not exactly… but if you save the required value today you can use it tomorrow :wink:


#11

True. But future max/min are just predictions. It might be off by a few degrees.


#12

Well then you’ll have to check the current observation hourly and update max / min.

Define
integer recordedMax
integer recordedMin
integer recordedAve
integer recordedAveYesterday

Every 1 hour at 00 minutes

IF
$weather.conditions.current_observation.temp_c IS greater than {recordedMax}
THEN
set variable {recordedMax} = {$weather.conditions.current_observation.temp_c}
End if

IF
$weather.conditions.current_observation.temp_c IS less than {recordedMin}
THEN
set variable {recordedMin} = {$weather.conditions.current_observation.temp_c}
End if

set variable {recordedAve} = {recordedMax * recordedMin) / 2

End every

Happens daily at 00:05
DO
Set variable {recordedAveYesterday} = {recordedAve}
// reset max / min for next day
Set variable {recordedMin} = {recordedAve}
Set variable {recordedMax} = {recordedAve}
End Every


#13

This is what I have. I will see how this works. Anyway for webcore to message me Soil temperature is ‘avg3 value’?


#14

something looks off with your last and condition … is that right?


#15

I had to involve my thermostat else the piston wasn’t going to run on its own. So now every time my thermostat is idle/heating/cooling it does the temperature calculations.

Is there a way to add the AVG3 value to the PUSH notifications? Example: Soil temperature is 55 F.


#16

Just place the variable name inside { } brackets within the message field.


#17

I just figured it out. But I am unable to adjust decimal place. This is what i have:

"Soil temperature is " {AVG3}


#18

Try round()

https://wiki.webcore.co/Functions#round


#19

I am trying but I am unable to get precision to work.

round({AVG3} [,precision=1])?


#20

"Soil temperature is " {round(AVG3,1)}