Comparing Dates for a group of items (Zigbee devices)

Thanks @rlkoshak for the quick response and the assistance. I was mainly referencing DateTime Conversion (openHAB 2.x)

That was my bad, creating a DateTime variable and assigning a string as opposed to converting the string.

Is it possible to combine this into a loop to check all items in a group? I was reading Design Pattern: Working with Groups in Rules

It looks possible, this is what I thought would work reading that:

val StringBuilder sb = new StringBuilder
groupName.members.filter[ i | AA.isBefore(new DateTime(i.state.toString).plusHours(5))].forEach[i | sb.append(", " + i.name) ]

which produces:

Rule ‘Test Time update’: Invalid format: “NULL”

Is it possible to put such a command in the group loop or would it be possible to make the loop so that multiple commands can be run. I’m thinking:

val StringBuilder sb = new StringBuilder
groupName.members.filter[ i | i != NULL].forEach[i |
var BB = new DateTime(mqtt_topic_10116ed7_MotionSensorUpLastSeen.state.toString)

if(AA.isBefore(BB)) {
sb.append(", " + i.name)
}
]

@hafniumzinc thanks, thats another great way to look at it. Unfortunately I’m interested in devices losing connection not necessarily going offline. This has happened a few times with Xiaomi motion and contact sensors where they will just stop responding until I press the pairing button on the device (no changes made to Zigbee2mqtt). In this case the availability does not seem to be updated (at least for me).