Add time since last update to group max calculation?

Trying to decay a group of RSSI values based on seconds since last update and obtaining the MAX of the group.

Is there a way to include this into the group calculation or how would I do a complex rule for this?

Assuming the group is in excess of 10, calculating 10 processed values and getting the max with each individual update seems like it would trigger a race condition.

On the other hand, without the expire binding in OH3, I cannot set a timer to subtract one from each individual RSSI value every second.

I tried using a 1 second timer set through a global variable but I seem to end up with 3 timers running concurrently after a few updates even though I reset the global variable each time.

var Timer rTimer = null

rule “RSSI Changed”
when
Item RSSI changed
then
rTimer = null
rTimer = createTimer(now.plusSeconds(1), [ |
if(RSSI.state >= -180){
var prevState = RSSI.state as Number
var newState = prevState - 1
RSSI.postUpdate(newState)
rTimer.reschedule(now.plusSeconds(1))
}
else rTimer = null
])
end

Suggestions appreciated.

nope, you are stuck with the available aggregation functions for Group states.

Available facsimile

The global variable rTimer is just a handle, a pointer. Setting it to null does not affect any timer it was pointing at, they are completely independent after creation. If your rule finds the handle non-null and wants to cancel an existing timer, you must take the specific action e.g.
rTimer.cancel

Available facsimile

I read a very heated discussion about the existence of jython/jsr223 in OH3. Unfortunately, due to the negative nature of the discussion I might have left the discussion under the impression it was a no go for OH3 as well. I will look into it again later.

The global variable rTimer is just a handle, a pointer. Setting it to null does not affect any timer it was pointing at, they are completely independent after creation. If your rule finds the handle non-null and wants to cancel an existing timer, you must take the specific action e.g.
rTimer.cancel

Thank you. This was the missing link I was looking for. I’m not very experienced with java, coming from python.

I seriously doubt it is a no go. It will almost certainly receive some sort of support at some point, probably very soon. It’s also worth noting that there is in work a native replacement for the Expire binding that will work with the existing Expire binding configs.