A different take on an alarm system

I wanted to put together a simple alarm system so I started with the manual alarm control panel and branched out a little. There are two pieces. The primary component (custom_components/alarm_control_panel/bwalarm.py) and the frontend panel (panels/alarm.html).

The component uses the same interfaces as the other alarm control panels but adds a state (warning) for a state when a delayed trip happens. It also does all the logic in the component (see process_event function), you only specify what sensors to use in the configuration.

The panel provides an overview of what inputs sensors are active as well as a heads up of any currently open sensors (or additional items to watch like locks).

As most of my stuff, its all up on github at https://github.com/drytoastman/haconfig/

The main configuration file has:

alarm_control_panel: !include alarm.yaml
panel_custom:
    - name: alarm
      sidebar_title: Alarm
      sidebar_icon: mdi:security-home
      config:
          alarmid: alarm_control_panel.house

The alarm.yaml contains:

platform: bwalarm
name: House
pending_time: 30
trigger_time: 600
alarm: switch.alarm
warning: switch.warning
headsup:
    - lock.backdoorlock_locked_17_0
    - lock.frontdoorlock_locked_16_0
    - binary_sensor.garagedoor
immediate:
    - binary_sensor.bedroomslider
    - binary_sensor.diningwindow
    - binary_sensor.littlewindow
    - binary_sensor.livingroomwindow
    - binary_sensor.officewindow
    - binary_sensor.patioslider
delayed:
    - binary_sensor.frontdoor
    - binary_sensor.backdoor
    - binary_sensor.primarymotion
notathome:
    - binary_sensor.primarymotion

And a few pics of the panel:

31 Likes

This is pretty cool actually. I’m working to replace my Control 4 setup with Home Assistant, and I’ve been thinking I’d have to get the Envisalink board to interface with my DSC alarm system, but I might actually go this route.

Is there some sort of alarm hooked up that goes off when something is triggered when it’s armed or do you have some kind of silent alarm that notifies you?

The component has two output entities that turn on/off. The alarm and the warning. Right now, I have a relay controlled alarm siren (from the original house alarm) connected to the alarm switch component. For the warning, I’m going to have a script like component that plays a looped audio sound from my PI3.

I hadn’t thought about a notification but HA makes it pretty easy to set one up.

That’s fantastic. For mine I think I’ll set it to notify me when the alarm is triggered so I can take action – whether that means checking to see if it was a false alarm by checking with family or calling the police. Thanks for sharing.

Nice work! Thanks for sharing. I have also a question.
I can’t find the non actoin or action you have when there is movement as the alarm is arm or disarm, in your files.
Sorry, if i don’t unerstand it very well. Thanks for help.

Not sure if I understand the question. I don’t specifically look at motion events, I group binary_sensors into the configuration groups ‘immediate’ and ‘delayed’. Anything in the immediate group causes an immediate alarm. Anything in the ‘delayed’ group will move to the warning state before alarming (giving you a chance to disarm). There is also a separate group ‘notathome’ for things to ignore if arming home.

This is just what I was looking for! Cool!
My guess is that this is something way more people want. Maybe you would want to create a pull request for this… :slight_smile:

4 Likes

Very nice project, thank you for Sharing. I was just wondering how do I incorporate a code for arming and disarming the alarm?

I don’t use a code at the moment as the only access is an SSL protected connection and a password on the home assistant interface. I consider that password my authentication. Not exactly strong two factor authentication but good enough for now.

The base alarm_control_panel class does include an option for a code to be specified. You would need to apply the code pieces from the built in Manual alarm control panel which means config/handling in the python code (pretty easy) and adding the additional input processing in the frontend piece (usually a little more work to get the layout right)

Thank you for the reply , I was trying to follow your suggestion and implement the part that deals with the code but my python skills are not that good , could you please point me to the right direction, thanks

1 Like

I took a stab at this since I was making some modifications to this already. If you just want the code piece, try this:

https://gist.github.com/tboyce1/9e27ea9b78a29cf65b3677b55ef3c384/346a34a76cf084131298a7e0f81102f799e33b65

I make no promises on the quality of this (it seemed to work during my brief testing), but it should at least give you an idea of what needs to be changed.

If you look at some of the later revisions as well, I also changed the “alarm” and “warning” config sections to take a service rather than group/switch ID, so you can change

alarm: switch.alarm
warning: switch.warning

to something like

alarm:
  service: notify.html5
  data:
    message: "Alarm triggered!"
warning:
  service: switch.turn_on
  data:
    entity_id: switch.warning

Note that this method will NOT turn the switch back off when the alarm is disarmed, so you’d have to use automation to do that if you want to continue using your existing switches with this implementation.

1 Like

Hi @drytoastman

Sorry to bother you, I’ve used your alarm code as it’s exactly what I was looking for.

I’ve got a speaker hooked up to my RPi, along with a working alarm.mp3 shell command.

Would you be able to tell me where I’d set notifications and the alarm looping?

This is the final piece of the Home Assistant puzzle :slight_smile:

Hi
Thank you for sharing your code. When I was trying your code it wasn’t asking for a code to arm or disarm the alarm.
I was tying to trace your code but I couldn’t find out why it’s not working.

Update: I was able to arm and disarm using the code only from the states panel, couldn’t get it to work from the Alarm panel (alarm.html) , any idea why?
Thanks

Update:
It works perfectly

hi ,

Did you implement the activation of a service instead of entity_id for alarm and warning?
It’s not working for me , I was able to get the entity_id to work with alarm and warning. I got lost a little tracking the revisions.
Thank you for any help

This one should include the alarm code and alarm/warning as a service:

https://gist.github.com/tboyce1/9e27ea9b78a29cf65b3677b55ef3c384/9326d1be5f7f747dba7914bca7d2db4aa0322366

Note that I commented out the schema validation so it won’t tell you if your configuration is wrong until it actually tries to call the service. It also only supports a single service (no lists using “-”), so if you want multiple services you’ll need to have it call a script.

Thank you for your help, I will try it and let you know.

It works, thank you for your help.

I just tried the code and looks great!
One thing I didn’t figured out is:

headsup config parameter, it looks like that doesn’t matter which sensor I put in there, it will give me headsup for everything.

Did I miss anything ?