Core: Yale smart alarm .084 fails error

Created on 13 Dec 2018  路  10Comments  路  Source: home-assistant/core

Home Assistant release with the issue: 0.84.1

Operating environment (Hass.io/Docker/Windows/etc.):
hass.io

Component/platform:
https://www.home-assistant.io/components/alarm_control_panel.yale_smart_alarm/

Description of problem:
works fine on first reboot yet then becomes unresponsive and fills the log with the below error

2018-12-13 08:18:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for alarm_control_panel.yale_smart_alarm fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/alarm_control_panel/yale_smart_alarm.py", line 84, in update
    armed_status = self._client.get_armed_status()
  File "/usr/local/lib/python3.6/site-packages/yalesmartalarmclient/client.py", line 49, in get_armed_status
    alarm_state = self._get_authenticated(self._ENDPOINT_GET_MODE)
  File "/usr/local/lib/python3.6/site-packages/yalesmartalarmclient/client.py", line 92, in _get_authenticated
    data = response.json()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
yale_smart_alarm

Most helpful comment

Thanks for investigating @charlesastaylor, will hopefully have a few spare minutes in the next couple of days to get this up.

All 10 comments

Same here. If I restart HA then it seems to work for a while then error continues to repeat as though it's timed out.

@domwillcode
would you be able to offer any assistance?

I've just noticed there was a post by @charlesastaylor that mentions something similar while testing before the issue was closed as the component was being updated

https://github.com/home-assistant/home-assistant/issues/17396

Yeah, I believe this is the issue with the refresh token @charlesastaylor solved. I'll double check and get a new version into HA as soon as I can.

All day it's been logging errors at random times. Yet it seem the token last about 12hrs before it expires.

Restarted my HA at 7.30am this morning stoped working now 8.00pm then errors appear in the log every minute

Hi. Yep this looks like a result of the bug I fixed here.

Access tokens expire after 10 hours and due to changes to the Yale API the check to test if this had happened no longer worked so the client never updates it's token and all requests fail. The error itself is a result of calling the requests json() method on an empty response.

The change I made to make use of refresh tokens was actually separate and probably shouldn't have been in the same PR.

@domwillcode Having just checked, I believe a new release needs to be put on PyPI and the HA requirements updated to reflect that.

In the meantime you can manually replace the yalesmartalarmclient/client.py that HA uses to the latest code and it'll work as expected.

Is it possible to use this on hass.io as a custom component or are they built differently?

Ah, didn't notice your environment. I've never used hass.io so don't know the answer to your question I'm afraid.

Looking at your stack trace though, if you can access the file system (with ssh maybe) the file you're looking to edit is /usr/local/lib/python3.6/site-packages/yalesmartalarmclient/client.py. No idea if this would mess up anything up in hass.io. Also, having looked into it a bit, I'm not sure it's really advised to manually edit files in site-packages anyway...

Okay thanks
I don't think you can access site packages in hass.io

I'll just have to wait for the new version to be submitted officially

Thanks for investigating @charlesastaylor, will hopefully have a few spare minutes in the next couple of days to get this up.

@domwillcode
Is The latest version 100% working and if so would it be possible to see it in the next HA update.

Merry Christmas

Was this page helpful?
0 / 5 - 0 ratings