import org.openhab.core.model.script.ScriptServiceUtil rule "Partition 1 Arm in STAY" when Item Partition1_Stay received command ON then if (Partition1_ReadyToArm.state == OFF) { logWarn("actions", "Ready to ARM is OFF") Alarm_Feedback.postUpdate("Ready to ARM is OFF") createTimer(now.plusSeconds(5), [ Alarm_Feedback.postUpdate("") ]) } else if (Partition1_Armed.state == ON) { logWarn("actions", "Alarm is already ARMED") Alarm_Feedback.postUpdate("Alarm is already ARMED") } else { val actions = getActions("caddx","caddx:partition::partition1") if (null === actions) { logWarn("actions", "Actions not found, check thing ID for bridge") Alarm_Feedback.postUpdate("No actions - Bridge ID?") return } logWarn("actions", "Executing STAY action ") actions.stay() } end rule "Partition 1 Arm in EXIT" when Item Partition1_Exit received command ON then if (Partition1_ReadyToArm.state == OFF) { logWarn("actions", "Ready to ARM is OFF") Alarm_Feedback.postUpdate("Ready to ARM is OFF") } else if (Partition1_Armed.state == ON) { logWarn("actions", "Alarm is already ARMED") Alarm_Feedback.postUpdate("Alarm is already ARMED") } else { val actions = getActions("caddx","caddx:partition::partition1") if (null === actions) { logWarn("actions", "Actions not found, check thing ID for bridge") Alarm_Feedback.postUpdate("No actions - Bridge ID?") return } logWarn("actions", "Executing EXIT action ") actions.exit() } end rule "Partition 1 DISARM" when Item Partition1_Pin_Number changed from "-" or Item Partition1_Pin_Number changed from "NULL" then if (Partition1_Armed.state == OFF ) { logWarn("actions", "Alarm is not armed") Alarm_Feedback.postUpdate("Alarm is not armed") } else { val actions = getActions("caddx","caddx:partition::partition1") if (null === actions) { logWarn("actions", "Actions not found, check thing ID for bridge") Alarm_Feedback.postUpdate("No actions - Bridge ID?") return } var EnteredPin = ScriptServiceUtil.getItemRegistry.getItem("Partition1_Pin_Number") logInfo("", "EnteredPin " + EnteredPin.state.toString) actions.disarm(EnteredPin.state.toString) } end rule "Partion 1 CHIME" when Item Partition1_Chime received command ON then { val actions = getActions("caddx","caddx:partition::partition1") if (null === actions) { logWarn("actions", "Actions not found, check thing ID for bridge") Alarm_Feedback.postUpdate("No actions - Bridge ID?") return } actions.chime() } end rule "Partition 1 Alarm Timestamp" when Item Partition1_AlarmMemory changed to ON //or //Item Testing_Switch received command ON then postUpdate(Partition1_Last_Alarm, new DateTimeType()) logInfo("", "Partition 1 Alarm Timestamp " + Partition1_Last_Alarm.state ) Partition1_Recent_Alarm.postUpdate(ON) end