YET another take on an alarm system

@keithh666 the python code looks for STATE_ON which is actually the ‘on’ value so the switches should be supported. Do you get any errors using these switches at all?

1 Like

I used to install professional security systems in commercial properties. They were always hard-wired top of the range gear. From my experience those systems are certainly more robust than what we are working with here with wireless sensors and software based controllers. That said I love my Hassio alarm system with wireless sensors as I have been able to install it in a rental property. My current issue is that I edited a yaml file remotely while at work and subsequently crashed my Hassio Pi :tired_face: Something that wouldn’t happen with a professional system.

At the end of the day most (if not all) house burglars are simple break and enter types who either don’t care about alarm systems and simply rip sirens off walls, or go to the house next door which doesn’t have one at all. They never bother to hack wireless signals or carefully bypass hard-wired sensors. Its usually a brick through a window or boot in a door.

I like to have motion sensors (pet immune) installed outside the property so that the alarm sounds before the person has even gotten near the house. This way they are far more likely to simply run away than to try and bypass / disable the siren.

If you put your Hass server and modem on a UPS, at least you should still have monitoring and reporting to your phone etc. even if they manage to cut power to the property.

Maybe it’s me not understanding how it works :frowning:

I have put my door sensor/switch in the immediate alarm area of alarm.yaml but when the switch changes state all that happens is that the switch shows as on and it moves up the list in the inactive list and appears in the top sensors open list, there is never anything in the immediate list and no alarm in raised :frowning: I’m sure it’s something stupid I’m doing I just can’t figure it out :stuck_out_tongue:

Sorry forgot to say that’s in perimeter mode, so all black mode :slight_smile:

OK, I think I’m getting the hang of it, it works in home mode, which, I thought was perimeter mode :stuck_out_tongue:

Can i ask you what type of sensor are you using outdoor?

1 Like

In my last house I used PE beams hard wired to a commercial grade alarm panel. The same PE beams can easily be used with Hass by implementing a z-wave switch such as the Fibaro universal binary sensor. I did this with one of them but that was back when I had a Vera3… The Vera3 was far too unreliable. You can also use. Outdoor rated, pet immune motion detectors. I used a bunch of Paradox ones on a friend’s house

1 Like

I’m having an odd issue with the alarm panel which may relate to how I have state persistence setup on my HASS. I run HASS on a docker and utilize Appdaemon to maintain my entities’ state across a reboot of the HASS docker. It seems when I reboot Home Assistant the alarm panel does not respond when it is set to an armed state prior to the reboot. The alarm panel still shows armed even after a reboot and the disarm service appears to be called but neither the alarm panel or alarm panel state change to disarmed. Here is some of my config if it helps:

alarm.yaml

  name: house
  code: !secret alarm_code
  pending_time: 25 #Grace time in seconds to allow for exit and entry using Away mode
  trigger_time: 600
  alarm: automation.alarm_triggered
  warning: automation.alarm_warning

  clock: True  #Optional - True enables a clock in the center of the status bar
  perimeter_mode: False #Optional - True enables perimeter mode, this could be known as 'Day Mode' i.e. only arm the doors whilst there is someone using all floors
  weather: False #Optional - Allows a weather summary to be displayed on the status bar. Dark Sky weather component must be enabled with the name sensor.dark_sky_summary

  #### COLOURS ###########  Use any HTML format
  warning_colour: 'orange'
  pending_colour: 'orange'
  disarmed_colour: '#03A9F4'
  armed_home_colour: 'black'
  armed_away_colour: 'black'
  triggered_colour: 'red'

  ############# SENSOR GROUPS ########################
  # Sensors in this group tigger the alarm immediately
  immediate:
    - binary_sensor.front_door_sensor
    - binary_sensor.side_door_sensor
  #  - binary_sensor.top_floor_multi_sensor_sensor
  #  - binary_sensor.lounge_multi_sensor_sensor
  #  - binary_sensor.toilet_window_sensor
  #  - binary_sensor.back_door_sensor
  #  - binary_sensor.lounge_doors_sensor
  #  - binary_sensor.kitchen_window_sensor

  # Sensors in this group start the clock (pending_time) when tripped before the alarm is activated in 'Away' mode
  delayed:
    - binary_sensor.dining_room_motion_sensor
  #  - binary_sensor.kitchen_multi_sensor_sensor
  #  - binary_sensor.hall_multi_sensor_sensor
  #  - binary_sensor.toilet_multi_sensor_sensor
  #  - binary_sensor.front_door_sensor
  #  - binary_sensor.garage_door_sensor

  # Same as notathome but hopefully the title is more self explanatory. Can still use notathome for backwards compatibility
  # Note sensors can exist in more than one group notice top_floor appears in two groups
  homemodeignore:
    - binary_sensor.side_door_sensor
  #  - binary_sensor.top_floor_multi_sensor_sensor
  #  - binary_sensor.lounge_multi_sensor_sensor
  # Use this group to automatically override the warning message on open sensors when setting 'away' mode. (I use this as I have a motion sensor at the front door)
  #override:
  #  - binary_sensor.hall_multi_sensor_sensor
  
  # This group is special and only effects 'perimeter mode'. If perimeter_mode is enabled then any sensor in this group will trigger the alarm immediately if arm perimeter is set. There is no delayed group for this mode (unless requested as a feature of course!)
  #perimeter:
  #  - binary_sensor.toilet_window_sensor
  #  - binary_sensor.back_door_sensor
  #  - binary_sensor.lounge_doors_sensor
  #  - binary_sensor.kitchen_window_sensor
  #  - binary_sensor.front_door_sensor
  #  - binary_sensor.garage_door_sensor

panel_custom.yaml

  - name: alarm
    sidebar_title: Alarm
    sidebar_icon: mdi:security-home
    config:
      alarmid: alarm_control_panel.house ## USE THE SAME ID AS USED IN YOUR ALARM.YAML

Appdaemon Config

switch_reset.py


  def initialize(self):
    
    self.device_db = shelve.open(self.args["file"])
    self.listen_event(self.ha_event, "ha_started")
    self.listen_event(self.appd_event, "appd_started")
    self.listen_state(self.state_change, "input_boolean")
    self.listen_state(self.state_change, "input_select")
    self.listen_state(self.state_change, "input_slider")
    self.listen_state(self.state_change, "device_tracker")
       
  def ha_event(self, event_name, data, kwargs):
    self.log_notify("Home Assistant restart detected")
    self.run_in(self.set_switches, self.args["delay"])
    
  def appd_event(self, event_name, data, kwargs):
    self.log_notify("AppDaemon restart detected")
    self.run_in(self.set_switches, self.args["delay"])

  def state_change(self, entity, attribute, old, new, kwargs):
    #self.log_notify("State change: {} to {}".format(entity, new))
    self.device_db[entity] = new
  
  def set_switches(self, kwargs):
    self.log_notify("Setting switches")
    # Find out what devices are avaiable.
    # If we don't know about it initialize, if we do set the switch appropriately
    state = self.get_state()
    for entity in state:
      type, id = entity.split(".")
      if type == "input_boolean" or type == "input_select" or type == "input_slider" or type == "device_tracker":
        if entity in self.device_db:
          if self.device_db[entity] != state[entity]["state"]:
            self.log_notify("Setting {} to {} (was {})".format(entity, self.device_db[entity], state[entity]["state"]))
            new_state = self.set_state(entity, state = self.device_db[entity])
        else:
          self.log_notify("Adding {}, setting value to current state ({})".format(entity, state[entity]["state"]))
          self.device_db[entity] = state[entity]["state"]
  
  def log_notify(self, message, level = "INFO"):
    if "log" in self.args:
      self.log(message)
    if "notify" in self.args:
      self.notify(message, globals.notify, name=globals.notify)

apps.yaml

  module: switch_reset
  class: SwitchReset
  file: "/conf/states/preserved_states"
  delay: 10
  additional_entities: alarm_control_panel.house

Log snippet

2017-12-10 07:06:28 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=alarm_control_panel, service=alarm_disarm, service_data=code=1234, service_call_id=47331182490232-27>
2017-12-10 07:06:28 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 47332686792520: Sending {'id': 16, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'alarm_control_panel', 'service': 'alarm_disarm', 'service_data': {'code': 'Somecode'}, 'service_call_id': '47331182490232-27'}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2017, 12, 10, 12, 6, 28, 285117, tzinfo=<UTC>)}}
2017-12-10 07:06:28 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=47331182490232-27>
2017-12-10 07:06:28 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 47332686792520: Sending {'id': 16, 'type': 'event', 'event': {'event_type': 'service_executed', 'data': {'service_call_id': '47331182490232-27'}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2017, 12, 10, 12, 6, 28, 288573, tzinfo=<UTC>)}}
2017-12-10 07:06:28 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 47332683886376: Sending {'id': 12, 'type': 'result', 'success': True, 'result': None}

The only workaround I’ve found is to change the alarm control panel state to disarmed from the Developer tools tab. Thanks for any help anyone can offer.

but how you connect the paradox sensor to HA? they are not z-wave or zig bee.

Use a Fibaro Universal Binary Sensor. They have two inputs so they can capture both the motion detection input and the tamper switch.

that’s far away from cheap. but it’s really interesting.

you can also get pet immune PIR’s that are already z-wave, I have just never used them yet. Still not cheap, but in Australia, nothing z-wave is cheap! Wherever you are might be different.

i’m from italy, i can’t find an “outdoor” z wave sensor.

These aren’t pet immune but they can be used outdoors.

in the web site sais that they have some kind of regulation. i was looking at the PIRZWAVE2.5-ECO that has a good price, pet immunity but is not outdoor. The problem is that is not compatible with the eu frequence.

I suspect it is the persistence something I haven’t had experience with… yet.

It’s likely the comparison of the old state compared to the new state are matching as on first initialization in bwalarm.py

self._state        = STATE_ALARM_DISARMED

is set.If your code over rights this then the clear signals function won’t run when disarming the alarm.

I’ll have a think about what could be changed here to support the persistence.

Great component, thanks for making this! As far as the cylon style animation, here is something that could possibly work, just using CSS3. Should be easy enough to add to the armed statecard for someone who knows more about front end design than me.
http://atomicrobotdesign.com/blog_media/knight_rider.htm

I’m currently playing around with a ‘screensaver’ style mode for wall mounted tablets which kicks in after X seconds on any inactivity (mouse, touch, keyboard). Dropped the cylon idea and tried to go for something a little more flashier. Let me know what you think and open to suggestions. Also is there any summary information from HA which would be useful to display? No of lights on maybe? The background transitions between dark grey, deep blue and black.

The gif isnt the best of quality. Here is a screenshot:

@gazoscalvertos - Please disregard my previous posts. I was able to figure it out.

It seems that locks when opened don’t trigger the alarm? I am also receiving an error “Timer got out of sync. Resetting”.

Thanks!

@junior466 what do the locks appear as in HA switches/sensors/binary sensors?

I don’t have any to test

@gazoscalvertos They appear as lock.LOCKNAME. I have tried unlocking then through the keypad and watched it’s state but it only goes from locked to unlocked. No special state such as “unlocked from keypad”.

Let me know if you need any further testing.