Manual Alarm Panel auto arm and disarm

I have been searching around and I am unable to arm and disarm my manual alarm panel. This is my first time posting code so I am hoping it posts correctly.

  • alias: ‘Auto Enable’
    trigger:
    • platform: time
      at: ‘20:00:00’
      condition:
    • condition: state
      entity_id: alarm_control_panel.Security_Alarm
      state: ‘disarmed’
      action:
    • service: alarm_control_panel.alarm_disarm
      entity_id: alarm_control_panel.Security_Alarm

I think you are telling HASS to disarm the system when it’s already disarmed.

state: 'disarmed’
action:
service: alarm_control_panel.alarm_disarm

As @Coolie1101 says you are telling the system to disarm, the service should look like this if you would like to arm home mode

service: alarm_control_panel.alarm_arm_home

If you would like to arm the away mode

service: alarm_control_panel.alarm_arm_away

Sorry about that, I’ve been commenting the condition out so it doesn’t apply since it shouldn’t be needed be needed to fire the action. I tried it again just now and same problem. Below is the code I used.

  • alias: ‘Auto Enable’
    trigger:
    • platform: time
      at: ‘06:00:00’
      condition:
    • condition: state
      entity_id: alarm_control_panel.Security_Alarm
      state: ‘disarmed’
      action:
    • service: alarm_control_panel.alarm_arm_away
      entity_id: alarm_control_panel.Security_Alarm

This is what it shows on command line when I let it reaches its trigger time on its own. The last line is marked in yellow

2017-10-23 11:00:00 INFO (MainThread) [homeassistant.components.automation] Executing Auto Enable
2017-10-23 11:00:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event logbook_entry[L]: message=has been triggered, name=Auto Enable, domain=automation, entity_id=automation.auto_enable>
2017-10-23 11:00:00 INFO (MainThread) [homeassistant.helpers.script] Script Auto Enable: Running script
2017-10-23 11:00:00 INFO (MainThread) [homeassistant.helpers.script] Script Auto Enable: Executing step call service
2017-10-23 11:00:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=1971475248-3, domain=alarm_control_panel, service_data=entity_id=[‘alarm_control_panel.security_alarm’], service=alarm_arm_away>
2017-10-23 11:00:00 WARNING (Thread-13) [homeassistant.components.alarm_control_panel.manual] Invalid code given for armed_away

I was able to get it to work after I commented out my passcode to arm and disarm.

Does anyone know how I can keep the alarm code but also be able to arm and disarm automatically?

your automation action should look like this:

action:
- service: alarm_control_panel.alarm_disarm
  data:
    entity_id: alarm_control_panel.ha_alarm
    code: !secret alarm_code

This way you can use a code on the alarm and still auto arm/disarm.

1 Like

Thank you Squirtbrnr, that works prefect

I created an automation to disarm my alarm using the Automation editor and I’m now trying to add the ‘code: !secret alarm_code’ to the YAML through both the Edit YAML function and the File Editor but I can’t get the alarm code added.

I get “Message malformed: extra keys not allowed @ data[‘action’][0][‘code’]” when I try to add the code.

Can someone help me figure out what I’m doing wrong? Thank you!

Post what automation code you have tried already. And please format the text properly.

I’ve got my own set of issues with the code part… I’m trying to enable and disable two systems at the same time and when I put the code statement in, I get the following errors:
Invalid config for [automation]: [code] is an invalid option for [automation]. Check: automation->action->1->code. (See /config/configuration.yaml, line 9).

Logger: homeassistant.components.manual.alarm_control_panel
Source: components/manual/alarm_control_panel.py:393
Integration: manual (documentation, issues)
First occurred: 2:58:05 PM (2 occurrences)
Last logged: 2:58:18 PM

  • Invalid code given for disarmed
  • Invalid code given for armed_away

–The relevant automation yaml is as follows

  • condition: device
    device_id: 9b97d33f2a5f2eabb457adee6fe67683
    domain: device_tracker
    entity_id: device_tracker.chris_phone
    type: is_not_home
    action:
  • service: alarm_control_panel.alarm_arm_away
    data: {}
    entity_id: alarm_control_panel.alexa_guard_a9542
  • service: alarm_control_panel.alarm_arm_away
    data: {}
    entity_id: alarm_control_panel.home_alarm
    code: !secret alarm_code

Any thoughts on that? I’m going to try moving where the alarm is defined in the configuration.yaml and see if that has any bearing on the invalid code error

Well nevermind, the template I used for the automation was created with the UI editor and then I took the code it gave me - saved it in another folder and modified it…
Long story short, I had to place the service data into the brackets.

Went from
data: {}
entity_id: alarm_control_panel.home_alarm
code: !secret alarm_code
To
data: {entity_id: alarm_control_panel.home_alarm, code: !secret alarm_code}

and now it is performing as desired

2 Likes

In my automation actions, I can make it work like this. However, the entity_id is used twice but if I drop target it gives error.
Any idea how fix it or better way as {} wasn’t working for me.

service: alarm_control_panel.alarm_disarm
data:
  entity_id: alarm_control_panel.partion_1, code:!secret envisa_code
target:
  entity_id: alarm_control_panel.partion_1