Hi there
Can you please help me? I have found and modify three rules here for a small alarm system and i would like to add a timer in this rule like this: when its in the armaway mode to create a timer that will delay all actions with 15 or 30 sec. I need to do so because this alarm system is made at this moment with only one door contact installed on my front door so if i open the door to enter the house, ill trigger the actions (only one at this moment but later i want to add more). This timer should be also available after arming the system, i mean i need few sec to open and close the door after arming the system and there will be another question here, if i need to reopen the door after arming the system (i forgot the car keys) whats gonna happen? the system will reset the alarm if i enter and exit the house within 30 sec or will start the alarm after 30 sec?
The rules looks like this:
rule "Dispatch Notification"
when
Item Notification_Proxy received update
then
logWarn("Notification", Notification_Proxy.state.toString)
sendMail("dragos.m.constantin@gmail.com", "Security System Alert!",
Notification_Proxy.state.toString)
end
rule "Process door intrusion updates"
Item gDoorSensors changed from CLOSED to OPEN
then
val aState = AlarmSysStatus.state as DecimalType
if(aState == 2 || aState == 3) {
alert.apply(gDoorSensors, "- Intrusion")
}
end
// Alarm Arm and Disarm
rule "rArmState1"
when
Item AlarmArmDisarm received command 3
then
{
if (receivedCommand == 3 && gDoorSensors.state == CLOSED)
{
postUpdate(AlarmSysStatus, 6)
Thread::sleep(30000)
postUpdate(AlarmSysStatus, 3)
logInfo("Security", "SECURITY: Armed Stay!")
sendMail("xxx@gmail.com", "Security: Armed Stay!", "Sistemul este armat in modul Stay!")
executeCommandLine("aplay /opt/openhab/configurations/sounds/armedstay.wav")
executeCommandLine("/opt/openhab/configurations/scripts/armedstay.ssh")
} else {
if (receivedCommand == 3)
logInfo("Security","SECURITY: Unable to Arm Stay!. Please try again.")
sendMail("xxx@gmail.com", "Security: Usa sau geam deschis!", "Sistemul nu s-a putut arma datorita unei usi sau geam deschise! Te rog verifica!.")
postUpdate(AlarmSysStatus, 5)
Thread::sleep(3000)
postUpdate(AlarmSysStatus, 1)
}}}
end
// Alarm Arm and Disarm
rule "rArmState2"
when
Item AlarmArmDisarm received command 2
then
{
if (receivedCommand == 2 && gDoorSensors.state == CLOSED) {
{
postUpdate(AlarmSysStatus, 6)
Thread::sleep(30000)
postUpdate(AlarmSysStatus, 2)
logInfo("Security", "SECURITY: Armed Away!")
sendMail("xxx@gmail.com", "Security: Armed Away!", "Sistemul este armat in modul Away!")
executeCommandLine("aplay /opt/openhab/configurations/sounds/armedaway.wav")
executeCommandLine("/opt/openhab/configurations/scripts/armedaway.ssh")
} else {
if (receivedCommand == 2)
logInfo("Security","SECURITY: Unable to Arm Away!. Please try again.")
sendMail("xxx@gmail.com", "Security: Detectie miscare!", "Sistemul nu s-a putut arma datorita detectiei miscarii. Te rog verifica!")
postUpdate(AlarmSysStatus, 4)
Thread::sleep(3000)
postUpdate(AlarmSysStatus, 1
}}}
end
// Alarm Arm and Disarm
rule "rArmState3"
when
Item AlarmArmDisarm received command 1
then
{
if (receivedCommand == 1)
{
logInfo("Security", "SECURITY: Disarmed")
postUpdate(AlarmSysStatus, 1)
sendMail("dragos.m.constantin@gmail.com", "Security: Disarmed!", "Sistemul este dezarmat!")
executeCommandLine("aplay /opt/openhab/configurations/sounds/disarmed.wav")
executeCommandLine("/opt/openhab/configurations/scripts/disarmed.ssh")
} else {
if (receivedCommand == 1)
postUpdate(AlarmSysStatus, 1)
}}}
end
// Alarm Arm and Disarm
rule "rArmState4"
when
Item AlarmArmDisarm received command 0
then
{
if (receivedCommand == 0)
{
logInfo("Security", "SECURITY: No Update")
}}
end
Alarm System Active Action
rule "rAlarmActivated"
when
Item gDoorSensors changed from CLOSED to OPEN
then
{
if (AlarmSysStatus.state == 2)
{
logInfo("Security", "SECURITY: ARMED-AWAY Motion Intrusion Detected!")
gAllLights.sendCommand(ON)
Thread::sleep(3000)
}
if (AlarmSysStatus.state == 2 && gDoorSensors.state == OPEN)
{
logInfo("Security", "SECURITY: ARMED-AWAY Door Intrusion Detected!")
gAllLights.sendCommand(ON)
Thread::sleep(3000)
}
if (AlarmSysStatus.state == 3 && gDoorSensors.state == OPEN)
{
logInfo("Security", "SECURITY: ARMED-STAY Door Intrusion Detected!")
gAllLights.sendCommand(ON)
Thread::sleep(3000)
}
}}}}
end
Could you please help with this?
Thanks!