[SOLVED] DateTime Items compare against fixed DateTimes

thx. I tested the proposal of Scott.
But when I set free the day0-Constant the error comes up.

you are right. I changed the Rule to:

rule test_date2_owm
  when
   Item Dummy3 received command ON 
  then

  var day0String = localLastMeasurement.state.format("%1$tY%1$tm%1$td")
   logInfo ("owm.test_date1", " String-Item: " + day0String)
  val day0 = new DateTime.valueOf(localLastMeasurement.state.toString)
   logInfo ("owm.test_date1", "Current-Time-Item: " + day0.toString )
//  val day1String = day0String.plusDays(1).toString("yyMMdd")
//   logInfo ("owm.test_date1", "day 1 -Time-Item: " + day1String)
//  val day2String = day0.plusDays(2).toString("yyMMdd")
//   logInfo ("owm.test_date1", "day 2 -Time-Item: " + day2String)
end
2018-12-04 14:04:26.886 [INFO ] [marthome.model.script.owm.test_date1] -  String-Item: 20181204
2018-12-04 14:04:26.890 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'test_date2_owm': 'plusDays' is not a member of 'org.eclipse.smarthome.core.library.items.DateTimeItem'; line 12, column 20, length 32

Do you have a proper definition for me?:wink:

See my previous post


Sorry i’m a silly fool, didn’t see the forest for the trees. Now it works excellent.

This is a further step to my goal.
thx to you all @5iver, @vzorglub, @rlkoshak

Can you post your working code, thanks

Hi, @vzorglub,
i will do this as fast as i can.
At the moment i solved the problem of DateTime with the help of all of you.
Now im beginning to create the rest of the rule. Pls give me a while as I’m an old man :older_man:, and of course no programming specialist.
thx for your interest, i keep you informed.

Hi, all @vzorglub @5iver @rlkoshak
thought i have it. But i’m in trouble with a command:

tempItemTemperature.addGroupName("gTemp_day0")   //dynamic item-name brings the error

This is the rule:

import org.eclipse.smarthome.model.script.ScriptServiceUtil
  var dayindex = 0  // day index
  var dcountindex = 0 // items a day
  var sum_temp_curr =0
 
rule owmSummarize_test
  when
   Item Dummy3 received command ON  or
   Item localLastMeasurement changed
  then
//++++ initial variables for the "while"-loop ++++
   var itemindex = 3 //item index
   var itemincrement  = 3 //item step
//++++ initial variables for daily maximum if-loops = 8
   var count_day0 = 1
	 var count_day1 = 1
	 var count_day2 = 1
	 var count_day3 = 1
	 var count_day4 = 1
	 var count_day5 = 1
	 
	 
//++++ initialize daily forecastvariables from day0(totay) to day5 to compare in the "if"-loops ++++           ***thx to @5iver and @vzorglub for help***
//++++ https://community.openhab.org/t/datetime-items-compare-against-fixed-datetimes/58615     ++++
   var day0 = new DateTime(localLastMeasurement.state.toString).toString("yyMMdd")
   logInfo ("owm.rules start", "day 0-Time-Item: {}", day0)
   
   var day1 = new DateTime(localLastMeasurement.state.toString).plusDays(1).toString("yyMMdd")
   logInfo ("owm.rules", "day 1-Time-Item: {}", day1)
   
   var day2 = new DateTime(localLastMeasurement.state.toString).plusDays(2).toString("yyMMdd")
   logInfo ("owm.rules", "day 2-Time-Item: {}", day2)
   
   var day3 = new DateTime(localLastMeasurement.state.toString).plusDays(3).toString("yyMMdd")
   logInfo ("owm.rules", "day 3-Time-Item: {}", day3)
   
   var day4 = new DateTime(localLastMeasurement.state.toString).plusDays(4).toString("yyMMdd")
   logInfo ("owm.rules", "day 4-Time-Item: {}", day4)
   
   var day5 = new DateTime(localLastMeasurement.state.toString).plusDays(5).toString("yyMMdd")
   logInfo ("owm.rules", "day 5-Time-Item: {}", day5)


  while (itemindex >=0 && itemindex <=16)     //  ++++ Endpoint is set to 16 for testing, when working it is 120 ++++
  {
   logInfo("owm.rules","Item-Index {}", itemindex)
//++++ Pointer-adresses for the dynamically generated items to get corresponding item                           ***thx to @5iver and @rlkoshak for help***
   var tempItemTimestamp = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Timestamp")
   logInfo("owm.rules","tempItemTimestamp: " + tempItemTimestamp)   // original item is shown
   var tempItemTemperature = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Temperature")
   logInfo("owm.rules","tempItemTemperature: " + tempItemTemperature)  // original item is shown
   var tmp_timestamp = new DateTime(tempItemTimestamp.state.toString).toString("yyMMdd") // create temporarily timestamp as needed -yyMMdd-
   //logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp)  // timestamp is shown as needed
   
   if (day0 == tmp_timestamp)  // an additional oparator can be used ( && count_day0 <= 8)
   {
     logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp + " Group should be gTemp_day0 ") // only check if correct timestamp for day0 is passed.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++ next lines are only for test with three items and item-names are manually set to see if addGroupName works
//     localHourlyForecast3Temperature.addGroupName("gTemp_day0")        // only for test if dynamic Group - addGroupName works (with a named item from owm.items it works)
//     logInfo ("owm.rules", "today " + localHourlyForecast3Temperature)    // only for test if dynamic Group  addGroupName works (with a named item from owm.items it works)
//     localHourlyForecast6Temperature.addGroupName("gTemp_day0")        // only for test if dynamic Group - addGroupName works (with a named item from owm.items it works)
//     logInfo ("owm.rules", "today " + localHourlyForecast6Temperature)    // only for test if dynamic Group  addGroupName works (with a named item from owm.items it works)
//     localHourlyForecast9Temperature.addGroupName("gTemp_day0")        // only for test if dynamic Group - addGroupName works (with a named item from owm.items it works)
//     logInfo ("owm.rules", "today " + localHourlyForecast9Temperature)    // only for test if dynamic Group  addGroupName works (with a named item from owm.items it works)
//++++ there is still a problem when removing the group fro the item, it seems still to be shown in the sitemap +++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++ This is the part which doesn't work as i want to work  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     tempItemTemperature.addGroupName("gTemp_day0")            //dynamic item-name brings the error
     logInfo ("owm.rules", "today " + tempItemTemperature)     //dynamic item-name brings the error
     itemindex = itemindex + itemincrement
     count_day0 = count_day0 + 1
   }
   if (day1 == tmp_timestamp)  // an additional oparator can be used ( && count_day1 <= 8)
   {
     logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp + " Group should be gTemp_day1 ")
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++ next lines are only for test with three items and item-names are manually set to see if addGroupName works
//     localHourlyForecast3Temperature.addGroupName("gTemp_day1")        // only for test if dynamic Group - addGroupName works (with a named item from owm.items it works)
//     logInfo ("owm.rules", "tomorrow " + localHourlyForecast3Temperature)    // only for test if dynamic Group  addGroupName works (with a named item from owm.items it works)
//     localHourlyForecast6Temperature.addGroupName("gTemp_day1")        // only for test if dynamic Group - addGroupName works (with a named item from owm.items it works)
//     logInfo ("owm.rules", "tomorrow " + localHourlyForecast6Temperature)    // only for test if dynamic Group  addGroupName works (with a named item from owm.items it works)
//     localHourlyForecast9Temperature.addGroupName("gTemp_day1")        // only for test if dynamic Group - addGroupName works (with a named item from owm.items it works)
//     logInfo ("owm.rules", "tomorrow " + localHourlyForecast9Temperature)    // only for test if dynamic Group  addGroupName works (with a named item from owm.items it works)
//++++ there is still a problem when removing the group fro the item, it seems still to be shown in the sitemap +++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++ This is the part which doesn't work as i want to work  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//     tempItemTemperature.addGroupName("gTemp_day1")            //dynamic item-name brings the error
     logInfo ("owm.rules", "tomorrow " + tempItemTemperature)  //dynamic item-name brings the error
     itemindex = itemindex + itemincrement
     count_day1 = count_day1 + 1
   }
   if (day2 == tmp_timestamp)  // an additional oparator can be used ( && count_day1 <= 8)
   {
     logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp + " Group should be gTemp_day2 ")
//     tempItemTemperature.addGroupName("gTemp_day2")            //dynamic item-name brings the error
     logInfo ("owm.rules", "tomorrow " + tempItemTemperature)  //dynamic item-name brings the error
     itemindex = itemindex + itemincrement
     count_day1 = count_day2 + 1
   }
   if (day3 == tmp_timestamp)  // an additional oparator can be used ( && count_day1 <= 8)
   {
     logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp + " Group should be gTemp_day3 ")
//     tempItemTemperature.addGroupName("gTemp_day3")            //dynamic item-name brings the error
     logInfo ("owm.rules", "tomorrow " + tempItemTemperature)  //dynamic item-name brings the error
     itemindex = itemindex + itemincrement
     count_day1 = count_day3 + 1
   }
   if (day4 == tmp_timestamp)  // an additional oparator can be used ( && count_day1 <= 8)
   {
     logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp + " Group should be gTemp_day4 ")
//     tempItemTemperature.addGroupName("gTemp_day4")            //dynamic item-name brings the error
     logInfo ("owm.rules", "tomorrow " + tempItemTemperature)  //dynamic item-name brings the error
     itemindex = itemindex + itemincrement
     count_day1 = count_day4 + 1
   }
//++++ This if-Statement is normally not needed it's just for check if all counts are correct ++++++++++
   if (day5 == tmp_timestamp)  // an additional oparator can be used ( && count_day1 <= 8)
   {
     logInfo("owm.rules","tmp_timestamp: " + tmp_timestamp + " Group should be gTemp_day5 ")
//     tempItemTemperature.addGroupName("gTemp_day5")            //dynamic item-name brings the error
     logInfo ("owm.rules", "tomorrow " + tempItemTemperature)  //dynamic item-name brings the error
     itemindex = itemindex + itemincrement
     count_day1 = count_day5 + 1
   }

 }
   logInfo ("owm.owm.rules end", "Ende:  " + itemindex + " :Schrittweite:  " + itemincrement)
end

Looks like a lot of stuff, but most of it, is explanation and logInfo.

When usung the above command, i get the following error:

2018-12-06 01:47:22.021 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'owm.rules'
2018-12-06 01:47:34.789 [INFO ] [arthome.model.script.owm.rules start] - day 0-Time-Item: 181206
2018-12-06 01:47:34.795 [INFO ] [pse.smarthome.model.script.owm.rules] - day 1-Time-Item: 181207
2018-12-06 01:47:34.802 [INFO ] [pse.smarthome.model.script.owm.rules] - day 2-Time-Item: 181208
2018-12-06 01:47:34.808 [INFO ] [pse.smarthome.model.script.owm.rules] - day 3-Time-Item: 181209
2018-12-06 01:47:34.814 [INFO ] [pse.smarthome.model.script.owm.rules] - day 4-Time-Item: 181210
2018-12-06 01:47:34.821 [INFO ] [pse.smarthome.model.script.owm.rules] - day 5-Time-Item: 181211
2018-12-06 01:47:34.827 [INFO ] [pse.smarthome.model.script.owm.rules] - Item-Index 3
2018-12-06 01:47:34.833 [INFO ] [pse.smarthome.model.script.owm.rules] - tempItemTimestamp: localHourlyForecast3Timestamp (Type=DateTimeItem, State=2018-12-06T04:00:00.000+0100, Label=Timestamp in 03 hours, Category=time, Groups=[gOWM])
2018-12-06 01:47:34.838 [INFO ] [pse.smarthome.model.script.owm.rules] - tempItemTemperature: localHourlyForecast3Temperature (Type=NumberItem, State=5.11 °C, Label=Temperature in 03 hours, Category=temperature, Groups=[gOWM])
2018-12-06 01:47:34.845 [INFO ] [pse.smarthome.model.script.owm.rules] - tmp_timestamp: 181206 Group should be gTemp_day0 
2018-12-06 01:47:34.848 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'owmSummarize_test': 'addGroupName' is not a member of 'org.eclipse.smarthome.core.items.Item'; line 71, column 6, length 46

It seems as if the Pointer-Item (hope this is correct) tempItemTemperature has problems with this kind of addGroup-Method. But in the logger, two lines before the ERROR the correct Item is shown tempItemTemperature: localHourlyForecast3Temperature (Type=NumberItem, State=5.11 °C, Label=Temperature in 03 hours, Category=temperature, Groups=[gOWM])

Part of owm.items:

Group                gOWM
Group:Number:Temperature:AVG     gTemp_day0                  "Ø-Temperature today [%.1f %unit%]"                                          (gOWM)
Group:Number:Temperature:AVG     gTemp_day1                  "Ø-Temperature tomorrow [%.1f %unit%]"                                       (gOWM)
Group:Number:Temperature:AVG     gTemp_day2                  "Ø-Temperature in 2 days [%.1f %unit%]"                                      (gOWM)
Group:Number:Temperature:AVG     gTemp_day3                  "Ø-Temperature in 3 days [%.1f %unit%]"                                      (gOWM)
Group:Number:Temperature:AVG     gTemp_day4                  "Ø-Temperature in 4 days [%.1f %unit%]"                                      (gOWM)
Group:Number:Temperature:AVG     gTemp_day5                  "Ø-Temperature in 5 days [%.1f %unit%]"                                      (gOWM)
//Group:Number:Temperature:AVG     gTemp_test                  "Ø-Temperature Test [%.1f %unit%]"                                           (gOWM)


//String               localStationId                          "Orts-Nr. [%s]"                                                            (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:station#id" }
String               localStationName                        "Ort [%s]"                                                                  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:station#name" }
Location             localStationLocation                    "Koordinaten [%2$s°N %3$s°E]"                                 <location>     (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:station#location" }
                                                             
DateTime             localLastMeasurement                    "Timestamp of last measurement [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]"<time> (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#time-stamp" }
                                                             
Image                localCurrentConditionIcon               "Icon"                                                                       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#icon" }
Number:Temperature   localCurrentTemperature                 "Current temperature [%.1f %unit%]"                           <temperature>  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#temperature" }
String               localCurrentCondition                   "Current condition [%s]"                                      <sun_clouds>   (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#condition" }
Number:Pressure      localCurrentPressure                    "Current barometric pressure [%.1f %unit%]"                   <pressure>     (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#pressure" }
Number:Dimensionless localCurrentHumidity                    "Current atmospheric humidity [%d %unit%]"                    <humidity>     (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#humidity" }
Number:Speed         localCurrentWindSpeed                   "Current wind speed [%.1f km/h]"                              <wind>         (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#wind-speed" }
Number:Angle         localCurrentWindDirection               "Current wind direction [%d %unit%]"                          <wind>         (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }
Number:Length        localCurrentRainVolume                  "Current rain volume [%.1f %unit%]"                           <rain>         (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#rain" }
Number:Length        localCurrentSnowVolume                  "Current snow volume [%.1f %unit%]"                           <snow>         (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#snow" }
Number:Length        localCurrentGustSpeed                   "Current Gust Speed Windböen[%.1f %unit%]"                    <wind>         (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#wind-gust" }
Number:Dimensionless localCurrentCloudiness                  "Current cloudiness [%d %unit%]"                              <cloudiness>   (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#cloudiness" }
String               localCurrentConditionID                 "Current condition ID[%s]"                                    <pic803>       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:current#condition-id" }
String               localCurrentDummy                       "---------------------------------------"                     <clouds>       (gOWM)
DateTime             localHourlyForecast3Timestamp           "Timestamp in 03 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#time-stamp" }
Image                localHourlyForecast3ConditionIcon       "Icon"                                                                       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#icon" }
Number:Temperature   localHourlyForecast3Temperature         "Temperature in 03 hours [%.1f %unit%]"                        <temperature> (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#temperature" }

String               localHourlyForecast3Condition           "Condition in 03 hours [%s]"                                   <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#condition" }
Number:Pressure      localHourlyForecast3Pressure            "in 03 hours barometric pressure [%.1f %unit%]"                <pressure>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#pressure" }
Number:Dimensionless localHourlyForecast3Humidity            "in 03 hours atmospheric humidity [%d %unit%]"                 <humidity>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#humidity" }
Number:Speed         localHourlyForecast3WindSpeed           "in 03 hours wind speed [%.1f km/h]"                           <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#wind-speed" }
Number:Angle         localHourlyForecast3WindDirection       "in 03 hours wind direction [%d %unit%]"                       <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#wind-direction" }
Number:Length        localHourlyForecast3RainVolume          "in 03 hours rain volume [%.1f %unit%]"                        <rain>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#rain" }
Number:Length        localHourlyForecast3SnowVolume          "in 03 hours snow volume [%.1f %unit%]"                        <snow>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#snow" }
Number:Length        localHourlyForecast3GustSpeed           "in 03 hours Gust Speed Windböen[%.1f %unit%]"                 <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#wind-gust" }
Number:Dimensionless localHourlyForecast3Cloudiness          "in 03 hours cloudiness [%d %unit%]"                           <cloudiness>  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#cloudiness" }
String               localHourlyForecast3ConditionId         "Condition ID [%s]"                                            <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours03#condition-id" }
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             localHourlyForecast9Timestamp           "Timestamp in 09 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#time-stamp" }
Image                localHourlyForecast9ConditionIcon       "Icon"                                                                       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#icon" }
Number:Temperature   localHourlyForecast9Temperature         "Temperature in 09 hours [%.1f %unit%]"                        <temperature> (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#temperature" }
String               localHourlyForecast9Condition           "Condition in 09 hours [%s]"                                   <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#condition" }
Number:Pressure      localHourlyForecast9Pressure            "barometric pressure in 09 hours [%.1f %unit%]"                <pressure>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#pressure" }
Number:Dimensionless localHourlyForecast9Humidity            "atmospheric humidity in 09 hours [%d %unit%]"                 <humidity>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#humidity" }
Number:Speed         localHourlyForecast9WindSpeed           "wind speed in 09 hours [%.1f km/h]"                           <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#wind-speed" }
Number:Angle         localHourlyForecast9WindDirection       "wind direction in 09 hours [%d %unit%]"                       <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#wind-direction" }
Number:Length        localHourlyForecast9RainVolume          "rain volume in 09 hours [%.1f %unit%]"                        <rain>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#rain" }
Number:Length        localHourlyForecast9SnowVolume          "snow volume in 09 hours [%.1f %unit%]"                        <snow>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#snow" }
Number:Length        localHourlyForecast9GustSpeed           "Gust Speed Windböen in 09 hours [%.1f %unit%]"                <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#wind-gust" }
Number:Dimensionless localHourlyForecast9Cloudiness          "cloudiness in 09 hours [%d %unit%]"                           <cloudiness>  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#cloudiness" }
String               localHourlyForecast9ConditionId         "Condition ID in 09 hours [%s]"                                <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours09#condition-id" }
String               localHourlyForecast9Dummy               "---------------------------------------"                      <clouds>      (gOWM)


DateTime             localHourlyForecast12Timestamp          "Timestamp in 12 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#time-stamp" }
Image                localHourlyForecast12ConditionIcon      "Icon"                                                                       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#icon" }
Number:Temperature   localHourlyForecast12Temperature        "Temperature in 12 hours [%.1f %unit%]"                        <temperature> (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#temperature" }
String               localHourlyForecast12Condition          "Condition in 12 hours [%s]"                                   <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#condition" }
Number:Pressure      localHourlyForecast12Pressure           "barometric pressure in 12 hours [%.1f %unit%]"                <pressure>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#pressure" }
Number:Dimensionless localHourlyForecast12Humidity           "atmospheric humidity in 12 hours [%d %unit%]"                 <humidity>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#humidity" }
Number:Speed         localHourlyForecast12WindSpeed          "wind speed in 12 hours [%.1f km/h]"                           <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#wind-speed" }
Number:Angle         localHourlyForecast12WindDirection      "wind direction in 12 hours [%d %unit%]"                       <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#wind-direction" }
Number:Length        localHourlyForecast12RainVolume         "rain volume in 12 hours [%.1f %unit%]"                        <rain>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#rain" }
Number:Length        localHourlyForecast12SnowVolume         "snow volume in 12 hours [%.1f %unit%]"                        <snow>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#snow" }
Number:Length        localHourlyForecast12GustSpeed          "Gust Speed Windböen in 12 hours [%.1f %unit%]"                <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#wind-gust" }
Number:Dimensionless localHourlyForecast12Cloudiness         "cloudiness in 12 hours [%d %unit%]"                           <cloudiness>  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#cloudiness" }
String               localHourlyForecast12ConditionId        "Condition ID in 12 hours [%s]"                                <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours12#condition-id" }
String               localHourlyForecast12Dummy              "---------------------------------------"                      <clouds>      (gOWM)
                                                             
DateTime             localHourlyForecast15Timestamp          "Timestamp in 15 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#time-stamp" }
Image                localHourlyForecast15ConditionIcon      "Icon"                                                                       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#icon" }
Number:Temperature   localHourlyForecast15Temperature        "Temperature in 15 hours [%.1f %unit%]"                        <temperature> (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#temperature" }
String               localHourlyForecast15Condition          "Condition in 15 hours [%s]"                                   <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#condition" }
Number:Pressure      localHourlyForecast15Pressure           "barometric pressure in 15 hours [%.1f %unit%]"                <pressure>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#pressure" }
Number:Dimensionless localHourlyForecast15Humidity           "atmospheric humidity in 15 hours [%d %unit%]"                 <humidity>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#humidity" }
Number:Speed         localHourlyForecast15WindSpeed          "wind speed in 15 hours [%.1f km/h]"                           <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#wind-speed" }
Number:Angle         localHourlyForecast15WindDirection      "wind direction in 15 hours [%d %unit%]"                       <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#wind-direction" }
Number:Length        localHourlyForecast15RainVolume         "rain volume in 15 hours [%.1f %unit%]"                        <rain>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#rain" }
Number:Length        localHourlyForecast15SnowVolume         "snow volume in 15 hours [%.1f %unit%]"                        <snow>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#snow" }
Number:Length        localHourlyForecast15GustSpeed          "Gust Speed Windböen in 15 hours [%.1f %unit%]"                <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#wind-gust" }
Number:Dimensionless localHourlyForecast15Cloudiness         "cloudiness in 15 hours [%d %unit%]"                           <cloudiness>  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#cloudiness" }
String               localHourlyForecast15ConditionId        "Condition ID in 15 hours [%s]"                                <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours15#condition-id" }
String               localHourlyForecast15Dummy              "---------------------------------------"                      <clouds>      (gOWM)
                                                             
DateTime             localHourlyForecast18Timestamp          "Timestamp in 18 hours [%1$ta, %1$ty-%1$tm-%1$td %1$tH:%1$tM]" <time>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#time-stamp" }
Image                localHourlyForecast18ConditionIcon      "Icon"                                                                       (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#icon" }
Number:Temperature   localHourlyForecast18Temperature        "Temperature in 18 hours [%.1f %unit%]"                        <temperature> (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#temperature" }
String               localHourlyForecast18Condition          "Condition in 18 hours [%s]"                                   <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#condition" }
Number:Pressure      localHourlyForecast18Pressure           "barometric pressure in 18 hours [%.1f %unit%]"                <pressure>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#pressure" }
Number:Dimensionless localHourlyForecast18Humidity           "atmospheric humidity in 18 hours [%d %unit%]"                 <humidity>    (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#humidity" }
Number:Speed         localHourlyForecast18WindSpeed          "wind speed in 18 hours [%.1f km/h]"                           <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#wind-speed" }
Number:Angle         localHourlyForecast18WindDirection      "wind direction in 18 hours [%d %unit%]"                       <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#wind-direction" }
Number:Length        localHourlyForecast18RainVolume         "rain volume in 18 hours [%.1f %unit%]"                        <rain>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#rain" }
Number:Length        localHourlyForecast18SnowVolume         "snow volume in 18 hours [%.1f %unit%]"                        <snow>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#snow" }
Number:Length        localHourlyForecast18GustSpeed          "Gust Speed Windböen in 18 hours [%.1f %unit%]"                <wind>        (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#wind-gust" }
Number:Dimensionless localHourlyForecast18Cloudiness         "cloudiness in 18 hours [%d %unit%]"                           <cloudiness>  (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#cloudiness" }
String               localHourlyForecast18ConditionId        "Condition ID in 18 hours [%s]"                                <pic600>      (gOWM)              { channel="openweathermap:weather-and-forecast:api:local:forecastHours18#condition-id" }
String               localHourlyForecast18Dummy              "---------------------------------------"                      <clouds>      (gOWM)
                                                             

If you like to have the complete item-set i can post it.
Any hints or tips are welcome.

maybe this is a problem which is still not fixed.

To add a item to a group I use two lines of code:

                group.addMember(item.getName())
                item.addGroupName(group.getName())

Without both I see inconsistence in the group membership. You can check this by looking at the group membership from the point of the group and of the item.

group.getMembers
item.getGroupNames
1 Like

addGroupName is a method of GenericItem, but ScriptServiceUtil returns Item. You’ll need to do a conversion


var GenericItem tempItemTimestamp = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Timestamp") as GenericItem
2 Likes

Hi, @5iver,
changed it as you described, to
var GenericItem tempItemTemperature = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Temperature") as GenericItem
Now works perfectly. :+1::+1::+1:

But next problem comes up when tryin to remove all items from the groups(e.g. “gTemp_day5”)

I tried: gTemp_day5.removeUsers(ALL) and gTemp_day5.deleteMembers(ALL) and gTemp_day5.removeMembers(ALL), but always got this errors.

2018-12-06 14:36:39.096 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'owm.rules'
2018-12-06 14:37:04.803 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'owm_removeGroup_test': 'removeMembers' is not a member of 'org.eclipse.smarthome.core.items.GroupItem'; line 142, column 3, length 29
2018-12-06 14:42:04.834 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'owm.rules'
2018-12-06 14:42:33.313 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'owm_removeGroup_test': 'deleteMembers' is not a member of 'org.eclipse.smarthome.core.items.GroupItem'; line 142, column 3, length 29
2018-12-06 14:44:22.705 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'owm.rules'
2018-12-06 14:44:37.828 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'owm_removeGroup_test': 'removeUsers' is not a member of 'org.eclipse.smarthome.core.items.GroupItem'; line 142, column 3, length 27

i’m desperate :confused::confused:

I could give you the answer, but I’d rather show you how to find it yourself :wink:. Go to the ESH repo, then search for GroupItem.java, select that file in the results, select the master branch, and then read the methods provided. A simpler way is to use VS Code with the OH extension and LSP enabled, then typing in gTemp_day5. (note the period) will display all available methods. Hint: removeMembers is not a valid method.

Once you’ve found your answer, you may want to consider iterating over the group members and removing the group from each of them.

To add to what @5iver has said regarding on-the-fly (dynamic) control of group membership, I would add that in the code and rules I use, I have found that it may be better to first remove the group from each member item’s list of groups to which it belongs before removing the member items from the GroupItems. I do this with JSR223 Jython, but the methods used are from the GenericItem and GroupItem ESH java classes, so the techniques should be the same using DSL rules.

[Update]
This thread has wandered off of the original topic, it might be best to start a new thread to discuss dynamic control of group membership.

Did you find that you needed to do both? I used this in my rules a while back and only used GroupItem.addMember/removeMember, and the items’ group membership were being properly updated. I no longer do this, so maybe it has changed.

I haven’t fiddled with it for some time, but it is possible that there was some delay after removing the group from each member item before the member items were removed from the group.

I have a simple script that iterates over all items, listing member items when group items are encountered. When running this script I discovered what I considered to be dangling group-member relationships. That discovery led me to take the two-pronged approach to removing member items from groups.

Maybe after removing the group from a member item’s list of groups, checking the list of the group item’s members for the presence of that member item would help determine whether or not it is necessary to remove the member item from the group.

1 Like

thx, a lot for your help up to this point. But it seems, i even have problems to find the wiki for the provided methods in the ESH repo. When using your hyperlink i come up here:

and when selecting “In this repository” or the other i can’t find a master branch. I only see this:

So for the moment this is bit to much stuff to learn and understand for me. I’m even too stupid to find a simple website.
I will put the project aside for a while as i think it’s a bit to big for me.

In your second image, select the GroupItem.java file to view it, from there you can select the branch. Don’t give up yet
 you’re real close!

[psst
 the method you’re looking for is in my last post :smile: ]

2 Likes

The moment of frustration was very short. Cry Uncle ? Never :stuck_out_tongue_winking_eye:
As i have no experience in Programming Languages like Java/DSL. it’s sometimes hard for me to understand what is meant and transpose it.
And when thinking about the target i want to reach , I came back to my first idea to realize the aggregation and additions make with a bit of code. Said it, did it.

This is my working Rule:

import org.eclipse.smarthome.model.script.ScriptServiceUtil
  var dayindex = 0  // day index
  var dcountindex = 0 // items a day
  var sum_temp_curr =0
 
rule owmSummarize_test
  when
   Item Dummy3 received command ON  or
   Item localLastMeasurement changed
  then
//++++ initial variables for the "while"-loop ++++
   var itemindex = 3 //item index
   var itemincrement  = 3 //item step
//++++ initial variables for daily if-loops as divisor
   var count_day0 = 0
   var count_day1 = 0
   var count_day2 = 0
   var count_day3 = 0
   var count_day4 = 0
   var count_day5 = 0
//++++ Temperature Results for the days
   val celsius = -273.15  // tricky Constant which represents the °C in the Itemstate (UoM)
   var Number sum_temp_day0 = 0
   var Number sum_temp_day1 = 0
   var Number sum_temp_day2 = 0
   var Number sum_temp_day3 = 0
   var Number sum_temp_day4 = 0
   var Number sum_temp_day5 = 0
   var Number avg_temp_day0 = 0
   var Number avg_temp_day1 = 0
   var Number avg_temp_day2 = 0
   var Number avg_temp_day3 = 0
   var Number avg_temp_day4 = 0
   var Number avg_temp_day5 = 0
/*+++++ for daily MIN/MAX Temperature-Values (not used yet)
   var Number min_temp_day0 = 999.9
   var Number min_temp_day1 = 999.9
   var Number min_temp_day2 = 999.9
   var Number min_temp_day3 = 999.9
   var Number min_temp_day4 = 999.9
   var Number min_temp_day5 = 999.9
   var Number max_temp_day0 = -999.9
   var Number max_temp_day1 = -999.9
   var Number max_temp_day2 = -999.9
   var Number max_temp_day3 = -999.9
   var Number max_temp_day4 = -999.9
   var Number max_temp_day5 = -999.9
	 */

   
//++++ initialize daily forecastvariables from day0(totay) to day5 to compare in the "if"-loops ++++           ***thx to @5iver and @vzorglub for help***
//++++ https://community.openhab.org/t/datetime-items-compare-against-fixed-datetimes/58615     ++++
   logInfo ("owm.rules start", "localLastMeasurement: {}", localLastMeasurement.state.toString)
   var day0 = new DateTime(localLastMeasurement.state.toString).toString("yyMMdd")
   logInfo ("owm.rules start", "day 0-Time-Item: {}", day0)
   
   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")
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++             Processing              ++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  while (itemindex >=0 && itemindex <=120)     //  ++++ Change itemindex for testing, when working it is 120 ++++
  {
//++++ Pointer-adresses for the dynamically generated items to get corresponding/generic item                           ***thx to @5iver and @rlkoshak for help***
   var tempItemTimestamp = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Timestamp")
   var GenericItem tempItemTemperature = ScriptServiceUtil.getItemRegistry.getItem("localHourlyForecast"+itemindex+"Temperature") as  GenericItem  // ***thx to @5iver ***
   var tmp_timestamp = new DateTime(tempItemTimestamp.state.toString).toString("yyMMdd") // create temporarily timestamp as needed -yyMMdd-
   
   if (day0 == tmp_timestamp)
   {
     itemindex = itemindex + itemincrement
     count_day0 = count_day0 + 1
     sum_temp_day0 = sum_temp_day0 + tempItemTemperature.state + celsius
   }
   if (day1 == tmp_timestamp)
   {
     itemindex = itemindex + itemincrement
     count_day1 = count_day1 + 1
     sum_temp_day1 = sum_temp_day1 + tempItemTemperature.state + celsius
   }
   if (day2 == tmp_timestamp)
   {
     itemindex = itemindex + itemincrement
     count_day2 = count_day2 + 1
     sum_temp_day2 = sum_temp_day2 + tempItemTemperature.state + celsius
   }
   if (day3 == tmp_timestamp)
   {
     itemindex = itemindex + itemincrement
     count_day3 = count_day3 + 1
     sum_temp_day3 = sum_temp_day3 + tempItemTemperature.state + celsius
   }
   if (day4 == tmp_timestamp)
   {
     itemindex = itemindex + itemincrement
     count_day4 = count_day4 + 1
     sum_temp_day4 = sum_temp_day4 + tempItemTemperature.state + celsius
   }
   if (day5 == tmp_timestamp)
   {
     itemindex = itemindex + itemincrement
     count_day5 = count_day5 + 1
     sum_temp_day5 = sum_temp_day5 + tempItemTemperature.state + celsius
   }

 }
//++++++++++++++++++ Check Division by zero and calculate Average ++++++++++++++++++++++++++++
   if (sum_temp_day0 != 0 && count_day0 != 0) avg_temp_day0 = sum_temp_day0 / count_day0
   if (sum_temp_day1 != 0 && count_day1 != 0) avg_temp_day1 = sum_temp_day1 / count_day1
   if (sum_temp_day2 != 0 && count_day2 != 0) avg_temp_day2 = sum_temp_day2 / count_day2
   if (sum_temp_day3 != 0 && count_day3 != 0) avg_temp_day3 = sum_temp_day3 / count_day3
   if (sum_temp_day4 != 0 && count_day4 != 0) avg_temp_day4 = sum_temp_day4 / count_day4
   if (sum_temp_day5 != 0 && count_day5 != 0) avg_temp_day5 = sum_temp_day5 / count_day5
//++++++++++++++++ Update Items in owm.items +++++++++++++++++++++++++++++++++++++++++++++++++
   localDay0TemperatureAverage.postUpdate(avg_temp_day0)
   localDay1TemperatureAverage.postUpdate(avg_temp_day1)
   localDay2TemperatureAverage.postUpdate(avg_temp_day2)
   localDay3TemperatureAverage.postUpdate(avg_temp_day3)
   localDay4TemperatureAverage.postUpdate(avg_temp_day4)
   localDay5TemperatureAverage.postUpdate(avg_temp_day5)
//+++++++++++++++ Formatting and Updating Forecast Stringitems in owm.items ++++++++++++++++++++
   var day0_format = new DateTime(localLastMeasurement.state.toString).toString("EE, yyyy-MM-dd")
   var day1_format = new DateTime(localLastMeasurement.state.toString).plusDays(1).toString("EE, yyyy-MM-dd")
   var day2_format = new DateTime(localLastMeasurement.state.toString).plusDays(2).toString("EE, yyyy-MM-dd")
   var day3_format = new DateTime(localLastMeasurement.state.toString).plusDays(3).toString("EE, yyyy-MM-dd")
   var day4_format = new DateTime(localLastMeasurement.state.toString).plusDays(4).toString("EE, yyyy-MM-dd")
   var day5_format = new DateTime(localLastMeasurement.state.toString).plusDays(5).toString("EE, yyyy-MM-dd")
//+++++++++++++++++  Concatenate for sitemap ++++++++++++++++++++++++++++++++++++++++++++++++++
   owmForecast_0Temp.postUpdate(day0_format + " " + localDay0TemperatureAverage.state.format("%.1f").toString)
   owmForecast_1Temp.postUpdate(day1_format + " " + localDay1TemperatureAverage.state.format("%.1f").toString)
   owmForecast_2Temp.postUpdate(day2_format + " " + localDay2TemperatureAverage.state.format("%.1f").toString)
   owmForecast_3Temp.postUpdate(day3_format + " " + localDay3TemperatureAverage.state.format("%.1f").toString)
   owmForecast_4Temp.postUpdate(day4_format + " " + localDay4TemperatureAverage.state.format("%.1f").toString)
   owmForecast_5Temp.postUpdate(day5_format + " " + localDay5TemperatureAverage.state.format("%.1f").toString)


   logInfo ("owm.owm.rules end", "Ende:  Index: " + itemindex + " :Inkrement:  " + itemincrement + " Day  " + day0_format)

end

There is a little trick i used to summarize the Temperature-Items, as they have the Measurement-Sign in the Item-State. I used a constant (celsius = -273.15) in my calculations.(I didn’t find a Filter. But this doesn’t work with Pressure-Items). It’s not professional Code, it’s a kind of spaghetti-code, but it works.

I’m thinking about undoing UoM in my .items-file and bring it to the sitemap, for easier calculations. But not forgetting the hints, you gave me in your last post and try it. I would like to study them and learn from.

thx again, Peter

EDIT:
Result looks like this:

1 Like

thx for hints.

Hi @scottk. What kind of script is this ? Can you post it ?

The following link is to my post on the thread [JSR223-Jython] Simplified rule definition (similar to Rules DSL) and universal decorator where I described the script in question.

1 Like