Alarm.com List Index Out of Range

Understand perfectly.
I fixed the items but it is still causing me problems that I just do not understand why.
binary sensor code is

        alarm_office_window:
          friendly_name: "Office Window (14)"
          device_class: window
          value_template: "{{ state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('Office Window (14) is Open', ignorecase=TRUE) }}"

Screenshot from 2020-03-24 12-08-52

Screenshot from 2020-03-24 12-12-42

What am I missing, I am flummoxed.
carltonb

Submitted a pull request to remove the need for bs4. Not sure if this would still be classified as web-scraping or not:.

Submitted. Hopefully it’s detailed enough… :grimacing:

Really odd, wonder if the regex doesn’t ‘like’ the ( or )…

If I try this in Developer Tools → Template I get FALSE:

{% set test = 'ed, Office Window (14) is Open' %}
{{ test | regex_search('Office Window (14) is Open', ignorecase=TRUE) }}

But if I try this when removing the (14) I get TRUE:

{% set test = 'ed, Office Window (14) is Open' %}
{{ test | regex_search('Office Window ', ignorecase=TRUE) }}

Ahh, might have figured it out, try putting \ in front of the ( and ), like so:

{% set test = 'ed, Office Window (14) is Open' %}
{{ test | regex_search('Office Window \(14\) is Open', ignorecase=TRUE) }}

^^ This w/ the \ returns TRUE for me.

So if I understand you I need to change this

value_template: "{{ state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('Office Window (14) is Open', ignorecase=TRUE) }}"

To this

value_template: "{{ state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('Office Window \(14\) is Open', ignorecase=TRUE) }}"

Correct?

That looks correct to me. I’d give it a shot and see what happens. :crossed_fingers:

Do you think there is a way to validate the HA alarm code against the alarm.com api instead of a fixed configured code? That would be awesome!

Firstly thank you for all the help.
Because of the problems with the “( )” brackets i eliminated them in all my entries and I changed the alarmdotcom sensor to read 14_Office Window.
So now the binary sensor code looks like

      alarm_14_office_window:
        friendly_name: "14_Office Window"
        device_class: window
        value_template: "{{ state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('14_Office Window is Open', ignorecase=TRUE) }}"

If I run it it still gives me a false error.
If I use your test sample of

{% set test = 'ed, 14_Office Window is Open' %}
{{ test | regex_search('14_Office Window is Open', ignorecase=TRUE) }}

It says it is true.
What the heck am I missing.
carltonb

I finally solved it.
After puling out my hair it had to do with the name.

# Example configuration.yaml entry
alarm_control_panel:
  - platform: alarmdotcomajax
    username: YOUR_USERNAME
    password: YOUR_PASSWORD
    #code: "01234"
    #force_bypass: "true"
    #no_entry_delay: "home"
    #silent_arming: "false"

It seems that on my system for some reason it must have a name.
I thought that the name was optional or that it defaulted to alarm_com.
My system required the name to be inserted.
So I used this.

# Example configuration.yaml entry
alarm_control_panel:
  - platform: alarmdotcomajax
    name: alarm_com
    username: YOUR_USERNAME
    password: YOUR_PASSWORD
    #code: "01234"
    #force_bypass: "true"
    #no_entry_delay: "home"
    #silent_arming: "false

Again thanks to all for the help. For now I am up and running.
carltonb

1 Like

I switched to the alarmdotcomwebapi version and it appears to be working fine. With one issue, every few days it ceases to work and when i do a restart it is fine again. Guessing it is a authentication issue. Thinking a temp fix would be to use automation to do a restart every so often.

Any ideas, could we add a keepalive function to the code?

Thanks

Yes, same here @samceccola re: WEBAPI version. Seeing these log errors this morning:

2020-03-26 08:38:56 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.work fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    await self.async_update()
  File "/config/custom_components/alarmdotcomwebapi/alarm_control_panel.py", line 74, in async_update
    await self._alarm.async_update()
  File "/config/custom_components/alarmdotcomwebapi/pyalarmdotcom.py", line 187, in async_update
    response = self.command('STATUS')
  File "/config/custom_components/alarmdotcomwebapi/pyalarmdotcom.py", line 160, in command
    currentstate = result['data']['attributes']['state']
KeyError: 'data'

Also using the updated AJAX version, which seems stable, but we’re working thru an issue w/ allowing multiple accounts/locations to work/play nicely together. I have home/work locations, so that’s why I’m running both WEBAPI and AJAX versions concurrently, fwiw.

WOW, this new version is FANTASTIC. I really approve. Not only did it get my alarm.com integration working again, it also adds silent arming, which is a feature I have been wanting forever.

Is there a way to chose silent vs. non-silent arming? Not really a deal killer, just wondering if that is possible. After all, I am really pleased with this new integration as-is!

I tested installing the integration through HACS and it seems to be working without issues.

To install through HACS:

  1. Add the integration repository as Category -> Integration using the SETTINGS page on the HACS interface,
  2. Search for Alarm.com on the INTEGRATIONS page on the HACS interface, click on the Alarm.com card and click INSTALL.

If you had not installed the integration as a custom_component you will need to update your configuration.yaml as documented in the README

NOTE: If you previously installed the integration as a custom_component you will want to move or remove that directory before restarting HA.

2 Likes

@Mr_Flibble, the integration does not provide a way to specify silent vs non-silent for each arming command issued, however the silent_arming flag can be configured in 4 different modes (“home”, “away”, “false” (never), “true” (always)), where “home” means always use silent arming during arm_home and “away” means always use silent arming during arm_away.

Worth reporting that I was able to install via HACS using these instructions, removing the previously created custom_component, and all is working well - including multiple locations. Thanks @aechelon and @uvjustin!

I had some trouble with this, so I want to make sure I am doing this correctly. I tried several variations of the integration repository in the SETTINGS page, and most resulted in errors. It finally came up when I entered “uvjustin/alarmdotcomajax”. Before I add the integration, I just want to verify - Is that correct?

And a second question: Once added, will this repository act just like any other HACS repository and provide alerts when updates are available?

I followed the HACS instructions from @aechelon but I am getting the following errors.

2020-03-27 15:39:06 ERROR (MainThread) [pyalarmdotcomajax.pyalarmdotcomajax] Unable to extract state data from Alarm.com

2020-03-27 15:39:16 WARNING (MainThread) [homeassistant.helpers.entity] Update of alarm_control_panel.alarm_com is taking over 10 seconds

I do have two alarms tied to the one account so I used name with the name of the alarm I want to appear. Even without name I was getting the error.

@Aussie See the “Multiple Alarm.com Installations” in the README.

@_Mike, you should use the full URL to the GitHub repository:

GitHub - pyalarmdotcom/alarmdotcom: Custom component to allow Home Assistant to interface with Alarm.com

You won’t get an explicit notification, however the HACS interface will show integrations that are out-of-date in orange. Clicking on the associated card will present an option to UPDATE the integration. I tested this with the Alarm.com integration earlier today and it worked without an issue.

1 Like

@aechelon just to clarify, I need to create separate users in alarm.com where each only has access to one of the alarms?

I did try duplicating what I had in my config and using the different names in name but that didn’t work.

I am now curious how the default integration in HA use to work without having to specify which one.