YET another take on an alarm system

This is my sensors template

- platform: template
  sensors:
    fdstatus:
      value_template: '{% if is_state("sensor.front_door_sensor_access_control", "23") %}closed{% else %}open{% endif %}'
      friendly_name: 'FD'

    ydstatus:
      value_template: '{% if is_state("sensor.yard_door_sensor_alarm_level", "0") %}closed{% else %}open{% endif %}'
      friendly_name: 'YD'

    gdstatus:
      value_template: '{% if is_state("sensor.garage_interior_door_alarm_level", "0") %}closed{% else %}open{% endif %}'
      friendly_name: 'GD'

    awdstatus:
      value_template: '{% if is_state("binary_sensor.andrews_window_opened", "off") %}closed{% else %}open{% endif %}'
      friendly_name: 'AWD'

    awlightstatus:
      value_template: '{% if is_state("switch.andrews_bedroom_switch", "off") %}Off{% else %}On{% endif %}'
      friendly_name: 'ABD'

    mblstatus:
      value_template: '{% if is_state("switch.my_bedroom", "off") %}Off{% else %}On{% endif %}'
      friendly_name: 'MBL'


    arwdstatus:
      value_template: '{% if is_state("binary_sensor.visonic_mct340_e_0b2a7984_1", "off") %}closed{% else %}open{% endif %}'
      friendly_name: 'arwd'
      
    lrwd1status:
      value_template: '{% if is_state("binary_sensor.visonic_mct340_e_0b0011fb_1", "off") %}closed{% else %}open{% endif %}'
      friendly_name: 'lrwd1'
      
    lrwd2status:
      value_template: '{% if is_state("binary_sensor.visonic_mct340_e_0b000c64_1", "off") %}closed{% else %}open{% endif %}'
      friendly_name: 'lrwd2'
      
    lrwd3status:
      value_template: '{% if is_state("binary_sensor.window_living_room_3_sensor", "off") %}closed{% else %}open{% endif %}'
      friendly_name: 'lrwd3'
      
    lrwd4status:
      value_template: '{% if is_state("binary_sensor.window_living_room_4_sensor", "off") %}closed{% else %}open{% endif %}'
      friendly_name: 'lrwd4'
      
    lrmotionstatus:
      value_template: '{% if is_state("binary_sensor.living_room_motion_sensor_sensor", "off") %}clear{% else %}detected{% endif %}'
      friendly_name: 'lrmotionsensor'
      icon_template: >
        {% if is_state('sensor.lrmotionstatus', 'detected') %}
        mdi:walk
        {% else %}
        mdi:run-fast
        {% endif %}

and here is the customized.yaml

sensor.fdstatus:
  friendly_name: Front Door
  icon: mdi:glassdoor
  
sensor.ydstatus:
  friendly_name: Yard Door
  icon: mdi:glassdoor
  
sensor.gdstatus:
  friendly_name: Garage Door
  icon: mdi:glassdoor
  
sensor.awdstatus:
  friendly_name: Andrew's Window
  icon: mdi:window-closed
  
group.weather_fw:
  icon: mdi:weather-sunny
  
sensor.awlightstatus:
  friendly_name: Andrew's Bedroom
  icon: mdi:ceiling-light

sensor.mbl:
  friendly_name: Master Bedroom Light
  icon: mdi:ceiling-light
  
sensor.arwdstatus:
  friendly_name: Arelly's Window
  icon: mdi:window-closed

sensor.yweather_condition:
  friendly_name: Condition
  
sensor.andrews_window_opened_battery:
  icon: mdi:battery

sensor.lrwd1status:
  friendly_name: Living Room Window 1
  icon: mdi:window-closed
  
sensor.lrwd2status:
  friendly_name: Living Room Window 2
  icon: mdi:window-closed

sensor.lrwd3status:
  friendly_name: Living Room Window 3
  icon: mdi:window-closed
  
sensor.lrwd4status:
  friendly_name: Living Room Window 4
  icon: mdi:window-closed
  
sensor.yweather_temperature:
  friendly_name: Temperature
  icon: mdi:temperature-fahrenheit
  
sensor.lrmotionstatus:
  friendly_name: Living Room Motion Sensor
  #icon: mdi:run

Could you try removing the custom state for one of the binary senors say awd and instead of the custom state in customize.yaml use:

device_class: opening

Also remove the icon from customize.yaml

Apologies all. Took a little longer to get the code into a shape to upload. Github updated as of 2 mins ago!

Changes:

Perimeter Mode (Optional) - I use this to just arm the doors/windows during the day when I am in
Weather Icon/Summary (Optional) - You need Dark Sky for this to work
Added 0 to code panel as requested by @thundergreen (Not sure about the design, if anyone could suggest/upload a decent layout it would be appreciated)

Any issues let me know.

Made the changes but they didnā€™t help. Iā€™m going to remove each sensor from the alarm and place them back one at a time to see if I can identify the root cause. Will let you know if I come up with a solution.

i have a question. with the introduction of ā€œperimeter modeā€ we need an another automation?

Nope it still activates ā€˜triggeredā€™ status on trip so all your existing automation should be good to go. Just make sure you add the sensors to ā€˜perimeterā€™ group

maybe only the one for the notification?

Yeah true if you have notifications set for alarm activations

Ok, every sensor that is on/off close/open on their own without the customization work without a problem. Why is that the customization cause the issue since the sensor that is being used is still outputting the same information just formatted differently?

@gazoscalvertos - I finally have it going. Originally I was customizing the sensors as standard sensors, with the help of @a_ndy on another thread I posted trying to discover the cause of why device_class: opening wasnā€™t working for me, he enlightened me that I needed to convert the sensor into a binary_sensor. That did the trick!

Brilliant! Glad you got it sorted.

We learn something new everyday!

Iā€™ll update the readme on the github page with your findings.

How can I just run this as a separate tab on my front end? I would love to use this but only want it in a tab

At the moment you can only run this as a panel, not much different to a tab view.

Iā€™ll implement statecards ie views/tabs once the design, features and bugs are worked out

Hi gazoscalvertos,
thank you for your project, I had to replace drytoastman component due to incompatibility with the latest versions of HA, and yours provided a smooth transistion, more or less: I wanted to ask you if thereā€™s a way to avoid asking for a digit code entry on disarm; I use some automations to temporarily disable the alarm on certain situations, and they are not working, probably for the inability to disarm the system without pin.

In your automation your can set the alarm code:

alias: '[Alarm] Disarm'
trigger:
  [YOUR TRIGGER]
action:
- service: alarm_control_panel.alarm_disarm
  entity_id: alarm_control_panel.house
  data:
    code: 1234
2 Likes

Great, Iā€™ll try it immediately, thanks!

I am trying do do something with a Amazon Dash Button via MQTT to enable and disable the alarm from the Dash Button on a set of keysā€¦ Im close but cant get the disarm to work, any ideas

- alias: 'Alarm Arm and Disarm Using Amazon Dash Olay'
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: switch.olay_dash_switch
    to: 'on'
  action:
    service_template: >
     {% if is_state('alarm_control_panel.house', 'disarmed') %}
       alarm_control_panel.alarm_disarm
     {% else %}
        alarm_control_panel.alarm_arm_away
     {% endif %}
    data_template:
      entity_id:  alarm_control_panel.house
      data: >
       {% if is_state('alarm_control_panel.house', 'disarmed') %}
         code: 9999
       {% endif %}

Looks like your missing an ! from your service template:

{% if !is_state('alarm_control_panel.house', 'disarmed') %}

And your data template:

{% if !is_state('alarm_control_panel.house', 'disarmed') %}

@gazoscalvertos thanks i get the following error when added !

2017-12-04 14:04:43 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected char ā€˜!ā€™ at 6) for dictionary value @ data[ā€˜actionā€™][0][ā€˜data_templateā€™][ā€˜dataā€™]. Got None invalid template (TemplateSyntaxError: unexpected char ā€˜!ā€™ at 6) for dictionary value @ data[ā€˜actionā€™][0][ā€˜service_templateā€™]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 27). Please check the docs at https://home-assistant.io/components/automation/

Hi, I didnā€™t realize that syntax wouldnā€™t work in Jinja2

try {% if is_state(ā€˜alarm_control_panel.houseā€™, ā€˜disarmedā€™) == false %}

You can test this in the templates section of HA before editing your code https://[HA URL]/dev-template

I have just tried this as a test and it works

{% if is_state('alarm_control_panel.house', 'disarmed') == false %}
  set
{% else %}
  not set
{% endif %}