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

Canary Camera Not Working #35569

Closed
CorneliousJD opened this issue May 13, 2020 · 26 comments · Fixed by #44645
Closed

Canary Camera Not Working #35569

CorneliousJD opened this issue May 13, 2020 · 26 comments · Fixed by #44645

Comments

@CorneliousJD
Copy link

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.

@probot-home-assistant
Copy link

canary documentation
canary source
(message by IssueLinks)

@k8gg
Copy link

k8gg commented May 26, 2020

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

@martijnrusschen
Copy link

Same here, sensors working. Not getting video from the camera.

@kendadk
Copy link

kendadk commented Jun 2, 2020

same here !!

@reisfni
Copy link

reisfni commented Jun 16, 2020

Same

@davcd3
Copy link

davcd3 commented Jul 5, 2020

same, sensors okay... no video

@jcutrell
Copy link

Also seeing the KeyError: 'access_token' in logs. Sensors available, no camera images.

@nkm8
Copy link

nkm8 commented Jul 28, 2020

I opened issue snjoetw/py-canary#4 on the underlying API this integration uses. I tried debugging everything I could think of, but I was unable to resolve the login error. I included all relevant details in case anyone else wants to take a look.

@erasmus83
Copy link

Same issue here

@CeccoCQ
Copy link

CeccoCQ commented Aug 21, 2020

Same issue

@jc5796
Copy link

jc5796 commented Aug 22, 2020

same here has been this way for quite a while.

@reisfni
Copy link

reisfni commented Oct 13, 2020

Same

@snipes040
Copy link

👍 I hope this gets fixed soon!

@callifo
Copy link

callifo commented Oct 30, 2020

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.

@willscottuk
Copy link
Contributor

I'm seeing the same issue @callifo, having updated to 0.117.x. I've taken a cut of the component from before #40691 was merged, loaded that in as a custom component and can at least get the alarm control panel back, though the camera is still broken as before. When I've got a bit more time I'll try to work out what changes to the component are needed to get it to work properly with the DataUpdateCoordinator, unless @ctalkington gets there first!

@callifo
Copy link

callifo commented Oct 31, 2020

I'm seeing the same issue @callifo, having updated to 0.117.x. I've taken a cut of the component from before #40691 was merged, loaded that in as a custom component and can at least get the alarm control panel back, though the camera is still broken as before. When I've got a bit more time I'll try to work out what changes to the component are needed to get it to work properly with the DataUpdateCoordinator, unless @ctalkington gets there first!

If you just go into the camera entities and disable them and then reload, it will load the rest of the canary component normally without needing to modify HA code.

@callifo
Copy link

callifo commented Nov 26, 2020

As this is still open, I will ask the question here, but is anyone else having the issue whereby everytime you restart HA, you get a new message from Canary saying 'Security alert: New login to your account'. For some reason HA now shows up as unique logins to my Canary account every reboot. My email box is full of them.

@davcd3
Copy link

davcd3 commented Nov 26, 2020

As this is still open, I will ask the question here, but is anyone else having the issue whereby everytime you restart HA, you get a new message from Canary saying 'Security alert: New login to your account'. For some reason HA now shows up as unique logins to my Canary account every reboot. My email box is full of them.

Funny you mention that, I hadn't restarted HASS in probably a few months and got the alert and changed my password thinking it wasn't me... but after seeing your message, know this is exactly what triggered that.

@snipes040
Copy link

snipes040 commented Nov 26, 2020

Yeah I'm seeing this too, I tried disabling 2FA on my account and restarting HA but that didn't do anything either

@ctalkington
Copy link
Contributor

please keep issues on topic and open new issues where they make sense.

this component doesn't have an active codeowner/maintainer to field these issues so the only fixes made lately have been for compatibility with HA platform changes. This is why the camera still doesn't function properly as one would need access to a device to troubleshoot. The underlying python module that handles communication with Canary also hasn't been update in 2 years so if you know a developer who has a canary device, itd be worthwhile to recruit them to help maintain this integration

@markallanson
Copy link
Contributor

I also raised a PR against the python canary library to fix this snjoetw/py-canary#6 - we just need to prod @snjoetw into action to accept one of them and push a new release of the library

@markallanson
Copy link
Contributor

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.

@nkm8
Copy link

nkm8 commented Dec 30, 2020

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)

markallanson added a commit to markallanson/core that referenced this issue Dec 30, 2020
@bm1549
Copy link

bm1549 commented Jan 4, 2021

Thanks for addressing the issue with the Canary API, but I'm still having an issue with canary video playback. The thumbnail image is correct, but video fails to load in both home assistant and HomeKit. I'm running in docker using homeassistant/home-assistant:2021.1.0b2 which should contain the authentication fix introduced in #44645 and includes ffmpeg. The logs I see are below. Has anyone else had this issue with the new update?

2021-01-04 16:26:57 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2021-01-04 16:26:57 ERROR (MainThread) [pyhap.camera] [ae24c0e6-744f-4480-9ea7-acfad45d393d] Failed to start/reconfigure stream, deleting session.
2021-01-04 16:27:07 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue for canary doing I/O at homeassistant/components/canary/camera.py, line 134: self._live_stream_session.live_stream_url,
2021-01-04 16:27:07 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue for canary doing I/O at homeassistant/components/canary/camera.py, line 134: self._live_stream_session.live_stream_url,
2021-01-04 16:27:17 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue for canary doing I/O at homeassistant/components/canary/camera.py, line 134: self._live_stream_session.live_stream_url,
2021-01-04 16:27:17 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue for canary doing I/O at homeassistant/components/canary/camera.py, line 134: self._live_stream_session.live_stream_url,
2021-01-04 16:27:27 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue for canary doing I/O at homeassistant/components/canary/camera.py, line 134: self._live_stream_session.live_stream_url,
2021-01-04 16:27:27 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue for canary doing I/O at homeassistant/components/canary/camera.py, line 134: self._live_stream_session.live_stream_url,
2021-01-04 16:27:27 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pyhap/camera.py", line 600, in _stop_stream
    stream_idx = session_info['stream_idx']
TypeError: 'NoneType' object is not subscriptable

@frenck
Copy link
Member

frenck commented Jan 4, 2021

@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 👍

@bm1549
Copy link

bm1549 commented Jan 4, 2021

Thanks for responding, I've opened a new issue here: #44830

markallanson added a commit to markallanson/core that referenced this issue Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.