Hi,
heggink wrote:All,
IMPORTANT: The original WIKI was created when domoticz still recognised changes in user variables and was able to trigger events. That is no longer the case. User variables need to be replaced with dummy devices instead.
I had a lot of issues getting the alarm system to work well with the current stable Domoticz release. Now it seems to work. I'd like to document here what I've done, to help others (and prevent them from wasting several hours, like I did...). Feedback is welcome.
My conventions:
- All "Door" sensors have names that start with "Door" ("MCS_" in the original version)
- All motion sensors have names that start with "Motion" ("PIR_" in the original version)
I created the following dummy devices (Virtual Switches):
- "AlarmDetected": Becomes Active when an alarm is detected
- "VirtualSiren": The device that triggers physical siren(s). Using a virtual device for this makes it easier to support multiple sirens/signaling devices, and solves some other problems. "Sirene: Innen" is my physical siren.
- "AlarmSirenTrigger": Used for the siren delay
The original LUA code has only been modified slightly. Here it is:
Event "MotionAlarm" -
Device:
Code: Select all
-- Title: script_device_PIRAlarm.lua
-- Date: 12-11-2015
-- checks for PIR during Alarm Away status
-- if detected then alert and set the alarm flag
--
commandArray = {}
tc=next(devicechanged)
PIR_switch=tostring(tc)
if (PIR_switch:sub(1,6) == 'Motion') then
if(otherdevices['Security Panel'] == 'Arm Away') then
print('Movement detected on '..PIR_switch)
-- commandArray['SendNotification']='Movement detected on '..PIR_switch
commandArray['Variable:LastAlarmDevice'] = 'Detected movement on '..PIR_switch
commandArray['AlarmDetected']='On'
end
end
return commandArray
Event "DoorAlarm" -
Device:
Code: Select all
-- Title: script_device_MCSAlarm.lua
-- Date: 12-11-2015
-- checks for MCS during Alarm Away status
-- if detected then alert and set the alarm flag
commandArray = {}
tc=next(devicechanged)
MCS_switch=tostring(tc)
if (MCS_switch:sub(1,4) == 'Door') then
if(otherdevices['Security Panel'] == 'Arm Away') then
print('Door open/close detected for '..MCS_switch)
commandArray['Variable:LastAlarmDevice'] = 'Detected door open/close on '..MCS_switch
-- commandArray['SendNotification']='Door open/close detected for '..MCS_switch
commandArray['AlarmDetected']='On'
end
end
return commandArray
Event "KeypadAlarm" -
Device:
Code: Select all
-- Title: script_device_AlarmPanel.lua
-- Date: 19-11-2015
-- this scrip switches the Alarm Status according to the alarm panel
--
commandArray = {}
tc=next(devicechanged)
Panel=tostring(tc)
if (Panel == 'Keypad Alarm Level') then
-- set the group to the status of the switch
if (devicechanged[Panel] == 'On') then
print('AlarmPanel Arm Away')
commandArray['Security Panel'] = 'Arm Away'
else
print('AlarmPanel Disarm')
commandArray['Security Panel'] = 'Disarm'
commandArray['Keypad Ack'] = 'On'
end
end
return commandArray
Event "SirenDelay" -
Device - triggers siren after 30sec:

- sirendelay.png (21.59 KiB) Viewed 6459 times
Event "SoundSiren" -
Device - actually enable the siren once the delay has passed:

- soundsiren.png (37.83 KiB) Viewed 6459 times
Event "CancelSiren" -
Security (!!!) - Cancel False Alarm by disarming while siren is active:

- cancelsiren.png (35.59 KiB) Viewed 6459 times
Continued in next post...