Alarm.com List Index Out of Range

For those who are interested in restoring sensor status information (and who would like to help with testing) there’s a new PR that uses Alarm.com’s web api – which hopefully is a little more stable than screen-scraping the web interface directly.

This PR also includes the HA plugin driver (alarm_control_panel.py) to simplify deployment and testing on HA using custom_components.

To install:

  1. Create directory config/custom_components/alarmdotcomwebapi
  2. Copy all files from the PR to config/custom_components/alarmdotcomwebapi/
  3. In your configuration.yaml, change
    platform: alarmdotcom
    to
    platform: alarmdotcomwebapi

I have been testing it for a few hours on HomeAssistant 0.103.6 / HASSIO 195. So far so good.

This version maintains the same interface as the original pyalarmdotcom module but uses the web API through a dev version of the mechanicalsoup module (which is embedded in the plugin because StatefulBrowser is still not part of the released version of mechanicalsoup.)

The code is based on this python script and the homebridge node interface

Thank you for your hard work…

I did as you instructed, unfortunately, nobueno
HA 0.107.0 in docker:

2020-03-18 19:09:07 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.home 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'

I just updated using this method and it appears to be working properly now. Hopefully the PR gets approved soon. Thanks!

Interesting. This seems to indicate that post-login your interface is returning different content (or perhaps no content at all).

Can you try the instructions for alarmdotcomajax that I posted yesterday and let me know if that worked?

Here’s what I did:

  1. Create directory config/custom_components/alarmdotcomajax
  2. Copy pyalarmdotcomajax.py from the PR to config/custom_components/alarmdotcomajax/
  3. Copy alarm_control_panel.py from the github repository to config/custom_components/alarmdotcomajax/
  4. Update line 5 of alarm_control_panel.py to say:
    from .pyalarmdotcomajax import Alarmdotcom
  5. Add an __init__.py file in config/custom_components/alarmdotcomajax/ containing the following:
    """The alarmdotcom component."""
    from .pyalarmdotcomajax import Alarmdotcom
  6. In your configuration.yaml, change
    platform: alarmdotcom
    to
    platform: alarmdotcomajax

You may want to copy that section and comment it out to make it easy to switch back once the official plugin is fixed.

To revert, just replace alarmdotcom in your configuration.yaml and delete directory config/custom_components/alarmdotcomajax/

There’s a new version of the alarmdotcomajax code that now also supports sensor_status. I just tested it out, and it works great.

To install:

  1. Create directory config/custom_components/alarmdotcomajax
  2. Copy all files from the PR to config/custom_components/alarmdotcomajax/
  3. Copy alarm_control_panel.py from the github repository to config/custom_components/alarmdotcomajax/
  4. Update line 5 of alarm_control_panel.py to say:
    from .pyalarmdotcomajax import Alarmdotcom
  5. In your configuration.yaml, change
    platform: alarmdotcom
    to
    platform: alarmdotcomajax

I would advise using this version because 1) the code has been tested for a couple of months and 2) it doesn’t depend on the mechanicalsoup module, and 3) it’s likely to get elevated to replace the version used by the HA alarmdotcom module.

1 Like

thanks! just did this and so far so good :slight_smile:

Thanks I misread the original instructions, it is working

This made me realize what it is – i have multiple systems connected to my alarm.com account…

So, I created a new sub-account that only has access to the system I wanted, and everything works perfectly.

Thanks again, Great work!

Thank you. These changes resolved my issue also. One other change I have also been doing is changing the CONF_CODE from int to string. I found when I was testing various PINs in the past that it breaks if they contain a leading zero. This should resolve that issue.

alarm_control_panel.py file around line 35

Change CONF_CODE from positive_int to string:

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_PASSWORD): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Optional(CONF_CODE): cv.string,
        #vol.Optional(CONF_CODE): cv.positive_int,
        vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    }
)

I had the same issue and got the core problem resolved by moving to alarmdotcomajax as described but I do not have access to any of my sensors. Just Arm/Disarm options. Any thoughts? I double checked permissions on the account being used to login and they are fine…

Sounds like you’d need to move to this version that @aechelon is graciously working on - though it’s not 100% tested - and in need of beta testers from what I gather.

I personally don’t use sensor data currently, so the AJAX version ok for me and I’m sadly unable to test sensors w/ the new API version.

I’m getting the same errors you got. Can you explain more of what you did to fix it?

That was it, I had scrolled up and down the page so many times that I crossed the two. webapi is working and senors are in, thanks!

I decided to move to the webapi version too. That seems to be working for me. Haven’t tested it much, but I will.

@aechelon, can you confirm that this line is blank prior to this addition? The first six lines of alarm_control_panel.py are blank when I open it to edit.

The method your describe does not seem to be working on this end. Once I change the line in the config.yaml, an effort to validate the config fails and HA will not reboot. If I change the confirmation.yaml back, it validates and reboots fine.

If you picked up alarm_control_panel.py from the github repository as documented in step 3, then its contents should look like this.

1 Like

Thanks for the help. Now able to get it running.

FYI everyone, appears alarmdotcom is going to be removed in the next version.

Wow. Thanks for that. That’s terrible…alarm.com is one of the main reasons I have HA in the first place. I was hoping it would just start working again, but at least we have good devs here that are picking up the slack.

Looks like the replacement for the module is full removal its already in the dev branch. So your custom component will be the way to go going forward.