Connecting a cheap Home Alarm System to OpenHAB

Creating a smart home Alarm using OpenHAB

When I moved into my new house a couple of years ago, there was already an alarm
system in place. This alarm was a typical cheap Chinese home alarm system that
you can buy on aliexpress or similar place.

The alarm system I have is branded as a HomeSecure Basic v2 which is a rebranded
cheap alarm. The alarm supports GSM, you can interact with it using text messages (SMS) and it can call you in case it goes off and you can listen using built in microphone.
There is also a built in battery so if power goes out you will get a text message warning you.

However the base functionality is quite good in my opinion, but you lack home automation integration. There is no apparent way to connect it to OpenHAB.

The alarm system is operating using 433 MHz, it has a wired siren and wireless door sensors, motion detectors and keypad. You can arm the alarm using a keyfob remote or the wirelss key pad.

In order to connect it to OpenHAB I started by building an RFLink. RFLink is an really nice option if you want to control 433MHz devices. It’s cheap and robust and you can build it yourselfby just ordering the parts.

http://www.rflink.nl/blog2/


Once I had a RFLink, I could mimic the keyfob, and thus arming and disarming the alarm
using RFLink. Other options if you have a 868.x MHz alarm is to build yourself something that pushes the buttons on a remote, for instance:

https://bitbucket.org/iesus_sonesson/d1-ajax-mqtt/src/master/

This could probably be enough to do some automation but in order to actually read the state of
the alarm I hooked it up to a Fibaro Smart Implant.

I want to do two things with the Smart Implant

  • Detect if the alarm is silent or transmitting the alarm signal
  • Detect whether the alarm is armed or unarmed

The Fibaro smart implant can read up to two binary inputs. The Home Alarm is outputting 12V DC when for instance the alarm is triggered on the siren. Therefor I would fry the Smart Implant if I would put 12V DC on it. In order to cope with that I attached a 4 pole relay. When the relay receives 12VDC it will shut the circuit (Normally Open NO) and you can get a binary signal out from that. With the help of the relay we can tell if the alarm is sounding by attaching it in parallel with the Siren/speaker. It also possible to attach additional sirens/speakers to the relay if you want that.

Picture of the relay

The same principal goes for the detection if the alarm is on or off. By attaching the the out signal from the homealarm (binary) to the smart implant we can tell whether the alarm is activated or not. This option is available on most alarms.

Here is a sketch of my alarm together with the relay and the 12VDC power source:

As you can see from the picture, I’m feeding pin 3 and 4 12VDC.
The speaker is connected to pin 7 and 8 which mean that pin 5 and 6 will
output a binary signal when the alarm is sounding, therefor pin 6 goes to the smartimplant.
If you want to add an additional speaker you would connect it to minus 12VDC on the power source and pin 5 which will carry 12VDC in case the alarm is sounding.

All wires connect in closure:


To wrap up. With the help of a relay and a smart implant we are able to detect if the alarm is sounding and we can tell whether the alarm is armed or unarmed by looking at the output at the alarm. This somewhat dumb alarm has become smart we can now using OpenHAB do the following:

  • Determine if the alarm is sounding or is silent.
  • Determine if the alarm is armed or unarmed
  • Turn the alarm on and off (arm and unarm)

Since we use OpenHAB as a platform we can leverage this to do all sorts of stuff. For instance I have the following features implemented:

  • Automatically turn the alarm off if it detects my phone as presence (See presence detection)
  • Warn if the alarm is armed and you are entering, this can be done with text-to-speech with Alexa or GoogleHome for instance.
  • Send push notification if the alarm is triggered or if it’s turned on or off
  • Do text to speech warning when you are turning the alarm on to leave the house
  • Turn on all lights or blink with lights if someone triggers the alarm
  • Play customized message using google home, alexa, sonos etc if the alarm is triggered

This is an example of what a simple setup can look like in OpenHAB (using the expire binding)

Alarm.items

Group Alarm <alarm>

Switch AlarmArm      "Arm Home Alarm"  <lock>                                 (Alarm) {expire="3s,command=OFF"}
Switch AlarmDisarm   "Disarm Home Alarm"          <unlock>                         (Alarm) {expire="3s,command=OFF"}
String AlarmNotificationMqtt                 "Home Alarm Disarm System"                   (Alarm)    { channel="mqtt:topic:drakemqtt:homealarm:notification" }

zwave.items

// Z-Wave Fibaro Smart Implant 
/////////////////
Group ZwaveSmartImplant1             "Alarm SmartImplant"                                         (Zwave)
Switch ZwaveSmartImplant1Alarm1   "Alarm SmartImplant Alarm Input 1 [%s]"   <switch>            (ZwaveSmartImplant1)  { channel="zwave:device:4b6916d0:node48:aAlarm_burglar1" }
Switch ZwaveSmartImplant1Alarm2   "Alarm SmartImplant Alarm Input 2 [%s]"   <switch>            (ZwaveSmartImplant1)  { channel="zwave:device:4b6916d0:node48:aAlarm_burglar2" }

alarm.rules

val LOG_HOME_ALARM="ALARM"

rule "Disarm Home Alarm"
when
  Item AlarmDisarm changed to ON
then
  logInfo(LOG_HOME_ALARM, "Home Alarm Disarm signal sent!")
  RFLinkHomeAlarmDisarm.sendCommand(ON)
  RFLinkHomeAlarmDisarm.postUpdate(OFF)
end

rule "Arm Home Alarm"
when
  Item AlarmArm changed to ON or
  Item TestHomeAlarmArm changed to ON
then
    logInfo(LOG_HOME_ALARM, "Home Alarm Arm signal sent!")
    val String message = "HomeAlarm is now going to be Armed!"
    NotifyHomeAlarm.sendCommand(message)
    NotifySlack.sendCommand(message)
    AlexaTTS.sendCommand("Warning Home Alarm is soon armed! Leave building!")                                     
    createTimer(now.plusSeconds(5), [|
    AlexaTTS.sendCommand("Warning Home Alarm is soon armed! Leave building! Second warning")
              ])
    createTimer(now.plusSeconds(10), [|
            AlexaTTS.sendCommand("Warning Home Alarm is soon armed! Leave building! Final warning")
                                         ])
    if (TestHomeAlarmArm.state != ON) {
        createTimer(now.plusSeconds(15), [|
            RFLinkHomeAlarmArm.sendCommand(ON)     
       ])
    }
end

rule "Home Alarm Armed"
when
  Item ZwaveSmartImplant1Alarm2 changed to ON or
  Item TestHomeAlarmArmed changed to ON
then
  logInfo(LOG_HOME_ALARM, "Home Alarm is Armed!")
    AlexaTTS.sendCommand("Warning Home Alarm is now armed! Leave building!")                                     
    createTimer(now.plusSeconds(5), [|
     AlexaTTS.sendCommand("Warning Home Alarm is now armed! Leave building! Second warning")                                       ])
    createTimer(now.plusSeconds(10), [|
            AlexaTTS.sendCommand("Warning Home Alarm is now armed! Leave building! Final warning")
                                         ])
end

rule "Home Alarm Triggered!"
when
  Item ZwaveSmartImplant1Alarm1 changed to ON
then
  logInfo(LOG_HOME_ALARM, "Home Alarm is Triggered!")
     val String message = "HomeAlarm is triggered and is sounding!"
    NotifyPushbullet.sendCommand(message)
end

Sitemap:

sitemap homeAlarm label="Home Alarm" {
    Frame {
		 Group item=Alarm {
            Text item=ZwaveSmartImplant1Alarm2 label="Alarm Status [MAP(alarmstatus.map):%s]"
            Text item=ZwaveSmartImplant1Alarm1 label="Alarm Siren [MAP(alarm.map):%s]"
            Switch item=AlarmArm
            Switch item=AlarmDisarm
        }
	}
}

transform:

alarmstatus.map

ON=Armed
OFF=Disarmed
-=-
undefined=-
uninitialized=-
NULL=-

alarm.map

ON=Alarm!
OFF=Silent
-=-
undefined=-
uninitialized=-
NULL=-

6 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.