core: Canary Camera Not Working

The problem

when using the Canary integration, everything works except the camera images do not load.

Environment

  • Home Assistant Core release with the issue: 0.109.6
  • Last working Home Assistant Core release (if known): N/A
  • Operating environment (Home Assistant/Supervised/Docker/venv): Docker on 4.19.107-Unraid
  • Integration causing this issue: Canary
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/canary/

Problem-relevant configuration.yaml

canary:
  username: !secret canary_username
  password: !secret canary_password

Traceback/Error logs

Logger: aiohttp.server
Source: components/canary/__init__.py:131
First occurred: 1:54:10 PM (2 occurrences)
Last logged: 1:54:27 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 125, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 490, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 507, in handle
    image = await camera.async_camera_image()
  File "/usr/src/homeassistant/homeassistant/components/canary/camera.py", line 87, in async_camera_image
    await self.hass.async_add_executor_job(self.renew_live_stream_session)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/canary/camera.py", line 123, in renew_live_stream_session
    self._live_stream_session = self._data.get_live_stream_session(self._device)
  File "/usr/src/homeassistant/homeassistant/components/canary/__init__.py", line 131, in get_live_stream_session
    return self._api.get_live_stream_session(device)
  File "/usr/local/lib/python3.7/site-packages/canary/api.py", line 144, in get_live_stream_session
    self._timeout)
  File "/usr/local/lib/python3.7/site-packages/canary/live_stream_api.py", line 37, in __init__
    self.login()
  File "/usr/local/lib/python3.7/site-packages/canary/live_stream_api.py", line 56, in login
    self._token = response.json()[ATTR_ACCESS_TOKEN]
KeyError: 'access_token'

Additional information

All other Canary sensors seem to work okay but the cameras do not load at all.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 26 (5 by maintainers)

Commits related to this issue

Most upvoted comments

The change is merged in the underlying library, we’re just waiting on a new release to be created now before updating the canary integration to use it.

Can confirm the same issue. I have multiple Canary Pros (aka all-in-one); temp & humidity data feeds from each device are fine, but Camera cards show nothing.

Yes I do have the camera configured per documentation

ffmpeg:

camera:
  - platform: canary

For anyone eager for an immediate resolution, I was able to install/test the fix with these steps:

  • Add new repository to add-on store: https://github.com/home-assistant/addons-development
  • Install ‘custom deps deployment’ add-on
  • Start new add-on and set to start on boot
  • Add the following to the Configuration tab:
pypi:
  - py-canary==0.5.1
apk: []
  • Restart Home Assistant

Tested and validated my Flex camera is now working! A few notes:

  • Make sure you disable two-factor authentication on your Canary account
  • Set an email filter to handle the spam emails regarding new logins to your Canary account
  • When Home Assistant is updated to use the new library version, you will need to remove this workaround (uninstall add-on or remove py-canary from configuration tab)

I’m now getting these errors spamming my logs,

2020-10-31 00:13:10 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/update_coordinator.py", line 119, in _handle_refresh_interval
    await self.async_refresh()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
    update_callback()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/update_coordinator.py", line 223, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 322, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/camera/__init__.py", line 453, in state_attributes
    attrs = {"access_token": self.access_tokens[-1]}
AttributeError: 'CanaryCamera' object has no attribute 'access_tokens'

Never had this previously, but I don’t use the Canary camera in HA, just the arm/disarm alarm.

@bm1549 This issue has been closed, if you have an issue with the beta, please raise a new issue so we can track and assign it. Thanks 👍