Identifying Triggering Devices for Burglar Alarm

I was curious if anyone smarter than me had an idea of how i could best/most efficiently identify which security sensor triggered an alarm. Here is a snippet of code I currently have in place:

rule "Burgler Away Door Conditions"
when
    Item front_door_sensor changed to OPEN or
    Item back_door_sensor changed to OPEN or
    Item garage_door_sensor changed to ON or
    Item front_door_alarmcodes changed to 22 or
    Item back_door_alarmcodes changed to 22 or
    Item garage_door_overhead_closedsensor changed to OPEN
then
     if (burgler_alarm_away.state == ON) {
        sendPushoverMessage(pushoverBuilder("Burgler Alarm Warning"))
        playSound("intruder.mp3")
	    timer10 = createTimer( now.plusSeconds(22)) [|
            burgler_alarm_away_act.sendCommand(ON)
            timer10 = null   // reset the timer
            ]
     }
end

rule "Burgler Away Doors ACTIONS"
when
    Item burgler_alarm_away_act changed to ON
then
	if (burgler_alarm_away.state == ON) {
        security_siren.sendCommand(ON)
        sendPushoverMessage(pushoverBuilder("BURGLER ALARM NOW ACTIVATED DUE TO A DOOR EVENT. SIREN IS SOUNDING").withEmergencyPriority())
        sendMail(all_recipients, "BURGLER ALARM ACTIVATED!", burgler_door_message)
        front_door_lock.sendCommand(ON)
        back_door_lock.sendCommand(ON)
        gAllDimmers.sendCommand(100)
        gAllLightSW.sendCommand(ON)
        burgler_sendsignal.sendCommand(ON) //send signal to alarm company
    }
end

This works just fine, but to bring this to the next level, i’d like to know which door event triggered the alarm. Can anyone suggest an efficient way to accomplish this? I have similar code for my motion and glass break sensors, so with my limited coding knowledge, I struggled to think of a solution that didn’t involve a ton of code… Thanks!

Put all the Items in a Group. Trigger the rule using Member of mygroup changed. Use the implicit variable triggeringItem within the rule to find the culprit.

1 Like