Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arlo Alarm Control Panel Repeatedly Loses Status #15177

Closed
rfpludwick opened this issue Jun 27, 2018 · 38 comments
Closed

Arlo Alarm Control Panel Repeatedly Loses Status #15177

rfpludwick opened this issue Jun 27, 2018 · 38 comments

Comments

@rfpludwick
Copy link

Home Assistant release with the issue:
0.72.1

Last working Home Assistant release (if known):
0.71

Operating environment (Hass.io/Docker/Windows/etc.):
Hassbian on Raspberry Pi 3B+

Component/platform:
Arlo alarm control panel

Description of problem:
I have an automation to post to a Slack channel when my Arlo's Alarm Control Panel state changes, and it's repeatedly changing between unknown and other states. This causes automation coordination of alarm systems to fail, which I've had to disable.

Sample Slack logs:

Home Assistant APP [9:16 AM]
Arlo mode changed to 'unknown'
Arlo mode changed to 'disarmed'
Arlo mode changed to 'unknown'
Arlo mode changed to 'unknown'
Arlo mode changed to 'unknown'
Arlo mode changed to 'disarmed'
Home Assistant APP [9:48 AM]
Arlo mode changed to 'unknown'
Arlo mode changed to 'disarmed'
Arlo mode changed to 'unknown'
Arlo mode changed to 'unknown'
@docbobo
Copy link

docbobo commented Jun 29, 2018

Same here. A while ago, I set up an automation that would restart HA whenever the control panel went dark.

Looking at current statistics, it takes about 20 to 30 minutes until the control panel turns its state to unknown.

@arsaboo
Copy link
Contributor

arsaboo commented Jun 29, 2018

Same here...I am seeing the same.

@joewesch
Copy link

joewesch commented Jul 3, 2018

I'm still on 0.68.1, and I may be having the same issue. The only mentions of Arlo in the release notes is on 0.72.0.

@lawtancool
Copy link
Contributor

This is an issue on 0.73 as well...

@jpreiditsch
Copy link

also seeing it

@grantclem
Copy link

Another casualty of the ongoing Arlo dramas...

@jpreiditsch
Copy link

Mine constantly loses status, and the service calls to actually change state work intermittently...
screen shot 2018-07-24 at 8 56 09 am

@Nicxe
Copy link

Nicxe commented Jul 28, 2018

Same here, satus jumps to unknown every now and then

@arievayner
Copy link

arievayner commented Jul 29, 2018

I see the same issue
image

Looking at the 3 day history, it looks very periodic. Seems to be happening almost every 30 minutes:
image

@arievayner
Copy link

Tagging @tchellomello as he has done amazing work getting Arlo to work better.

@tchellomello
Copy link
Contributor

Hello folks, this issue is happening because it seems the Arlo has changed the endpoint to get the base station status. We currently have an issue opened at tchellomello/python-arlo#92

@arievayner
Copy link

I've implemented a temporary solution by using a python script which arms/disarms the arlo cameras...

So I've created the following script, which I called set_arlo_mode.py

#! /usr/bin/python

from pyarlo import PyArlo
import sys
import argparse

args_parser = argparse.ArgumentParser(description='Arlo mode setter')
args_parser.add_argument('--mode', dest='mode', type=str, default='')
args_parser.add_argument('--debug', action='store_true')

args = args_parser.parse_args()

if args.mode == '':
    print('Error: --mode is missing')
    args_parser.print_help()
    exit()

arlo = PyArlo('<username>', '<password>')

if not arlo.is_connected:
    print('Error: Not connected to Arlo')
    exit()

base = arlo.base_stations[0]

if args.debug:
    print('Device: %s' % (arlo.devices))
    print('Base: %s' % (arlo.base_stations))
    print('Available Modes: %s' % (base.available_modes))

if args.mode not in base.available_modes:
    exit('Error: unknown mode "%s".\nRecognized modes: %s' % (args.mode, base.available_modes))

base.mode=args.mode
if args.debug:
    print('Mode set to %s' % (args.mode))

(don't forget to make it executable using chmod +x set_arlo_mode.py

Then, in the homeassistant configuration, I've added the following (adjust your path...)

shell_command:
  arm_arlo: '/home/homeassistant/.homeassistant/homeassistant-configs/set_arlo_mode.py --mode=armed'
  disarm_arlo: '/home/homeassistant/.homeassistant/homeassistant-configs/set_arlo_mode.py --mode=disarmed'

If you have different mode names, use the --debug flag when running set_arlo_mode.py from a shell prompt, and it will list all the available modes.

After adding the above config, you will have 2 new service calls added in homeassistant called shell_command.arm_arlo and shell_command.disarm_arlo

In my case, these are the scripts I call from the automation arming/disarming the "alarm":

alarm_on:
  alias: Arm Alarm
  sequence:
  - alias: Arm Arlo Alarm
    data:
      entity_id: alarm_control_panel.arlo1
    service: alarm_control_panel.alarm_arm_away
  - alias: Set Alarm state to Armed
    data:
      entity_id: input_boolean.alarm_armed
    service: homeassistant.turn_on
  - service: shell_command.arm_arlo
alarm_off:
  alias: Disarm Alarm
  sequence:
  - alias: Disarm Arlo Alarm
    data:
      entity_id: alarm_control_panel.arlo1
    service: alarm_control_panel.alarm_arm_home
  - alias: Set Alarm state to Not Armed
    data:
      entity_id: input_boolean.alarm_armed
    service: homeassistant.turn_off
  - service: shell_command.disarm_arlo

@Nicxe
Copy link

Nicxe commented Sep 5, 2018

Thanks, I will definitely check this out. If I understand the script right you are still using the Arlo control panel?

https://www.home-assistant.io/components/alarm_control_panel.arlo/

@arievayner
Copy link

@Nicxe, yes, the script still uses the regular control panel. I did not remove that, but just added the external shell script

@Nicxe
Copy link

Nicxe commented Sep 7, 2018

Thanks @arievayner I will giv this a try. Hope it can be involved in the component.

@Nicxe
Copy link

Nicxe commented Sep 15, 2018

I can't get this to work @arievayner Maybe it has something to do with that I run hassio? I get the error

image

@mlevit
Copy link

mlevit commented Nov 4, 2018

Whilst a better fix is hopefully on the way, I've come up with a simple workaround. Make a new templates sensor reading the state of the Arlo Control Panel. If the state of Arlo Control Panel is unknown then set the sensor state to itself (thereby preserving the current state).

- platform: template
  sensors:
    arlo_arm_mode:
      friendly_name: Mode
      value_template: >-
        {% if is_state("alarm_control_panel.home", "unknown") %}
          {{ states.sensor.arlo_arm_mode.state }}
        {% else %}
          {{ states.alarm_control_panel.home.state }}
        {% endif %}

@orcinus
Copy link

orcinus commented Nov 11, 2018

That doesn't really do much, unfortunately, because setting the state has the same problem. Arming and disarming the base fails all the time. The actual issue is the HTTPS request to Arlo API times out more often than not.

Perhaps increasing the timeout would help?

Is there a way to create a state machine that would keep retrying in case the update attempt throws a timeout exception?

@Nicxe
Copy link

Nicxe commented Nov 13, 2018

Still got the same issue as @orcinus , arming and disarming of often fails.

I run the arm and disarm with IFTTT for now, but arming custom modes don't work thru IFTTT so still needs this to work.

@joewesch
Copy link

@tchellomello, I don't think the endpoint is the issue. I was able to easily get and set the mode via the following (note, I am using my Android app credentials instead of home assistant):

>>> from pyarlo import PyArlo
>>> arlo = PyArlo(username=app_username, password=app_password)
>>> base_station = arlo.base_stations[0]
>>> from homeassistant.components.alarm_control_panel.arlo import ArloBaseStation
>>> bs = ArloBaseStation(base_station, "NOTIFY OFF", "NOTIFY ON")
>>> bs.update()
>>> bs._base_station.mode
'NOTIFY OFF'
>>> bs._base_station.mode = "NOTIFY ON"
>>> bs._base_station.mode
'NOTIFY ON'
>>> bs._base_station.mode = "NOTIFY OFF"
>>> bs._base_station.mode
'NOTIFY OFF'
>>> exit()

The time it takes to get or set the mode is 10+ seconds. Here is the same thing, but with my home assistant credentials (notice it is returning None for the mode):

>>> from pyarlo import PyArlo
>>> arlo = PyArlo(username=home_assistant_username, password=home_assistant_password)
>>> base_station = arlo.base_stations[0]
>>> from homeassistant.components.alarm_control_panel.arlo import ArloBaseStation
>>> bs = ArloBaseStation(base_station, home_mode_name, away_mode_name)
>>> bs.update()
>>> bs._base_station.mode
>>> bs._base_station.mode
>>> exit()

The issue seems to be that HA is polling the cameras (or other components) before the mode can be received (or set). This goes back to netgear only allowing a single account to access the interface at a time. Due to the new async methods, it is just queuing it up and the next one is colliding with it at netgear's site and interrupting it. That is why it is sporadic - sometimes it hits between polls.

I'm not familiar enough with asyncio to do a PR, but it seems if there was a way to not allow other components to attempt a connection if there is already one in use that would fix it. Thoughts?

@orcinus
Copy link

orcinus commented Nov 14, 2018

Does HA have some kind of a mutex mechanism built in? If not, that would be a good thing to have.

Alternative temp fix would be to set cameras and alarm panel as separate platforms, and using separate accounts for each.

@Nicxe
Copy link

Nicxe commented Nov 14, 2018

In my config I don't load any cameras, only the Arlo component an the Arlo Control Panel but still got the same issue that the change of status is very unreliable

@arievayner
Copy link

I can't get this to work @arievayner Maybe it has something to do with that I run hassio? I get the error

image

Sorry, didn't see this... I guess you need to install the module in whatever virtualenv it is running in...

@htvekov
Copy link

htvekov commented Dec 11, 2018

Any update on this 'unreliable' Arlo control panel issue ?

I experience that the Arlo control panel after x hours suddenly can't relay changes to Arlo API.
Sometimes with heavy Async.py log errors. Sometimes without log errors ? It just simply gives up and no changes to Arlo state are made when requested from HA.

Only a reboot of HA, restores the ability to change state again.
But again, will only work for x hours again then...

Can someone please share examples of their IFTTT settings (Nicxe ?), as I need to migrate this vital core thing in my HA setup from Arlo control panel to IFTTT.

Thank you in advance

@Swiftnesses
Copy link

Is there an update on this issue, really missing ARLO integration :(

@Detoo
Copy link

Detoo commented Feb 10, 2019

If arm/disarm Arlo control panel is your top priority and you are ok that it is not reporting accurate status, below is a temporary workaround.

The following code is a modified version of alarm_control_panel component for HA v0.87.0, so please make sure you are using the same version. Create a file and paste the code to

<your-ha-config-dir>/custom_components/alarm_control_panel/arlo.py

and restart HA. It will override the existing alarm_control_panel component and disable Arlo status querying (querying too often seems to be one of the reason Arlo becomes unresponsive).

It has been working for me, as a result it becomes more responsive in handling arm/disarm, and I can still see (approx.) status-change history; however, they are blind statuses because the modified component only requests for arm/disarm and always assumes it successful without actually verifying the status with Arlo. I've added a bunch of warning messages in the code below as a reminder of such trade-off.

"""
This is a modified version of Arlo Alarm Control Panels of HA v0.87.0
Please evaluate the trade-offs below and use it as is.
"""
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.components.alarm_control_panel import (
    AlarmControlPanel, PLATFORM_SCHEMA)
from homeassistant.components.arlo import (
    DATA_ARLO, CONF_ATTRIBUTION, SIGNAL_UPDATE_ARLO)
from homeassistant.const import (
    ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME,
    STATE_ALARM_DISARMED, STATE_ALARM_ARMED_NIGHT)

_LOGGER = logging.getLogger(__name__)

ARMED = 'armed'

CONF_HOME_MODE_NAME = 'home_mode_name'
CONF_AWAY_MODE_NAME = 'away_mode_name'
CONF_NIGHT_MODE_NAME = 'night_mode_name'

DEPENDENCIES = ['arlo']

DISARMED = 'disarmed'

ICON = 'mdi:security'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_HOME_MODE_NAME, default=ARMED): cv.string,
    vol.Optional(CONF_AWAY_MODE_NAME, default=ARMED): cv.string,
    vol.Optional(CONF_NIGHT_MODE_NAME, default=ARMED): cv.string,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Arlo Alarm Control Panels."""
    arlo = hass.data[DATA_ARLO]

    if not arlo.base_stations:
        return

    home_mode_name = config.get(CONF_HOME_MODE_NAME)
    away_mode_name = config.get(CONF_AWAY_MODE_NAME)
    night_mode_name = config.get(CONF_NIGHT_MODE_NAME)
    base_stations = []
    for base_station in arlo.base_stations:
        base_stations.append(ArloBaseStation(base_station, home_mode_name,
                                             away_mode_name, night_mode_name))
    add_entities(base_stations, True)


class ArloBaseStation(AlarmControlPanel):
    """Representation of an Arlo Alarm Control Panel."""

    def __init__(self, data, home_mode_name, away_mode_name, night_mode_name):
        """Initialize the alarm control panel."""
        self._base_station = data
        self._home_mode_name = home_mode_name
        self._away_mode_name = away_mode_name
        self._night_mode_name = night_mode_name
        self._state = None

    @property
    def icon(self):
        """Return icon."""
        return ICON

    async def async_added_to_hass(self):
        """Register callbacks."""
        async_dispatcher_connect(
            self.hass, SIGNAL_UPDATE_ARLO, self._update_callback)

    @callback
    def _update_callback(self):
        """Call update method."""
        _LOGGER.warning("Skip _update_callback()... This is a hack to prevent Arlo basestation from being unresponsive.")
        # self.async_schedule_update_ha_state(True)

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Update the state of the device."""
        _LOGGER.debug("Updating Arlo Alarm Control Panel %s", self.name)
        _LOGGER.warning("Skip update()... This is a hack to prevent Arlo base station from being unresponsive.")
        # mode = self._base_station.mode
        # if mode:
        #     self._state = self._get_state_from_mode(mode)
        # else:
        #     self._state = None

    async def async_alarm_disarm(self, code=None):
        """Send disarm command."""
        self._base_station.mode = DISARMED
        _LOGGER.warning(f"Blindly setting Arlo control panel state to {STATE_ALARM_DISARMED}... This is a hack to prevent Arlo base station from being unresponsive.")
        self._state = STATE_ALARM_DISARMED

    async def async_alarm_arm_away(self, code=None):
        """Send arm away command. Uses custom mode."""
        self._base_station.mode = self._away_mode_name
        _LOGGER.warning(f"Blindly setting Arlo control panel state to {STATE_ALARM_ARMED_AWAY}... This is a hack to prevent Arlo base station from being unresponsive.")
        self._state = STATE_ALARM_ARMED_AWAY

    async def async_alarm_arm_home(self, code=None):
        """Send arm home command. Uses custom mode."""
        self._base_station.mode = self._home_mode_name
        _LOGGER.warning(f"Blindly setting Arlo control panel state to {STATE_ALARM_ARMED_HOME}... This is a hack to prevent Arlo base station from being unresponsive.")
        self._state = STATE_ALARM_ARMED_HOME

    async def async_alarm_arm_night(self, code=None):
        """Send arm night command. Uses custom mode."""
        self._base_station.mode = self._night_mode_name
        _LOGGER.warning(f"Blindly setting Arlo control panel state to {STATE_ALARM_ARMED_NIGHT}... This is a hack to prevent Arlo base station from being unresponsive.")
        self._state = STATE_ALARM_ARMED_NIGHT

    @property
    def name(self):
        """Return the name of the base station."""
        return self._base_station.name

    @property
    def device_state_attributes(self):
        """Return the state attributes."""
        return {
            ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
            'device_id': self._base_station.device_id
        }

    def _get_state_from_mode(self, mode):
        """Convert Arlo mode to Home Assistant state."""
        if mode == ARMED:
            return STATE_ALARM_ARMED_AWAY
        if mode == DISARMED:
            return STATE_ALARM_DISARMED
        if mode == self._home_mode_name:
            return STATE_ALARM_ARMED_HOME
        if mode == self._away_mode_name:
            return STATE_ALARM_ARMED_AWAY
        if mode == self._night_mode_name:
            return STATE_ALARM_ARMED_NIGHT
        return mode

@zemerick1
Copy link
Contributor

Can we just not use the API here? The API on Arlo's end has been updated and it seems this API is not keeping up. The above referenced API works great.

I keep seeing this same issue closed instead of dealing with it. . disappointing given how much everyone seems to want it.

@Nicxe
Copy link

Nicxe commented Feb 20, 2019

If you have the know how many you can help get it to work @zemerick1 ?

@zemerick1
Copy link
Contributor

I will look into it.

I'm just recommending that the Arlo component be swapped out with the API I linked to. It's better maintained. The hack above freaked out on me too. . froze HA solid. LoveLace also seems to spazz out when using the Alarm card. . .

@Nicxe
Copy link

Nicxe commented Feb 20, 2019

Looking forward to your rebuild of the component zemerick1 It will be great to have a working component again.

@Detoo
Copy link

Detoo commented Feb 20, 2019

@zemerick1 were you running other components like arlo camera or arlo sensor? My hack probably won’t work in that case because they could have their own query cycles and might still keep the base station occupied. This is just my hypothesis though since I didn’t look at their codes

@arsaboo
Copy link
Contributor

arsaboo commented Feb 20, 2019

Follow https://community.home-assistant.io/t/arlo-replacement-pyarlo-module/93511 for an update on Arlo integration. We will soon move to that library.

@zemerick1
Copy link
Contributor

Well shit. .just wasted a couple hours of my time. lol. Thanks for the update @arsaboo

@zemerick1
Copy link
Contributor

@Detoo Yeah, after looking at the code it looked like everything was being updated every 60 seconds. Either way, it looks like the project arsaboo referenced is the way to go.

I had it 50% rewritten and he dropped that bomb on me. . haha

@JuniorGamingTime
Copy link

Is the issue fixed then? @zemerick1

@jonaswikstrom
Copy link

Hello! Any reactions here?!! Issue started one year ago?
This error still occurs for me version 0.93.1

@Swiftnesses
Copy link

Swiftnesses commented May 24, 2019

Swap to Aarlo component, much better!

@stale
Copy link

stale bot commented Aug 22, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 22, 2019
@stale stale bot closed this as completed Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests