OpenWeather - how to interpret and calculate rain for last 24h and the 24h forecast

I’m working on the irrigation system and want to make it dependent on the rain forecast and precipitation for the last 24 hours.

To calculate the decision whether to start watering or not I use OpenWeatherBinding, however, I don’t know how to interpret the current and forecasted rain. I use persistence to store the value of the current rain every 15 minutes.

First of all, I don’t understand the unit of measurement of the precipitation the OpenWeather provides. What does it mean exactly that it is 2 mm of rain? Does it mean that there will be 2 mm of rain in 1 hour?

Here is a particular example. Below is the graph that represents the stored values of current rain for the last 24h. You can easily see a huge peak around 18-19. This was a really huge rain.

When I sum the rain from the last 24 hours with the code below, I get the result of 680 mm of rain (I’m not sure if this is calculated in the right way).

WeatherAndForecastCurrentRain.sumSince(now.minusHours(24), "influxdb")

When I get average rain fro the last 24h, I get the result of 2.58 mm of rain and considering that there was a huge rain and flood this value looks quite small to me.

WeatherAndForecastCurrentRain.averageSince(now.minusHours(24), "influxdb”)

The other thing is the forecasted rain which I can get from OpenWeather by adding forecasted precipitation for the 3, 6, 9, 12, 15, 18, 21, and 24 hours to the group and get the average or the sum.

Group:Number:AVG GroupForecastedRain24

Group:Number:SUM GroupForecastedRain24

I can’t correlate the values of the forecast with the last 24 hours.

Could you help me understand the values from the OpenWeather binding and how to calculate the sum / average for the last 24 h and for the forecast for the next 24 h?

I would include the Group:Number MAX ForecastedRain24 as well, because this is a good indicator there could be a huge downpour.

Knowing that you store every 15 minutes that is at least 96 times a day.
If you divide the maximum by 96 and compare it to the AVG and the SUM. The lower the number the smallest number of real big showers.

For the current value, it would mean 2mm of rain in 1 hour. For the forecast, it is 2mm of rain in 3h. For the daily forecast (not available with free API), it is 2mm for the day.

You can persist data every change or every update. When using averageSince, you need to take this into account.

If you are using a persistence strategy to save the current 1 hour rain volume data every 15 minutes, then you are persisting mm/h every 15 minutes. So, you will have 4 values per hour and the sum of the persisted values over the last 24 hours would need to be divided by 4 to get the 1 day sum. The average over the last 24 hours will provide the 15 minute average, so you will need to multiply by 96 (24 * 4) to estimate the 1 day average. Things would be more straightforward if you persisted every 1 hour.

For the 3h forecasts, you won’t be able to use persistence, but you can use this, which puts the 3h forecasts into groups to aggregate the values…

That clarifies a lot.
But I think something is still wrong, as the average for last 24h is higher than sum. That is the code (once I fully understand that I’ll change persisting to 1 h instead of 15 mins):

SumRainLast24h.sendCommand((WeatherAndForecastCurrentRain.sumSince(now.minusHours(24), "influxdb") as Number).doubleValue / 4)
AvgRainLast24h.sendCommand((WeatherAndForecastCurrentRain.averageSince(now.minusHours(24), "influxdb") as Number).doubleValue * 24*4)

The sum is: 21.9125 mm
The avg is: 49.5243 mm

I understand that for the forecast when I have

Group:Number:AVG GroupForecastedRain24

I have to multiply it by 8 (24 h / 3 h forecast)?

Here are the items in the GroupForecastedRain24:

Item WeatherAndForecastForecastHours03Rain | 0.0 mm

Item WeatherAndForecastForecastHours06Rain | 0.0 mm

Item WeatherAndForecastForecastHours09Rain | 0.0 mm

Item WeatherAndForecastForecastHours12Rain | 0.0 mm

Item WeatherAndForecastForecastHours15Rain | 0.0 mm

Item WeatherAndForecastForecastHours18Rain | 0.043333333333333335 mm

Item WeatherAndForecastForecastHours21Rain | 0.12333333333333334 mm

Item WeatherAndForecastForecastHours24Rain | 0.12 mm

Could you post the persistence strategy used for these Items? If you are using every change and/or also persisting other than 15 minutes, then you will get some funky values, which is what I just got when testing this out.

BTW, if you do not have a way to see the data, you might want to look at…

This will give you the average 3h forecast for the day. I think you are looking for the SUM of the 3h forecasts for the day.

I think that the biased data is because I changed the strategy yesterday day. The strategy is:
every15Minutes : "0 */15 * ? * *"

Group_Rain*: strategy = every15Minutes

Will do. Thanks!

This will give you the average 3h forecast for the day. I think you are looking for the SUM of the 3h forecasts for the day.

That is so obvious… :man_facepalming:

I’ll change the persistence strategy to 1h and I’ll check the results again tomorrow against what is actually forecasted now.

1 Like