First of all, thx for your help and the diagnostic code. I will try to integrate into my rule.
So now let me explain what the rule should do (hope in short words).
I’m using the “OpenWeatherMap-Binding” (free Version) to get several Weather-Data. The Problem of the free Version is that you do not get daily values, only values in 3-hour-steps, up to 120 hours (120 / 24 = 5 days), but shifting every 3 hours.
Now I want to know daily measures for today, tomorrow,… up to day 5 for exactly the specific day(s). So I began to create a rule.
The first one I made (with the help of @5iver, @rlkoshak, @vzorglub) , where I learned a lot about generic items from Scott, was about 350 Lines (or more) of code. (a lot of variables,shifting and calculate…)
The second one has had a lot of HashMaps and I could reduce the code down to 250 lines (thx to Rich for his help and his endurance).
This version is more or less based on a great idea of @Udo_Hartmann. So I can learn from him something about the Grouping-Methods. Now the code has (more or less) 80 lines, doing the same as the both others.
So here I calculate the number of items for the specific days and which one is the last item of the specific day:
val day = -1
val day0 = 7 - (now.getHourOfDay / 3).intValue
val day1 = day0 + 8
val day2 = day1 + 8
val day3 = day2 + 8
val day4 = day3 + 8
val Number day5 = 40
Therefore the items look like
Number:Temperature localHourlyForecastTemperature_00 "Aktuelle Temperatur [%.1f %unit%]" <temperature> (gOWM1,gTemp) { channel="openweathermap:weather-and-forecast:api:local:current#temperature" }
Number:Temperature localHourlyForecastTemperature_01 "Temperatur in 03 Stunden[%.1f %unit%]" <temperature> (gOWM1,gTemp) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#temperature" }
Number:Temperature localHourlyForecastTemperature_02 "Temperatur in 06 Stunden [%.1f %unit%]" <temperature> (gOWM1,gTemp) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#temperature" }
Number:Temperature localHourlyForecastTemperature_03 "Temperatur in 09 Stunden [%.1f %unit%]" <temperature> (gOWM1,gTemp) { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#temperature" }
.................
Number:Temperature localHourlyForecastTemperature_39 "Temperatur in 12 Stunden [%.1f %unit%]" <temperature> (gOWM1,gTemp) { channel="openweathermap:weather-and-forecast:api:local:forecastHours117#temperature" }
Number:Temperature localHourlyForecastTemperature_40 "Temperatur in 15 Stunden [%.1f %unit%]" <temperature> (gOWM1,gTemp) { channel="openweathermap:weather-and-forecast:api:local:forecastHours120#temperature" }
for the later “Splitting and Changing Part” in the Grouping-Section and summarizing the daily measures.
So after I understand that genius idea it was not very hard to realize.
Maybe it’s hard and complex for DSL , but not for me anymore. I learned a lot in that time, when corresponding with you all. I’m still a newbie (and dummy) and as my nick-name says (fibu = financial accountant - now retired) I still have no idea about programming and that stuff, but I know there’s always a “helping hand” here in the community (and of course in the german one too) and that’s why I like this software (openHAB) even with all corners and edges.
So one more time, many thanks for your help.
Cheers,
Peter
BTW: The error didn’t came up anymore 'til now. If one of you wants to have my setup(items,rules,thing) for testing purposes; any time