Page 1 of 5

Alarm system 'wiki'

Posted: Saturday 21 November 2015 14:05
by heggink
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.

Since my existing, built in alarm, is getting to an end, I needed to replace it with something new. Obviously, domoticz was my first choice so I decided to give it a go.

My key challenge was that I found bits and pieces everywhere but wanted a more 'all-encompassing' approach which turned into something that could be considered sort of a generic wiki. Since this would be my first wiki, I would like some feedback before I post so here it goes :-). Be gentle ;-).

Practical guide to building an alarm system using Domoticz

Contents
General concept
Building resilience
Detection devices
Sirens
Arm/Disarm
Putting it all together
Alerting
Actions

Contents

Setting up a fully capable, industry grade alarm system using Domoticz is pretty doable and quite cost effective. Obviously Domoticz will not be using wired devices and wireless devices are never as secure as wired ones. If that's what you need then you will be better off buying a separate, wired alarm system. That said, using a mixed system of devices (z-wave, 433) will make it hard for any burglar to jam everything at the same time giving quite a decent base system.

There is quite a bit of info in this wiki and it may seem complex but it really isn't. It does require basic knowledge of domoticz but you should not have to do any (major) lua programming yourself if you don't feel comfortable.

General concept

This design is based on the following basic principles:
1. use the domoticz built-in security panel (arm, disarm, check states)

2. use any standard detection devices: motion detectors as well as door/window sensors and name them such that you can easily detect them generically (motion detected, door opened) : 2 simple lua scripts handle either motion detection (PIR) or door/window sensor detection. All motion/PIR sensors need to be named PIR_something (e.g. PIR_hallway, PIR_livingroom), all door/window sensors need to be named MCS_something (e.g. MCS_backdoor, MCS_frontdoor). This way, you can easily add sensors without having to change anything in the rest of system.

3. separation between detection and action: instead of dealing with the threat in the detection script itself, I decided to handle any action outside of the detection scripts. That gives me a lot more flexibility in dealing with these. The detection scripts set a user variable “AlarmDetected” to 1 if an alert is detected. Using either scripting or (blocky) events, you can then act on these. I currently use events (being lazy by nature, it's easier to make a change rather than to have to login and change/test lua scripts). Either way, once an action is done, you need to set the user variable “AlarmDetected” back to 0 in order for new alarms to be raised.

4. Any PIR or MCS activity when the alarm is armed is notified through the notification system. Set that up and you get a notification on the exact trigger.

Building resilience & security

Any alarm system built on computing technologies is as good as the availability of the system. Once the computer is down, so is your alarm. A couple of things that can be done to increase the resilience of the system. Also, it's tempting to connect domoticz to the internet and access it from outside yout house. Once domoticz controls your alarm, that may not be the best idea as you don;t want hackers to control your security in any way.

In order to increase resilience, I can recommend using (some of) the following:
  • Equip domoticz with a (small) UPS. I use the very cheap Sweex 1000VA UPS (usually around 85 bucks) for both my electronics cabinet as well as for domoticz (which is in a different place). Since domoticz, in my case, runs on a raspberry pi, it can go on for days on the UPS if need be
    use a watchdog if your system has one. The raspberry pi does. This ensures that if the system locks up (hangs or CPU max), it gets restarted automatically. There are general pages for the pi as well as a specific page for domoticz. Google is your friend.
    Make sure that not only domoticz is on an UPS but everything else you need in order to get a message out. If your router is not on the UPS then no internet if the power is down.
    Consider a cell network data plan with a dongle in order to send messages even if all the power in the neighborhood is out. Neighborhood wide power outages are notorious burglar events. Some routers support a dongle based backup if the main internet is out but you can also equip your system directly with a dongle.
    Just make sure that the entire end to end chain (end points and switches in between), is on an UPS as, having a pi desperately trying to alert you without a network is not good. Note that it's not uncommon for a burglar to short-cut an outside electricity socket to trip the main switch/RCD in your home. If your power is down, can you still get a message out?
In order to increase security, I strongly recommend to NOT directly connect domoticz to the interenet. Whilst domoticz can be secured in a reasonable way, there are too many vulnerabilities to allow any direct connection to the box. Never put domoticz in a DMZ and I strongly recommend to not even use port forwarding. If you do want to access domoticz outside of your home, use a VPN. Most routers these days are equipped with a VPN server. Setting one up is not complex at all. If you have a choice in VPN server (if the router has a VPN server, it usually allows some choice between e.g. PPTP and OpenVPN), I recoomend NOT using PPTP as it's much more hackable than e.g. OpenVPN. Unfortunately my windows phone does not support OpenVPN which, for me, means I will not use my windows phone as PPTP is, IMO, just not good enough any more. Apple devices will support OpenVPN. Once the VPN tunnel is up, you can connect to domoticz as if you were on your home network.

Detection devices

Building the system, you have a choice of detection devices:
  • Movement detection devices aka PIR or passive infra-red: these come in various technologies both 433, z-wave and probably others. This wiki will use both KAKU AWST-6000 (the downside is that they create a 5-10s signal burst during which rfxcom cannot send/receive other signals so essentially not a good choice, I need to replace them) as well as z-wave Philio PST02-1B. Again, call these PIR_something.
    Door-window sensors: these also come various technologies. I use the KAKU AWST-606 (they are cheap). Obviously the Philio sensors are much more dependable and you will not miss a signal but they are 3-4x more expensive. Since it's strongly advised to equip all external and some internal doors/windows with a sensor (and I have a lot) then decide whether you want to spend the money (in my case, 12x a difference of 35 euros ie 400 euros for just the door sensors). Also recognise that you should combine these with motion detection as any burglar smashing in a window will not trigger the window/door sensor. Make sure you put a sensor on your utilities cabinet (Meterkast) in case anyone is looking to cut off your electricity. My sensor triggers an immediate alarm if the alarm system is armed. Again, call these MCS_something.
    Glass break sensors: this seems to be a rather weak area in home automation as there don't seem to be too many options here. I have found the vision security ZS5101 z-wave shock sensor which is listed as being able to detect glass breaks. It has mixed feedback on the internet. Please report any confirmed working glass break sensors
    Camera's: you have a choice of confirmed supporting camera's that you can buy in local shops or order any of these cheap chinese IP wifi camera's and pray they will work. Many of them have both infrared support as well as some form of motion detection. In most cases, the motion detection is not integrated in domoticz AFAIK but there are guides on how to do this. Again, google is your friend. It's not difficult to add a (supported) camera to domoticz (Setup→>More Options→Camera → Add Camera) and then to add the camera to a dummy switch. When you press the switch, the camera takes a picture and sends it to you vial email.
Sirens

There are a number of different sirens on the market in various technologies. I decided to use 433 based linked smoke detectors, in my case the König SAS SA200. These are cheap but connectable smoke detectors. I have 3 of them (garage/laundry, kitchen/living and upstairs) that are linked. If one goes off, so do the others. Domoticz can also trigger them causing a 3x 85db noise which I can assure you is quite effective. There are other options including z-wave sirens. Again, these are more dependable and will definitely go off if Domoticz tells it to (again, a 433 signal may get undetected). A z-wave device will probably cost as much as my 3 smoke detectors together.

Arm/Disarm

Domoticz has a security panel built in which works perfectly but requires a computer (phone, tablet) to arm. For convenience, I have added the z-wave zipato mini keypad. Not only is it very small and easy to use but it uses rfid tags to arm/disarm. There is an excellent wiki on how to install with domoticz: https://www.domoticz.com/wiki/Zwave#Usi ... Tag_Reader. Adding rfid tags (and user pin codes) was a breeze and you can have it up and running in a matter of minutes. It creates multiple devices of which I use 2 (3 if you count the tamper switch which I don't think I will use as I hope my alarm has gone off by then):
  • Alarm level: on means the peypad was armed (away button), off means disarmed (home button)
    Switch: this is the feedback of the device ie the beeps when you arm it. I renamed it to keypad Ack based on 'lolautruche' recommendations in the domoticz forum and set it to on when the keypad is disarmed. That way, next time the alarm is armed, you hear the beeps indicating the system is about to arm.
Once the zipato keypad is installed and configured, you need to integrate it into your security setup as, by default, it only creates an on/off switch that does nothing else. Since Domoticz already has the built-in security panel and the system has specific functionalities built in to handle security states and alerts, I used this rather than to build my own. Simplest way is to arm/disarm the security panel once after which it shows up in your devices list allowing you to include it in yout switches list and on your dashboard if you so choose.

Once that's done, you need to let the zipato keypad control the domoticz alarm state. There are different ways this can be done. I used a simple lua script that sets the domoticz security state based on the keypad action as follows:

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['Variable:AlarmDetected'] = '0'
                commandArray['Keypad Ack'] = 'On'
        end
end
return commandArray
Sweet and simple. The beauty is that arming the security panel uses the built in security panel's delay as configured in the domoticz settings. Again, there are different ways you can do this.

Putting it all together

1. Create a user variable called “AlarmDetected” (without the quotes obviously) of type string. Set it to 0.

2. If you use the zipato keypad, save the AlarmPanel script in the domoticz/scrips/lua directory

3. Set up any notifications you want in the domoticz notifications system. I use both pushalot for my windows phone and that works really well. I also use pushover for my ipad (and soon my wife's iphone) which also works well

4. Save the following 2 lua scripts in the domoticz/scrips/lua directory:

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,3) == 'MCS') then
	if(otherdevices['Security Panel'] == 'Arm Away') then
		print('MCS motion detected:'..MCS_switch)
		commandArray['SendNotification']='MCS motion detected:'..MCS_switch
		commandArray['Variable:AlarmDetected'] = '1'
	end
end
 
return commandArray

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,3) == 'PIR') then
	if(otherdevices['Security Panel'] == 'Arm Away') then
		print('PIR motion detected:'..PIR_switch)
		commandArray['SendNotification']='PIR motion detected:'..PIR_switch
		commandArray['Variable:AlarmDetected'] = '1'
	end
end
 
return commandArray
5. If you use a camera, set it up as described above and create the dummy switch so you can take a picture when triggering the switch. Make sure you set up your email address so it can actually send you the picture as well (instead of the burglar ending up with a nice picture of him/herself)

6. Decide how you want to deal with the alarms generated. A simple way could be to create an event called AlarmNotification with the following blocky:
Image

This (only) sends a notification and switches the AlarmDetected flag off after 20 seconds kind off creating a silent alarm. In my case, this is still WIP. Considerations for me are:
if after sundown and before sun-up (simple addition to the event above), switch on the lights and use my indoor camera to take a picture (or start recording?)
if I get an alarm notification on my phone, am I better off asking my neighbors to check up on the house using our community whatsapp group? If after 1am and before 7am, should I still sound the alarm since nobody is looking at their phones?
Do I want any speaker connected to my pi saying that the police is on their way now?
As you can see, the possibilities are endless and I still need to make up my mind how exactly I will handle them. Domoticz at least allows us to do whatever I would want to do in a way that is much more flexible than any standard alarm system.

Re: Alarm system 'wiki'

Posted: Sunday 22 November 2015 10:12
by stlaha2007
Hi there,

Nice very nice. Very understanding.

Looked at it with a technical and regular user view. Both are satisfied.

Makes may want to look into the HomeAlarm system now.

Keep going on.

Grtz,
Stephan

Sent from my D6503 using Tapatalk

Re: Alarm system 'wiki'

Posted: Sunday 22 November 2015 22:00
by heggink
Thanks! I have made some minor changes already so an update is due soon. There is 1 more thing I want to do before I add this to the wiki which is that I need to figure out how to enable a delayed siren. Imagine someone coming home through the back door having to cross some distance to disable the alarm. By the time you disable the alarm, several triggers will have occurred. You need some time (say 90 seconds) to shut off the alarm and prevent the siren from going off.

This could be done through scripting but I wanted to make the system as simple as possible requiring (ideally) no programming so need to figure out a way to enable a delayed siren than can be disabled in the mean time.

Anyways, thanks for the support!

H

Re: Alarm system 'wiki'

Posted: Monday 23 November 2015 11:00
by joshimosh
Thank you very much for this comprehensive and very helpfull Wiki. I am currently in the process of adding an Alarm feature to my Domoticz-Bades HA system. Your Wiki is a very valueable input - thank you for making your thoughts available.

Cheers
Josh

Re: Alarm system 'wiki'

Posted: Tuesday 24 November 2015 20:11
by ceedebee
The script for setting the security panel doesn't work for me, I am using the following script:

Code: Select all

commandArray = {}

if (devicechanged['Iemand thuis'] == 'Off' ) then
  commandArray['Security Panel'] = 'Arm Away'
  print('Setting Arm Away')
end

return commandArray
I'm getting the print result in my log but no change in de status of the security panel and no log of the eventsysten.
Anybody an idea why?

Re: Alarm system 'wiki'

Posted: Tuesday 24 November 2015 20:17
by jvdz
That should be:

Code: Select all

commandArray['SecPanel']='Arm Away'
Jos

Re: Alarm system 'wiki'

Posted: Tuesday 24 November 2015 20:51
by ceedebee
I'm sorry but this isnt working either :(

Re: Alarm system 'wiki'

Posted: Tuesday 24 November 2015 20:56
by jvdz
What did you name your SecPanel switch exactly? ( found in the Switches tab of the DOMOTICZ website)
That name needs to go in this part: commandArray['???????']

Jos

Re: Alarm system 'wiki'

Posted: Tuesday 24 November 2015 21:17
by ceedebee
Okay... thank you, that did the trick. My assumption was that the panel had a standard name. But in my case it's Security Panel in Dutch.

Re: Alarm system 'wiki'

Posted: Wednesday 25 November 2015 8:42
by void
heggink wrote:Thanks! I have made some minor changes already so an update is due soon. There is 1 more thing I want to do before I add this to the wiki which is that I need to figure out how to enable a delayed siren. Imagine someone coming home through the back door having to cross some distance to disable the alarm. By the time you disable the alarm, several triggers will have occurred. You need some time (say 90 seconds) to shut off the alarm and prevent the siren from going off.

This could be done through scripting but I wanted to make the system as simple as possible requiring (ideally) no programming so need to figure out a way to enable a delayed siren than can be disabled in the mean time.

Anyways, thanks for the support!

H
Did you by any chance found the right parameter for this yet?
I'm currently using device presence to turn the alarm on/off but since the presence script normally only runs once a minute the alarm disables when I'm about 20-40 seconds in the house.
I could obviously modify the presence to sleep for 30 seconds and then repeat the script, thus making it run twice a minute but there most be a more elegant way to archieve this.

The countdown timer is in the disarmed -> armed state, so it shouldn't be rocked science to get it to countdown 30 secs when a breach is detected. Right? :?:

Re: Alarm system 'wiki'

Posted: Wednesday 25 November 2015 8:55
by heggink
Yes. What I have done is I have created a blocky that sounds the alarm based on a variable SoundSiren'"1" and SecurityStatus="Armed Away". The lua scripts trigger the variable AlarmDetected so I can act on any alarm raised. A blocky event then acts based on this and sets SoundSiren to "1" after 90 seconds. That way, the alarm will only go off after 90 seconds and I have time to shut it down.

The only other thing I did was create 2 additional blocky's AlarmOn and AlarmOff where the first sets a variable AlarmActive when the Alarm status is "Armed Away" and the second (AlarmOff) resets all te variables so nothing gets triggered. I needed the AlarmActive because, otherwise, the scripts would get triggered constantly (since events are time based afaik ie not triggered by a device/variable state change).

I hope to release the total wiki shortly (as soon as I have time to create the page). that will include the blocky's and all.

Re: Alarm system 'wiki'

Posted: Thursday 26 November 2015 8:56
by user9142313
I took your initial scripts and made a few changes. At the end of all this, it doesn't resemble very much of your original work except for the idea and concept. It was useful because I knew nothing about Domoticz's events system. This is only my second day using this application.

The intention behind these modifications is have it behave somewhat similar to a commercial alarm system (DSC, Honeywell, etc.). It's far from it in terms of feature sets and reliability but it's close. With the following script, you have proper home armed support (disables PIR), disarm delays and so forth.

This script requires the use of virtual switches, Lua script and Blocky events. I found that I couldn't get Blocky events to trigger when using user defined variables for some reason hence the use of the virtual switches, a total of three switches in addition to the PIR/MCS/Siren, and four Blocky Events.

I haven't written a single line of Lua until today so I apologize for how badly it's written. Refactoring to follow. The following code describes the requirements of this script and how it's integrated. I left the debugging code and other comments to show how this was conceived.

I hope this helps someone.

script_device_alarm.lua

Code: Select all

--[[
Community Alarm Script v1.0
-----------------
Script is based off an alarm script based from a forum posting by 'heggink',
a Domoticz forum user.

The contributed script was a good start as it provided information of
Domoticz's Lua inner workings. Other than the idea and general flow,
this version doesn't share a lot of similarities.

This feature requires the use of Lua and 'Blocky' elements. This script
should not be considered a complete alarm solution. I'm planning on
integrating Philips Hue, IP cameras and so forth to record intruders.

Requirements:
-------------
Virtual switches:
- vsAlarmDetected - Responsible for triggering of Blocky events
- vsSirenTrigger  - Executes Blocky events responsible for the disarm delay,
                    and eventual trigger of the siren. This was created
                    because Domoticz doesn't have the ability to trigger an
                    intrusion event, fire off the sirens and provide sufficient
                    time to disarm like you would with a proper alarm install
- vsFireSiren     - Responsible for firing siren. In this example, it uses a
                    Vision ZM1606 (Z-Wave) siren

Blocky:
- Alarm_Detected_Events - This is responsible for the siren and notification
                          action once Lua parses the device events.
                          vsAlarmDetected set by Lua is the trigger
- Alarm_Trigger_Sirens  - Triggered by the On status of vsSirenTrigger; resp-
                          onsible for the possible firing of the siren. The
                          time delay introduced by the previous Blocky gives
                          users time to disarm before this sets the virtual
                          switch svFireSiren to ON
- Alarm_Acivate_Sirens  - Triggered by svFireSiren. It will send an email notif-
                          ication to indicate the siren is on and will proceed
                          to set the virtual switches used here to Off.
- Alarm_Reset_Disarm    - When security system is disarmed, it clears all
                          virtual switches used. It also turns off the siren
                          if it's accidentally trigged (ie, the delay is
                          insufficient to disarm the system due to the groceries
                          and key fumbling)
Flow:
-----
- Lua script enumerates through device changes to filter out switches
  that starts with MCS or PIR
- Determines if Domoticz's security feature is in use
- If PIR/MCS triggered and the security system is armed, this script follows
  two code paths
  - If armed home (meaning you're at home), it ignores PIR events
  - If armed away, all PIR and MCS events will trigger the alarm sequence
- If script determines this is an actionable event, it sets a virtual
  switch called vsAlarmDetected to On
- Blocky 'Alarm_Detected_Events' sets two other virtual switch:
  - vsAlarmDetected to Off after 20 seconds
  - vsSirenTrigger to On after 20 seconds
- Block 'Alarm_Trigger_Siren' executes once vsSirenTrigger is set to On AND
  the security system hasn't been disarmed. If these conditions matches, it
  will preform the following:
  - sets vsFireSiren to On after 1 second if security system hasn't been disarmed.
    - NOTE: In essence, the previous Block event and the 20 second delay introduced
      in the vsSirenTrigger variable set is the delay between a door opening and
      disarming of alarm system
  - If system disarmed, or vsSirenTrigger is Off, the else conditional will
    clear all virtual switch variables responsible for this alarm script
- If svFireSiren is still On at this stage, the Blocky event
  'Alarm_Activate_Siren' fires and will perform the following:
  - Sets a switch responsible for the Siren function (ZM1606 used here)
    to the On state for 1 minute
  - Sends email notification to inform us of the siren trigger
  - Clears the virtual switch variables used by this alarm script

Notes:
------
- This script discards door closes and PIR inactivities once triggered
  to prevent misfires of the siren. The Blocky events responsible for
  the rest of the alarm system doesn't require frequent updates once
  the variable of vsAlarmDetected is set to On
- Blocky events doesn't seem to trigger when an user variable changes.
  It seems to react to only switches and time events (bummer)

Reference:
----------
Based off:
Title: script_device_MCSAlarm.lua
Date: 2015-11-12
URL: https://www.domoticz.com/forum/viewtopic.php?f=38&t=9031&p=62952
]] --

commandArray = {}

debug = 0
local trigger_alarm = 0
local alarm_mode = 'off'
local device_state = ''

-- Gather all devices changed

device = next(devicechanged)
device_switch = tostring(device)
device_type = device_switch:sub(1,3)
device_state = tostring(otherdevices[device_switch])

function debug_msg (msg)
    if (debug == 1) then
        print('ALARM DEBUG: '.. msg)
    end
end

if (debug == 1) then
    -- print ('DEBUG: '.. device_type)
    -- print ('DEBUG: '.. otherdevices['Security Panel'])
    -- print ('DEBUG: '.. globalvariables['Security'])

    -- for i, v in pairs(devicechanged) do debug_msg(i ..'--'.. v) end
    -- for i, v in pairs(globalvariables) do debug_msg(i, v) end
    for i, v in pairs(otherdevices) do debug_msg(i ..'--'..  v) end

    if not otherdevices['vsAlarmDetected'] then
        debug_msg('Where is my virtual switch?')
    else
        debug_msg('switchie is found!')
    end
end

if (device_type == 'PIR' or device_type == 'MCS') then
    alarm_mode = globalvariables['Security']

    print('Alarm_Script: Security Panel set to - '.. alarm_mode)
    print('Alarm_Script: Device detected - ('.. device_type ..') - '.. device_switch ..' - '.. device_state)

    if (string.match(alarm_mode, 'Armed [Away|Home]')) then
        -- Filter PIR trigger and MCS open events
        if ((device_type == 'PIR' and device_state == 'On') or (device_type == 'MCS' and device_state == 'Open')) then

            -- Trigger conditions
            -- Home mode:
            if (alarm_mode == 'Armed Home' and device_type == 'PIR') then
                debug_msg('Home mode ('.. alarm_mode ..') enabled -- '..  device_type ..' detected movement, not triggering alarm.')
                trigger_alarm = 0
            else
                trigger_alarm = 1
            end

            if (trigger_alarm == 1) then
                if (debug == 1) then
                    debug_msg('device state: '.. devicechanged[device])
                else
                    notify_sub = '[HOME ALARM] '.. device_switch ..' - '.. device_state ..' - device triggered'
                    notify_msg = '[HOME ALARM] '.. device_switch ..' - '.. device_type ..' device triggered'
                    commandArray['SendNotification'] = notify_sub..'#'..notify_msg
                end

                -- Triggering Notifications and Sirens via Blocky
                commandArray['Variable:AlarmDetected'] = '1'
                commandArray['vsAlarmDetected'] = 'On'
            end
        else
            print('Alarm: '.. device_type ..' ('.. device_state ..') - skipping alarm notifications.')
        end
    end
end

-- tc=next(devicechanged)
-- MCS_switch=tostring(tc)
-- if (MCS_switch:sub(1,3) == 'MCS') then
--    if(otherdevices['Security Panel'] == 'Arm Away') then
--       print('MCS motion detected:'..MCS_switch)
--       commandArray['SendNotification']='MCS motion detected:'..MCS_switch
--       commandArray['Variable:AlarmDetected'] = '1'
--    end
-- end
--
-- tc=next(devicechanged)
-- PIR_switch=tostring(tc)
-- if (PIR_switch:sub(1,3) == 'PIR') then
--    if(otherdevices['Security Panel'] == 'Arm Away') then
--       print('PIR motion detected:'..PIR_switch)
--       commandArray['SendNotification']='PIR motion detected:'..PIR_switch
--       commandArray['Variable:AlarmDetected'] = '1'
--    end
-- end

return commandArray
Hardware: RPI2, RazBerry, Vision PIR, Door sensors and Sirens using Debian Wheezy with a compiled version of OpenZWave and Domoticz from their respective git repositories.

Thanks Heggink for your notes.

Re: Alarm system 'wiki'

Posted: Friday 27 November 2015 22:57
by heggink
Final 'product' now at: http://www.domoticz.com/wiki/Alarm_Setup

Next steps:

1) notify "Armed away" to those that need to know

2) audible reminder that the alarm is on and those that entered the house have limited time to disarm
=> not figured this out just yet as the zipato keypad does have a notification sound but it's very limited and only works if you enter through a door that is close to the keypad so you can hear it. Also requires a wakeup of the keypad. IMO not a very practical option. Alternative is to have a siren do a short blip (fast on/off) but I am not sure if that can be done with a z-wave siren. It did not work for me using a regular smoke detector and a blocky. I'll try the z-wave siren (eminent) tomorrow. I suspect a similar challenge. Input/help appreciated.

@user9142313: glad it helped. I wanted to limit the lua as much as possible so even non programmer/lua people could build a system. I managed to get it to work with only variables (used string variables to ease compatibility between blocky and lua but should have used booleans but these don't exist).

Re: Alarm system 'wiki'

Posted: Tuesday 22 December 2015 23:49
by maomanna
im busy with your alarm system which is described at the wiki

All motionsensors named PIR_naamx
the zipato keypad is named Keypad Alarm Level

made the variables and blocky's.

The keypad changes states from on to off and visaversa.

When I trigger a PIR_ sensor trigger, I see that in the log

quote:
2015-12-22 22:36:24.311 OpenZWave: Alarm Level: Tamper
2015-12-22 22:36:24.321 LUA: AlarmPanel Arm Away
2015-12-22 22:36:24.312 (Zwaveusb) Lighting 2 (Keypad Alarm Level)
2015-12-22 22:36:24.367 (Zwaveusb) Lighting 2 (Unknown)
2015-12-22 22:36:46.998 (Zwaveusb) Lighting 2 (PIR_SKvoor)
Nthing happens, not even a notification

any idea?

Re: Alarm system 'wiki'

Posted: Thursday 24 December 2015 9:38
by heggink
Maybe: I noticed that after an upgrade (beta), a variable change through lua no longer triggered a blocky event. I have reported it to development but implemented a work around by replacing all the variables with dummy switches. These still work unlike the variables. Not sure what version you are on but you may have found the same issue.

Re: Alarm system 'wiki'

Posted: Monday 28 December 2015 22:35
by maomanna
after the tip from heggink to change the user variables with dummyswitches, I took the same idea, but try to do it with blockly.

This is what I come up with atm.
Dummyswitches:
Image

Set alarm:
Image

Motiondetection
Image

Set Siren:
Image

SoundSiren:
Image

Alarmoff:
Image


after a short test it worked, but didnt test it with delays etc.
Also the switch SoundAlarm doesnt switch everytime when AlarmDetect is switched on.
Someone know how to fix this?

Re: Alarm system 'wiki'

Posted: Tuesday 29 December 2015 21:50
by nayr
nice, this was needed.. there was basically nothing when I started down this road.

I am using Domoticz for alarm system but in a slightly different way, bit simpler.. We have a couple dogs (they will bark at night, but on other hand need to go potty at night without setting off an alarm) and weird hours so have no use for a Night-Armed mode, basically everything is Away or not so instead of using the security panel I just created a variable called away, a timed script that checks for our presence and toggles away on or off.. and each security sensor has a script saying if the sensor is activated and away is set then spam out notifications with urgency.. otherwise silently capture a photo from the nearest camera and store it in gmail (filters keep it silent) for offsite logging purposes.. (my outdoor cameras record 24/7/365 to my Domoticz server via FTP on there own vlan)

For presence detection I use a combination of Geofencing apps on mobile devices and ping scripts on my x509 auth wifi network (Both our phones must be offline or manually trigger armed externally).. My Domoticz is routed directly to the internet behind a hardened nginx proxy configured for x509 authentication required (using same cert for wifi access).. only https/ssh are open outside, and all require certificates.. no passwords allowed, im not worried about brute forcing.. if a device gets lost or stolen I can simply the revoke its cert or re-key everything.. I do have a VPN setup (also x509 auth) but thats mainly for viewing my IPCameras real time feed remotely; forcing VPN on my wife's phone was not approved by her.. most of the cert auth stuff was setup for wife approval, simply she would not have to login with a secure passphrase each time, I could just authorize each device and be done with it.

now I need to setup two factor authentication, and backup incase the phone is dead or unavailable.. I have Cisco VoIP phones throughout the house I can push an XML menu to, I am thinking of putting a keypad input for arming/disarming the security system on these and putting a prox card reader near the front door.. if you come home use the prox card and system will disarm, if you come home and your phone is dead use prox card and input pin number into nearest phone.. or use prox card to arm system as you walk out the door for instant arming.

Combination of Wired and Z-Wave sensors, wired sensors go to beaglebone blacks with opti-io boards running Domoticz slave nodes and a bit of code to update the sensors/devices.

Re: Alarm system 'wiki'

Posted: Wednesday 30 December 2015 23:55
by heggink
This is pretty close to what I implemented and what works really well for me.

Re: Alarm system 'wiki'

Posted: Friday 01 January 2016 23:22
by maomanna
My blokcly seems to work as a charm!

I made an extra check (IemandThuis), if that one is on, then turn off the virtual switches and siren (send off signal, even when its off).
Still I need to disarm with the keypad, to change the state to off.

It also seems that the fibaro Smokesensor isnt working that well, so I switched it for my Everspring Siren.

Re: Alarm system 'wiki'

Posted: Tuesday 05 January 2016 14:56
by spyseiko
Pretty neat you figured it out, i'm also trying to build a z-wave alarm setup with aeonlabs sensors and siren.
I will be testing you're scripts this weekend hope it will all work.

The only thing i couldn't figure out is the "Iemand thuis" variable how did you configure that one ?