Openhab 2 Lastest Motiondetector logger

https://docs.openhab.org/administration/logging.html#create-log-entries-in-rules

Log out everything. What is the name of the Item that gets set to motionLatest? What is the name of the Item that gets set to doorwindowLatest? What is their lastUpdate? What is the lastUpdate for ALL the Items in both groups?

hello

i added loggin but still i see the same thing in the logs

2018-01-19 19:35:03.840 [INFO ] [home.model.script.MotionUpdate.rules] - Checking Last Motion Detection !
2018-01-19 19:35:03.846 [INFO ] [home.model.script.MotionUpdate.rules] - Lastmotiondetector intrusion state ON
2018-01-19 19:35:03.853 [INFO ] [home.model.script.MotionUpdate.rules] - Lastdoorwindow intrusion state CLOSED
2018-01-19 19:35:03.858 [INFO ] [home.model.script.MotionUpdate.rules] - Lastest intrusion state CLOSED
2018-01-19 19:35:03.864 [INFO ] [home.model.script.MotionUpdate.rules] - DoorWindowsSensor Garage Intrusion!, CLOSED

current rule:

rule "Process Intrusion Updates"
when
	Item gMotionAlarms changed from OFF to ON or
	Item DoorsWindows changed from OFF to ON
then
	Thread::sleep(300)
	logInfo("MotionUpdate.rules", "Checking Last Motion Detection !")
	//val motionLatest = gMotionAlarms.members.sortBy[lastUpdate].last
	val motionLatest = gMotionAlarms.members.filter[a | a.lastUpdate !== null].sortBy[lastUpdate].last
	logInfo("MotionUpdate.rules", "Lastmotiondetector intrusion state" + " " + motionLatest.state.toString)
	val doorwindowLatest = DoorsWindows.members.sortBy[lastUpdate].last
	logInfo("MotionUpdate.rules", "Lastdoorwindow intrusion state" + " " + doorwindowLatest.state.toString)
    val latest = if(motionLatest.lastUpdate.isAfter(doorwindowLatest.lastUpdate)) motionLatest else doorwindowLatest
	logInfo("MotionUpdate.rules", "Lastest intrusion state" + " " + latest.state.toString)
	val name = latest.name.split("_")
    LastMotionDetection.postUpdate("" + name.get(1) + " " + name.get(2) + " Intrusion!, " + latest.state.toString)
	logInfo("MotionUpdate.rules", LastMotionDetection.state.toString)	
end

I don’t care what the state is. We need to know what Item it is.

motionLatest.name

I have a different approach. Instead of browsing through persistence, use the triggeringItem.

String lastMotion "Last motion [%s]"
rule "contact check"
when 
	Item DOOR_STATE changed from OPEN to CLOSED	or			
	Item DOOR_STATE changed from CLOSED to OPEN or
	Item MOTION_STATE changed from ON to OFF	or			
	Item MOTION_STATE changed from OFF to ON
/// put all your watched items and state changes in the conditions block
then
	val String msg = triggeringItem.name
	lastMotion.postUpdate(msg)
	logInfo("motion", msg)
end	

I use that msg, device name and state:

val String msg = String::format("%s %s", triggeringItem.name.split("_").get(0), triggeringItem.state.toString)

Excuse me, if i did miss the point.

problem is solved by setting the group for the door/windows correctly
it was set to a switch while it should be a contact.

changed the group to:
Group:Contact:OR(OPEN,CLOSED) DoorsWindows

adjusted the rule:

rule "Process Intrusion Updates"
when
	Item gMotionAlarms changed from OFF to ON or
	Item DoorsWindows changed from CLOSED to OPEN
then
	Thread::sleep(300)
	logInfo("MotionUpdate.rules", "Checking Last Motion Detection !")
	//val motionLatest = gMotionAlarms.members.sortBy[lastUpdate].last
	val motionLatest = gMotionAlarms.members.filter[a | a.lastUpdate !== null].sortBy[lastUpdate].last
	logInfo("MotionUpdate.rules", "Lastmotiondetector intrusion state" + " " + motionLatest.name.toString)
	val doorwindowLatest = DoorsWindows.members.filter[b | b.lastUpdate !== NULL].sortBy[lastUpdate].last
	logInfo("MotionUpdate.rules", "Lastdoorwindow intrusion state" + " " + doorwindowLatest.state.toString)
    val latest = if(motionLatest.lastUpdate.isAfter(doorwindowLatest.lastUpdate)) motionLatest else doorwindowLatest
	logInfo("MotionUpdate.rules", "Lastest intrusion state" + " " + latest.state.toString)
	val name = latest.name.split("_")
    LastMotionDetection.postUpdate("" + name.get(1) + " " + name.get(2) + " Intrusion!, " + latest.state.toString)
	logInfo("MotionUpdate.rules", LastMotionDetection.state.toString)	
end