Regarding to section 4b of the DateTime Conversion post it is a joda time
val MyJodaFromDateTimeType_VariantB = new DateTime(MyDateTimeItem.state.toString)
I think, your code could also look like this
rule "doorOpened"
when
Item contactDoor changed from CLOSED to OPEN
then
lastDoorOpen.postUpdate(new DateTimeType)
doorTimer.sendCommand(ON)
end
rule "motioninhouse"
when
Item sensorMotion changed from OFF to ON
then
lastMotion.postUpdate(new DateTimeType)
end
rule "doorTimerExpired"
when
Item doorTimer changed from ON to OFF
then
val JodaLastDoorOpen = new DateTime(lastDoorOpen.state.toString)
val JodaLastMotion = new DateTime(lastMotion.state.toString)
if ( JodaLastDoorOpen.isBefore(JodaLastMotion) ) {
andyIsHome.sendCommand(ON)
}
if ( JodaLastDoorOpen.isAfter(JodaLastMotion) ) {
andyIsHome.sendCommand(OFF)
}
end