Alarm in openhab

1,581 views
Skip to first unread message

and...@mindchill.com

unread,
Aug 17, 2014, 2:24:44 PM8/17/14
to ope...@googlegroups.com
Hi

Anybody got any experience of implementing a house alarm system using openhab and zwave sensors, door contacts and siren.

Any thoughts on how guests could turn it on/off, any keypads compatible with openhab.

Any thoughts appreciated

Thx
Andy

FredF

unread,
Aug 17, 2014, 2:30:07 PM8/17/14
to ope...@googlegroups.com, and...@mindchill.com
I think that implementing an alarm system based on zwave is a very bad idea : the zwave system is *VERY* easy to interfere using very cheap portable electronic devices available everywhere on the internet.

Modern certified alarm system use interference proof transmission, with random frequencies change, to solve this problem. As far as I know, the zwave system does not implement such kind of security feature.

So, again, using plain standard zwave to implement an alarm system is a very bad idea...

Joe Barneson

unread,
Aug 17, 2014, 2:39:04 PM8/17/14
to ope...@googlegroups.com, and...@mindchill.com
I would be interested in "arming" my house while i'm gone to be notified of unusual behavior. I'm not that concerned if someone jammed all the z-wave frequencies bc I doubt I'm a high value target with even mildly sophisticated burglars or hoodlums. I wouldn't intend hooking up the alarm system to call service - but having it notify my phone of something unusual would be great... I too would be interested if anyone has had experience setting this up 

nwe...@gmail.com

unread,
Aug 18, 2014, 6:02:40 PM8/18/14
to ope...@googlegroups.com
Ditto on the above 1st and 3rd post.

in regards to security, lots of security equipment uses 433MHz one way communication and has to protection at all. Very easy to hack or just break the window and come in.
Neil.

Robert Bausdorf

unread,
Aug 19, 2014, 7:22:47 AM8/19/14
to ope...@googlegroups.com, and...@mindchill.com


Am Sonntag, 17. August 2014 20:39:04 UTC+2 schrieb Joe Barneson:
I would be interested in "arming" my house while i'm gone to be notified of unusual behavior. I'm not that concerned if someone jammed all the z-wave frequencies bc I doubt I'm a high value target with even mildly sophisticated burglars or hoodlums. I wouldn't intend hooking up the alarm system to call service - but having it notify my phone of something unusual would be great... I too would be interested if anyone has had experience setting this up 


Yesterday I finished such a task ... ;-)
I had an very old and no more working alarm system in my House - a small Box with a 2-way key switch an some LED. There are simple wired Reed contacts in the entry doors an a siren on the outside.

So I removed the old electronic part from the alarm box an replaced it by a Raspberry Pi with the PiFace Digital I/O addon. This addon has a working openHAB binding. I wired the Reed contacts from the doors and the key switch of the alarm box to some input pins of the PiFace. The siren an the electric door opener for the outer gate I wired to the two low voltage relais on the PiFace and the LEDs of the alarm box to the Piface output pins.

The key switch puts the system from off state (no logging / alerting) to notify state (only logging, no alerting) or armed state (logging and alerting). If armed and one of the entry doors is opened (even shortly) an one minute timer starts. After expiration of this minute, an email is send containing the state history of each door during the last minute. If the key switch is put to notification  state within this minute no mail is sent and the alarm is only logged, if the key switch is put to off state nothing happens.

If I receive an alarm mail (or NMA notification with which im experimenting right now) I can decide to call the police or call my neighbour (who is a friend an has a key for the alarm box) to take a look. If the alarm is not acknowleded within 10 Minutes (by requesting a special URL or by operating the key switch on the alarm box) the siren is switched on. As a goody I can open the outer gate from every computer, tablet or smartphone then the door bell rings ... :-)
In addition to alerting i'm using the gcal binding to have a cronological history of alarm events in a google calendar.

I will see how this setup behaves in real live ...

Regards,
Robert

Richard Trenchard

unread,
Aug 19, 2014, 9:30:14 AM8/19/14
to ope...@googlegroups.com
Would you mind passing on a sanitised version of you setup files please

Regards

Richard


--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Robert Bausdorf

unread,
Aug 19, 2014, 4:23:54 PM8/19/14
to ope...@googlegroups.com
Am Dienstag, 19. August 2014 15:30:14 UTC+2 schrieb Richard Trenchard:
Would you mind passing on a sanitised version of you setup files please

Regards

Richard

 
Hi Richard,

Here are the relevant items:

*** snip ***
Group ALL
Group gEG (All)
Group gTG (All)

Group:Contact:OR(OPEN, CLOSED) Doors "Doors [(%d )]" <door> (All)
Group:Contact:OR(OPEN, CLOSED) Gates "Gates [(%d )]" <door> (All)

Contact EG_Frontdoor "Entry door [MAP(de.map):%s]" <door> (gEG,Doors) { piface="piface1:IN:5" }
Contact TG_Frontdoor "Basement door [MAP(de.map):%s]" <door> (gTG,Doors) { piface="piface1:IN:4" }
Contact GATE_Front "Front gate [MAP(de.map):%s]" <door> (Gates) { piface="piface1:IN:3" }
Contact GATE_Carport "Carport [MAP(de.map):%s]" <door> (Gates) { piface="piface1:IN:2" }

Contact Doorbell "Doorbell [MAP(de.map):%s]" <siren> (gEG) { piface="piface1:IN:1" }
Contact AL_IN_Intruder "Intruder [MAP(de.map):%s]" <siren> (gEG,Alarm) { piface="piface1:IN:0" }

Group Alarm
Number Main_Switch "Key switch" <network>         (All)
Switch AL_IN_Monitoring "Monitoring" <light> (Alarm) { piface="piface1:IN:6" }
Switch AL_IN_ON "Scharf" <light> (Alarm) { piface="piface1:IN:7" }

Switch AL_OUT_R1 "Door opener" <siren> (Alarm) { piface="piface1:OUT:1" }
Switch AL_OUT_R2 "Sirene" <light> (Alarm) { piface="piface1:OUT:0" }
Contact AL_OUT_Main "System" <light> (Alarm) { piface="piface1:OUT:3" }
Contact AL_OUT_Entry "Eingang / Ausgang" <light> (Alarm,PresenceSimulationGroup) { piface="piface1:OUT:4" }
Contact AL_OUT_Line1 "Line 1" <light> (Alarm) { piface="piface1:OUT:5" }
Contact AL_OUT_Line2 "Line 2" <light> (Alarm) { piface="piface1:OUT:6" }
Contact AL_OUT_Intruder "Eindringling" <light> (Alarm) { piface="piface1:OUT:7" }
*** snap ***

The relevant ruleset is as follows:

*** snip ***
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

// Timer for door opener
var Timer timer = null

// Timer for alarm mail 
var Timer mailTimer = null

// Timer for alarm mail 
var Timer sirenTimer = null

// Alarm mail text
var String mailtext = ""

// Last caller ID on FB 
var String lastCallNo = ""

// executed when system starts
rule "Startup"
when
System started or
Time cron "0 0/5 * * * ?"
/*
 * order for cron expressions
 * 1. Seconds
 * 2. Minutes
 * 3. Hours
 * 4. Day-of-Month
 * 5. Month
 * 6. Day-of-Week
 * 7. Year (optional field)
 */
then
// switch main power led - it shows that openHAB is up and running
sendCommand(AL_OUT_Main, OPEN)
sendCommand(AL_OUT_Main, CLOSED)
// poll key switch state to set alarm main switch item state correctly at startup
if(AL_IN_ON.state == ON) {
postUpdate(Main_Switch, 2)
} else if( AL_IN_Monitoring.state == ON ) {
postUpdate(Main_Switch, 1)
} else {
postUpdate(Main_Switch, 0)
}
logInfo("Alarm", "System ok")
// remove if correctly wired
postUpdate(GATE_Carport, CLOSED)
postUpdate(GATE_Front, CLOSED)
postUpdate(AL_OUT_Line1, OPEN)
postUpdate(AL_OUT_Line2, OPEN)
postUpdate(AL_OUT_Intruder, OPEN)
end

// only executed if "shutdown" ist typed at osgi console :-(
rule "Shutdown"
when
System shuts down
then
sendCommand(AL_OUT_Main, OPEN)
sendCommand(AL_OUT_Entry, OPEN)
logInfo("Alarm", "shut down")
end

// capture changes on key switch to/from monitoring position (only notification)
// and set correct Main_Switch item state
rule "Monitoring Switch"
when
Item AL_IN_Monitoring received update
then 
if( AL_IN_Monitoring.state == ON ) {
if( AL_IN_ON.state == ON ) {
logInfo("Main Switch", "set to ON")
postUpdate(Main_Switch, 2)
} else {
postUpdate(Main_Switch, 1)
logInfo("Main Switch", "set to Monitoring")
}
} else {
if( AL_IN_ON.state == ON ) {
logInfo("Main Switch", "set to ON")
postUpdate(Main_Switch, 2)
} else {
logInfo("Main Switch", "set to OFF")
postUpdate(Main_Switch, 0)
}
}
end

// capture changes on key switch to/from alerting position
// and set correct Main_Switch item state
rule "On Switch"
when
Item AL_IN_ON received update
then 
if(AL_IN_ON.state == ON) {
logInfo("Main Switch", "set to ON")
sendCommand(Main_Switch, 2)
} else {
if( AL_IN_Monitoring.state == ON ) {
logInfo("Main Switch", "set to Monitoring")
postUpdate(Main_Switch, 1)
} else {
logInfo("Main Switch", "set to OFF")
postUpdate(Main_Switch, 0)
}
}
end

// Reset alarm mail text in notification and off state.
// Experiments with NMA actions.
rule "Main Switch actions"
when
Item Main_Switch changed
then
if(Main_Switch.state == 2) {
notifyMyAndroid("Hauptschalter", "AN")
} else if( Main_Switch.state == 1 ) {
notifyMyAndroid("Hauptschalter", "STILL")
mailtext=""
// switch siren off or cancel siren timer
sendCommand(AL_OUT_R2, OFF)
if( sirenTimer != null ) {
sirenTimer.cancel()
sirenTimer = null
}
} else {
mailtext=""
// switch siren off or cancel siren timer
sendCommand(AL_OUT_R2, OFF)
if( sirenTimer != null ) {
sirenTimer.cancel()
sirenTimer = null
}
}
end

// No changing commands on Main_Switch item is allowed  
rule "Main Switch GUI"
when
Item Main_Switch received command
then
if(AL_IN_ON.state == ON) {
postUpdate(Main_Switch, 2)
} else if( AL_IN_Monitoring.state == ON ) {
postUpdate(Main_Switch, 1)
} else {
postUpdate(Main_Switch, 0)
}
end

// Collect door states when in alerting mode
rule "Front Doors"
when
Item TG_Frontdoor received update or
Item EG_Frontdoor received update
then
if( TG_Frontdoor.state == OPEN || EG_Frontdoor.state == OPEN ) {
if( Main_Switch.state == 2 ) {
mailtext=mailtext+"Geoeffnet wurde: "
if( EG_Frontdoor.state == OPEN ) {
mailtext= mailtext + "Haustuer\n"
}
if( TG_Frontdoor.state == OPEN ) {
mailtext= mailtext + "Kellertuer\n"
}
}
sendCommand(AL_OUT_Entry, OPEN)
} else if( TG_Frontdoor.state == CLOSED && EG_Frontdoor.state == CLOSED ) {
sendCommand(AL_OUT_Entry, CLOSED)
}
end

// Collect gate states when in alerting mode
rule "Gates"
when
Item GATE_Front received update or
Item GATE_Carport received update
then
if( GATE_Front.state == OPEN || GATE_Carport.state == OPEN ) {
if( Main_Switch.state == 2 ) {
mailtext=mailtext+"Geoeffnet wurde: "
if( GATE_Front.state == OPEN ) {
mailtext= mailtext + "Eingangstor\n"
}
if( GATE_Carport.state == OPEN ) {
mailtext= mailtext + "Rolltor\n"
}
}
// sendCommand(AL_OUT_Entry, OPEN) //currently not wired
} else if( GATE_Front.state == CLOSED && GATE_Carport.state == CLOSED ) {
// sendCommand(AL_OUT_Entry, CLOSED) //currently not wired
}
end

// start alarm timer if doors are opened
rule "Entry Alarm"
when
Item Doors changed
then
if( Doors.state == OPEN ) {
if( mailTimer == null ) {
logInfo("Alarm", "start timer for action")
// create one minute alarm timer
mailTimer = createTimer(now.plusSeconds(60)) [|
mailtext=mailtext+"Geoeffnet sind:\n"
if( EG_Frontdoor.state == OPEN ) {
mailtext= mailtext + "Haustuer\n"
}
if( TG_Frontdoor.state == OPEN ) {
mailtext= mailtext + "Kellertuer\n"
}
// if( GATE_Front.state == OPEN ) {
// mailtext= mailtext + "Gartentor\n"
// }
// if( GATE_Front.state == OPEN ) {
// mailtext= mailtext + "Carport\n"
// }
if( Main_Switch.state == 2 ) {
// only send mail if still in alerting mode
logWarn("Alarm", "send mail: " + mailtext)
sendMail("my.e...@address.de", "ALARM: Tür geöffnet!", mailtext)
mailtext="";
} else if( Main_Switch.state == 1 ) {
// if in notification mode, write mailtext to log
logWarn("Alarm", "monitoring: " + mailtext)
else {
// something happened with the doors (just for debugging)
logInfo("Alarm", "off:doors")
}
mailTimer = null
]
// create 10 minutes siren timer
sirenTimer = createTimer(now.plusSeconds(600)) [|
// make noise
sendCommand(AL_OUT_R2, ON)
sirenTimer = null;
]
}
}
end

// Operate dooropener relais from GUI :-) 
rule "Dooropener"
when
Item AL_OUT_R1 received command
then
if(receivedCommand==ON) {
if(timer==null) {
// first ON command, so create a timer to turn the opener on
timer = createTimer(now.plusSeconds(3)) [|
// after 3 sec turn the opener off
sendCommand(AL_OUT_R1, OFF)
]
} else {
// subsequent ON command, so reschedule the existing timer
timer.reschedule(now.plusSeconds(3))
}
} else if(receivedCommand==OFF) {
// remove any previously scheduled timer
if(timer!=null) {
timer.cancel
timer = null
}
}
end

*** snap ***

Active addons are:

org.openhab.action.mail-1.5.0.jar
org.openhab.action.nma-1.5.0.jar
org.openhab.binding.ntp-1.5.0.jar
org.openhab.binding.piface-1.5.0.jar
org.openhab.persistence.gcal-1.5.0.jar
org.openhab.persistence.rrd4j-1.5.0.jar
org.openhab.binding.http-1.5.0.jar

Not alarm relevant but used:
org.openhab.binding.fritzbox-1.5.0.jar


With this setup the load on my RasPi is between 1 and 1.5 - I think thats ok but it also shows that there is not much capacity left.

Hope it helps -
Robert

Richard Trenchard

unread,
Aug 20, 2014, 9:11:54 AM8/20/14
to ope...@googlegroups.com
thankyou that will be a great help

Robert Bausdorf

unread,
Aug 21, 2014, 10:25:11 AM8/21/14
to ope...@googlegroups.com
An additional tip: 
I experienced unintended and fast open/close triggering on PiFace inputs when using longer wires - especially when using bell wire transmitting low AC voltage like needed for bells or door openers. Because of the sensitivity of the open collector inputs on the piface even the slightest potential as captured from electrical interference does trigger the input. The switchable input pullup resistors on the PiFace are too weak if the interference is to high.

In my case even stronger additional pullups did not solve the problem. I needed to put a small capacitor (< 1µF) between the input pin and the ground contact. After that the input behaved as expected.

Without capacitor, the interference measured by a voltmeter reached peaks up to 100 mV, with capacitor the peeks do not exceed 15 mV.

If the switchable pullups on the PiFace turn off for some reason (as they did yesterday when I thougt I was ready :-( ) every input pin did trigger fast when open. The only solution for that was to shutdown openHAB and the ohpiface.py script, start and stop the pifacedigital-emulator (wich turns the pullups on initially) and finally restart the ohpiface.py script and openHAB

Took me a whole day to figure that out ... ;-)

and...@mindchill.com

unread,
Aug 26, 2014, 5:07:59 PM8/26/14
to ope...@googlegroups.com
HI

I have decided to go with an Alarm System (Visonic Powermaster) and hope that I can use the sensors to drive automation as well as the alarm,

Anyone know of any development on a Powermaster binding, if not I will probably try and develop one myself, the protocol is reasonably well documented on other forums.

Any thoughts, info to point me in the right direction would be much appreciated

Thx
Andy
Reply all
Reply to author
Forward
0 new messages