For garden watering purpose, I’m trying to determine for how long time the drip / sprinkler watering system should be turned on every night.
Every hour a rule is evaluating the weather, and assigns it to one of five weather groups (type of weather).
rule "HourlyWeaterGroupDetection"
when
Time cron "0 0 * * * ?"
then
logInfo("Weather","Weather rule fired")
if(Humidity_Average.state <= 30 && Clouds.state == 0 && Netatmo_RainGauge_RainLevel1h.state == 0 && Temperature.state > 20) {
WeatherGroup05 = WeatherGroup05 + 1
postUpdate(SitemapWeatherGroup05, WeatherGroup05)
logInfo("Weather","Weather group 5 evaporation 5mm")
}
else if(Humidity_Average.state <= 70 && Clouds.state <= 20 && Netatmo_RainGauge_RainLevel1h.state == 0 && Temperature.state > 15) {
WeatherGroup04 = WeatherGroup04 + 1
postUpdate(SitemapWeatherGroup04, WeatherGroup04)
logInfo("Weather","Weather group 4 evaporation 4mm")
}
else if(Humidity_Average.state <= 90 && Clouds.state <= 80 && Netatmo_RainGauge_RainLevel1h.state < 0.5 && Temperature.state > 10) {
WeatherGroup03 = WeatherGroup03 + 1
postUpdate(SitemapWeatherGroup03, WeatherGroup03)
logInfo("Weather","Weather group 3 evaporation 3mm")
}
else if(Humidity_Average.state >= 60 && Clouds.state >= 65 && Netatmo_RainGauge_RainLevel1h.state < 0.5 && Temperature.state > 5) {
WeatherGroup02 = WeatherGroup02 + 1
postUpdate(SitemapWeatherGroup02, WeatherGroup02)
logInfo("Weather","Weather group 2 evaporation 2mm")
}
else if(Humidity_Average.state >= 60 && Clouds.state >= 65 && Netatmo_RainGauge_RainLevel1h.state >= 0.5 && Temperature.state > 5) {
WeatherGroup01 = WeatherGroup01 + 1
postUpdate(SitemapWeatherGroup01, WeatherGroup01)
logInfo("Weather","Weather group 1 evaporation 1mm")
}
end
Just before midnight, I want to turn on the garden watering, and the most used weather group (highest decimal value) decides for how long time.
At midnight all five weather group items are set to zerro
My question is, what is the best way to determine which of the five number items have the greatest value? I have tried with “>” two at a time, I think I could mange it to work, but it dose not look quite elegant I guess.
Any suggestions?
BR O