"no context to infer the closure's argument types from" error in Rule

Hi,
I have two window contact sensors, and I want to use a push notification to see if one of them is open.
My rule looks like this:

rule "XY"
when
    Member of gSensor changed
then
    if(outofhouse==ON)
    {
        val String zeit = now.withZone(DateTimeZone.forID("Europe/Berlin")).toString("dd.MM.yyyy' 'HH:mm:ss") 
        val ContactItem opendoor = gSensor.members.sortby[ lastUpdate ].findFirst[ i | i.state == OPEN ]
        logInfo("notifications", "Sending notification via pushover.") 
        sendPushoverMessage(pushoverBuilder(opendoor+ "wurde am"+zeit+"geöffnet."))
        }        
end

I get the

There is no context to infer the closure's argument types from. Consider typing the arguments or put 
the closures into a typed context.

error.
Any ideas why?

This might help

I don’t think that link is the root cause of the problem here. In that sortBy thread the error would be a null error. This error is different.

This error is saying that it can’t figure out the type of either lastUpdate or i. It is most likely i because sortBy expects a method, not an Object. Try giving i a state. findFirst[ ContactItem i | i.state == OPEN ].

The old thread also gives important hints about having persistence working and default persistence being set correctly, in order to get anything useful from lastupdate.

True, but in those cases, if persistence were not set up correctly they would be getting null errors. And once they fix the original problem they very well might have persistence problems. The error they are receiving is happening before the code gets that far.