Group:DateTime:MIN not displayed in sitemap

  • Platform information:
    • Hardware: RaspberryPi 3b
    • openHAB version:
  • Issue of the topic: please be detailed explaining your issue
    I have a problem with my DateTime group item.
    I want to display the oldest value of sensor updates.
    The members of the group are updated rule based.
    All members in the sitemap are displayed correctly.
    Only the group state is UNDEF and so not displayed.
    Can someone help.
  • Please post configurations (if applicable):
    • Items configuration related to the issue
Group:DateTime:MIN gLastSeen "Last Seen [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS]" <calendar> (gHome)
DateTime GF_HL_MO_1_LastSeen "LastSeen GF_HL_MO_1 [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS] "  <calendar> (gLastSeen)
DateTime GF_K_MO_1_LastSeen "LastSeen GF_K_MO_1 [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS]" <calenadar> (gLastSeen)
DateTime OU_GA_T_1_LastSeen "LastSeen OU_GA_T_1 [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS]" <calendar> (gLastSeen)
  • Sitemap configuration related to the issue
sitemap first label="My Hell" {
        Frame label="LastSeen" {
                Text item=gLastSeen icon="calendar"
                Group item=gLastSeen
  • Rules code related to the issue
 rule "Sensor updates LastSeen"
         Member of gSensor received update
         val sensor = triggeringItem;
         val na =;
         val split = na.split("_");
         val String itemName = split.get(0) + '_' + split.get(1) + '_' + split.get(2) + '_' + split.get(3) + '_LastSeen'
                           gLastSeen.members.filter[i |].forEach [item | item.postUpdate(new DateTimeType); logInfo("lastseen.rules", "Item " + itemName + " updated.");]  
  • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

I’m not at all sure that MIN/MAX aggregations are implemented for DateTime Group types. Not every function makes sense for every possible type e.g. what should AVG or SUM do with dates?

The docs do say that MIN/MAX/AVG are for “decimal type” (Number)

EDIT - so, how to do it instead? Using Group functions is a neat idea, but you’d have to do it with a Group of Number Items holding the “timestamp” as an epoch integer.
Easy enough to populate those from your timestamping rule.
For display, you could use a transform to convert epoch to readable - a javascript I should think.

Or abandon the group, and have your rule populate a dedicated “oldest” Item. The rule would have to retrieve the “old” individual value before updating the timestamp, and compare with current “oldest”.
Hmm, then you’d still need to search for the next-oldest. That’s an interesting little task … I can feel a sorted list coming on somewhere.

In Rules DSL a map/reduce would work I think. Something like:

var oldestDT =[(state as DateTimeType).zonedDateTime].reduce[oldest, curr | oldest = if(curr.isBefore(oldest)) curr else oldest]

In Python:

oldestDT = reduce(lambda: oldest, curr: oldest = curr if curr.isBefore(oldest) else oldest,
                  [items[].getZonedDateTime() for dt in ir.getItem("MyDateTimes")])

I just typed in the above two lines, there may be typos, especially in the Python verison. See Design Pattern: Working with Groups in Rules for details.

1 Like

Thanks for the help!
I did it like this:

In the rule I changed to


Group:Number:MIN gLastSeen “Last Seen [JS(millisToDate.js):%s]” (gHome)

(function(i) {
       return new Date(parseInt(i)).toString();