Hallo Udo,
ich hoffe ich habe dich nicht um deinen Schlaf gebracht, dass du mir um diese Uhrzeit noch (schon) antwortest

.
Also, es geht um das OpenWeatherMap-Binding (die freie Version) von C.Weitkamp. Dieses Binding liefert Wetterdaten. Allerdings stellt die freie Version keine kumuliertenTagesdaten zur Verfügung.
Man bekommt hier für einen Zeitraum von max. 5 Tage die Vorhersagewerte für jeweils 3 Stunden. Es gibt also Werte für "Jetzt", in 3 Stunden, in 6 Stunden, in... bis in 120 Stunden. Der Prinzip-Aufbau ist an die Binding-Doku angelehnt.
Diese Werte
a) verschieben sich natürlich immer wieder. Alle 3 Stunden fällt der letzte Wert weg und vorne kommt ein neuer hinzu und die dazwischen verschieben sich um einen Zeitraum.
b) die Werte als solche passen sich natürlich auch wieder an die aktuelle Wettersituation bzw. Vorschau an.
Hier ein kleiner Auszug aus meinem Items-File:
Code: Alles auswählen
DateTime localLastMeasurement "Timestamp of last measurement [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]"<time> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#time-stamp" }
DateTime lastRuleRefresh "Rule triggered at [%1$tH:%1$tM:%1$tS]" <time> (gOWM,gOWMOutlook) // Value calculated via Rule "owm Aggregation daily Measures"
Switch owmTriggerSwitch "manually Trigger Switch [%s]" (gOWM,gOWMOutlook) // using mapdb.persist to save last State
Image localCurrentConditionIcon "Icon" (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#icon" }
String localCurrentConditionIconId "Icon Id [%s]" <icon> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#icon-id" }
Number:Temperature localCurrentTemperature "Current temperature [%.1f %unit%]" <temperature> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#temperature" }
String localCurrentCondition "Current condition/Wetterlage[%s]" <sun_clouds> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#condition" }
Number:Pressure localCurrentPressure "Current barometric pressure/Luftdruck [%.1f %unit%]" <pressure> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#pressure" }
Number:Dimensionless localCurrentHumidity "Current atmospheric humidity/Luftfeuchtigkeit [%d %unit%]" <humidity> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#humidity" }
Number:Speed localCurrentWindSpeed "Current wind speed/Windgeschwindigkeit [%.1f km/h]" <wind> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#wind-speed" }
Number:Angle localCurrentWindDirection "Current wind direction/Windrichtung [%d %unit%]" <wind> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }
Number:Angle localCurrentWindDirectionNamed "Current wind direction Named [SCALE(wind.scale):%s]" <compass> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }
Number:Length localCurrentRainVolume "Current rain volume/Regen [%.1f %unit%]" <rain> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#rain" }
Number:Length localCurrentSnowVolume "Current snow volume/Schnee [%.1f %unit%]" <snow> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#snow" }
Number:Speed localCurrentGustSpeed "Current Gust Speed/Windböen[%.1f %unit%]" <wind> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#gust-speed" }
Number:Dimensionless localCurrentCloudiness "Current cloudiness/Bewölkung [%d %unit%]" <cloudiness> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#cloudiness" }
String localCurrentConditionID "Current condition ID[%s]" <pic803> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:current#condition-id" }
DateTime localCurrentUVIndexTimestamp "Timestamp current UV [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time> (gOWM,gOWMOutlook) { channel="openweathermap:uvindex:api:local:current#time-stamp" }
//DateTime owm_localCurrentUVIndexTimestamp "Timestamp UV Index [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time> (gOWM,gOWMOutlook) {http="<[owm_test:120000:JSONPATH($.date_iso)]"}
Number localCurrentUVIndex "Current UV Index [%d]" <uv_index> (gOWM,gOWMOutlook) { channel="openweathermap:uvindex:api:local:current#uvindex" }
//Number owm_localCurrentUVIndex "Current UV Index [%d]" <uv_index> (gOWM,gOWMOutlook) {http="<[owm_test:120000:JSONPATH($.value)]"}
Number owm_localCurrentWindchill "Current Windchill [%.1f °C]" <windchill1> (gOWM,gOWMOutlook) // Value calculated via Rule "Windchill_Calculate"
//String localCurrentDummy "---------------------------------------" <clouds> (gOWM)
DateTime localHourlyForecast3Timestamp "Timestamp in 03 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#time-stamp" }
Image localHourlyForecast3ConditionIcon "Icon" (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#icon" }
Number:Temperature localHourlyForecast3Temperature "Temperature in 03 hours [%.1f %unit%]" <temperature> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#temperature" }
String localHourlyForecast3Condition "Condition in 03 hours [%s]" <pic600> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#condition" }
Number:Pressure localHourlyForecast3Pressure "in 03 hours barometric pressure [%.1f %unit%]" <pressure> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#pressure" }
Number:Dimensionless localHourlyForecast3Humidity "in 03 hours atmospheric humidity [%d %unit%]" <humidity> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#humidity" }
Number:Speed localHourlyForecast3WindSpeed "in 03 hours wind speed [%.1f km/h]" <wind> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#wind-speed" }
Number:Angle localHourlyForecast3WindDirection "in 03 hours wind direction [%d %unit%]" <wind> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#wind-direction" }
Number:Length localHourlyForecast3RainVolume "in 03 hours rain volume [%.1f %unit%]" <rain> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#rain" }
Number:Length localHourlyForecast3SnowVolume "in 03 hours snow volume [%.1f %unit%]" <snow> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#snow" }
//Number:Length localHourlyForecast3GustSpeed "in 03 hours Gust Speed Windböen[%.1f %unit%]" <wind> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#wind-gust" }
Number:Dimensionless localHourlyForecast3Cloudiness "in 03 hours cloudiness [%d %unit%]" <cloudiness> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#cloudiness" }
String localHourlyForecast3ConditionId "Condition ID [%s]" <pic600> (gOWM,gOWMOutlook) { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#condition-id" }
Number owm_localHourlyForecast3Windchill "in 03 hours Windchill [%.1f °C]" <windchill1> (gOWM,gOWMOutlook) // Value calculated via Rule "Windchill_Calculate"
String localHourlyForecast3Dummy "---------------------------------------" <clouds> (gOWM)
DateTime localHourlyForecast6Timestamp "Timestamp in 06 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#time-stamp" }
Image localHourlyForecast6ConditionIcon "Icon" (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#icon" }
Number:Temperature localHourlyForecast6Temperature "Temperature in 06 hours [%.1f %unit%]" <temperature> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#temperature" }
String localHourlyForecast6Condition "Condition in 06 hours [%s]" <pic600> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#condition" }
Number:Pressure localHourlyForecast6Pressure "in 06 hours barometric pressure [%.1f %unit%]" <pressure> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#pressure" }
Number:Dimensionless localHourlyForecast6Humidity "in 06 hours atmospheric humidity [%d %unit%]" <humidity> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#humidity" }
Number:Speed localHourlyForecast6WindSpeed "in 06 hours wind speed [%.1f km/h]" <wind> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#wind-speed" }
Number:Angle localHourlyForecast6WindDirection "in 06 hours wind direction [%d %unit%]" <wind> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#wind-direction" }
Number:Length localHourlyForecast6RainVolume "in 06 hours rain volume [%.1f %unit%]" <rain> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#rain" }
Number:Length localHourlyForecast6SnowVolume "in 06 hours snow volume [%.1f %unit%]" <snow> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#snow" }
//Number:Length localHourlyForecast6GustSpeed "in 06 hours Gust Speed Windböen[%.1f %unit%]" <wind> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#wind-gust" }
Number:Dimensionless localHourlyForecast6Cloudiness "in 06 hours cloudiness [%d %unit%]" <cloudiness> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#cloudiness" }
String localHourlyForecast6ConditionId "Condition ID [%s]" <pic600> (gOWM) { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#condition-id" }
//String localHourlyForecast6Dummy "---------------------------------------" <clouds> (gOWM)
DateTime.....
Den kompletten Items-File hänge ich mal als Anhang dran.
Ausgehend von der aktuellen Messung (localLastMeasurement), ermittle ich zunächst das Datum für aktuell bis Tag 5 als Vergleichswert mit dem Zeitstempel der jeweiligen Messgruppe ( z.B. localHourlyForecast3Timestamp bzw. GenericItem tempItemTimestamp) um die zugehörigen Items bzw. deren Werte zuordnen zu können. Das sieht dann so aus:
Code: Alles auswählen
var day0 = new DateTime(localLastMeasurement.state.toString).toString("yyMMdd")
var day1 = new DateTime(localLastMeasurement.state.toString).plusDays(1).toString("yyMMdd")
var day2 = new DateTime(localLastMeasurement.state.toString).plusDays(2).toString("yyMMdd")
var day3 = new DateTime(localLastMeasurement.state.toString).plusDays(3).toString("yyMMdd")
var day4 = new DateTime(localLastMeasurement.state.toString).plusDays(4).toString("yyMMdd")
var day5 = new DateTime(localLastMeasurement.state.toString).plusDays(5).toString("yyMMdd")
Das ist die Basis für die Zuordnung in den sechs "If-Bedingungen", die ich oben ansatzweise skizziert habe. Diese laufen innerhalb einer "while-Schleife", mit der ich die jeweiligen Items dynamisch/generisch ermittle. Das sieht dann so aus:
Code: Alles auswählen
val imin = 0
val imax =120
while ((itemindex >=imin) && (itemindex <=imax)) // ++++ Reduce itemindex for testing, when working it is 120 (imax) or less as in Thing-Parameter --> forecastHours=xxx <-- ++++
{
//++++ Pointer-adresses for the dynamically generated items to get corresponding/generic item ***thx to @5iver and @rlkoshak for help***
var GenericItem tempItemTimestamp = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Timestamp") as GenericItem // ***thx to @5iver ***
var GenericItem tempItemTemperature = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Temperature") as GenericItem // ***thx to @5iver ***
var GenericItem tempItemRainVolume = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"RainVolume") as GenericItem // ***thx to @5iver ***
var GenericItem tempItemSnowVolume = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"SnowVolume") as GenericItem // ***thx to @5iver ***
if (tempItemTimestamp.state != NULL && itemindex <=imax) {
tmp_timestamp = new DateTime(tempItemTimestamp.state.toString).toString("yyMMdd") // create temporarily timestamp as needed -yyMMdd-
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++ Day 0 ++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (day0 == tmp_timestamp)
{ ........
Wenn die While-Schleife (und in ihr die If-Bedingungen) beendet ist, werden die ermittelten Werte noch ein bisschen weiterbearbeitet und für die Ausgabe aufbereitet.
Nun habe ich gedacht, ob man die in der While-Schleife laufenden If-Bedingungen optimieren kann, da der Ablauf immer der gleiche ist. Der Unterschied sind die verwendeten Variablen (day0 - day6).
In der While-Schleife ermittle ich den tatsächlichen Item-Namen über "GenericItem ". Gibt es so etwas auch für Variablen, oder geht das vielleicht über eine Lambda-Funktion (hört sich gut an, hab aber überhaupt keinen Plan wie das gehen könnte

).
So jetzt hab ich aber genug erzählt. Vielleicht fällt dir ja doch was ein. Wenn nicht, auch kein Problem.
Danke und Gruss - Peter