I was reading on forums, but couldn’t find exactly what I’m looking for.
My test:
-Door changes status to OPEN
-if a motion detected in last 5 min (for testing only) turn on the light
rule:
rule "Door opens - hue light"
when
Item HallwayDoorSensorIsOpen changed from CLOSED to OPEN
then
val Number KitchenLM = new DateTime(KitchenMotionSensorLastMotion).millis
if( KitchenLM > now.minusMinutes(5).millis ) {
KitchenLightSwitch.sendCommand("ON")
}
end
But i receive an error: Rule 'Door opens - hue light': No instant converter found for type: org.eclipse.smarthome.core.library.items.DateTimeItem
Rule 'Door opens - hue light': 'isAfter' is not a member of 'java.lang.Number';
rule:
val Number KitchenLM = new DateTime(KitchenMotionSensorLastMotion.state.toString)
if( KitchenLM.isAfter(now.minusMinutes(5) ) {
KitchenLightSwitch.sendCommand("ON")
}
Item events are like:
KitchenMotionSensorLastMotion changed from 2019-07-10T16:25:22.773+0200 to 2019-07-10T16:26:23.793+0200
rule "Door opens - hue light"
when
Item HallwayDoorSensorIsOpen changed from CLOSED to OPEN
then
val KitchenLM = new DateTime(KitchenMotionSensorLastMotion.state.toString)
if( KitchenLM.isBefore(now.minusMinutes(15)) ) {
KitchenLightSwitch.sendCommand("ON")
LivingRoomLightSwitch.sendCommand("ON")
}
end