I’m trying to reuse the Design Pattern: Working with Groups in Rules Design Pattern.
I’m getting the following error:
2017-07-17 20:47:56.902 [INFO ] [clipse.smarthome.model.script.motion] - Motion: Sensor - LandingMotion Triggered
2017-07-17 20:47:56.911 [INFO ] [clipse.smarthome.model.script.Motion] - Timer: LandingMotionTimer
2017-07-17 20:47:56.923 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'A Motion Sensor Changed': org.eclipse.smarthome.core.library.types.DateTimeType
items:
Group:Contact:OR(OPEN, CLOSED) gMotionSensors "The Motion Sensors are [%s]"
Group:DateTime:MAX gMotionLast "The last motion event was [%1$tm/%1$td %1$tH:%1$tM]"
Group:Switch:OR(ON, OFF) gMotionTimers
Switch HallwayMotionTimer (gMotionTimers) { expire="2m30s,command=OFF" }
Switch LandingMotionTimer (gMotionTimers) { expire="2m30s,command=OFF" }
Contact HallwayMotion "Hallway Motion [MAP(en.map):%s]" <contact> (gHall,gMotion,gMotionSensors) {mios="unit:house,device:22/service/SecuritySensor1/Tripped"}
DateTime HallwayMotion_LastUpdate "Hallway Motion [%1$tm/%1$td %1$tH:%1$tM]" (gMotionLast)
Contact LandingMotion "Landing Motion [MAP(en.map):%s]" (gModbus, gMotion, gMotionSensors) {modbus="slave1:0"}
DateTime LandingMotion_LastUpdate "Landing Motion [%1$tm/%1$td %1$tH:%1$tM]" (gMotionLast)
Rule:
rule "A Motion Sensor Changed"
when
Item LandingMotion changed or
Item HallwayMotion changed
then
Thread::sleep(100) // give persistence time to catch up
val motion = gMotionSensors.members.filter[s|s.lastUpdate("mapdb") != null].sortBy[lastUpdate("mapdb")].last as ContactItem
logInfo("motion", "Motion: Sensor - " + motion.name + " Triggered")
val timer = gMotionTimers.members.filter[t | t.name == motion.name+"Timer"].head as SwitchItem
logInfo("Motion", "Timer: " + timer.name)
if(motion.state == OPEN){
timer.sendCommand(ON)
val lastUpdate = gMotionLast.members.filter[dt | dt.name == motion.name + "_LastUpdate"].head as DateTimeType
logInfo("Motion", "LastUpdate: " + lastUpdate.name)
lastUpdate.postUpdate(new DateTimeType)
// Alert
val StringBuilder msg = new StringBuilder
msg.append(motion.name) // note a map and transform can convert from Item name to human friendly words
msg.append(" was activated")
if(AlarmSet.state == ON){
sendLogNotification(msg.toString)
}
if (FrontLux.state < LightLevelTrigger && Elevation.state < ElevationHeightTrigger){
msg.append(" DO stuff here!")
logInfo("lightsLanding", msg.toString)
//LandingLightLoadLevelStatus.sendCommand(80)
}
}
//timer.postUpdate(OFF) // postUpdate(OFF) cancels the Timer without triggering the rule below
end
Thanks
James