roleoroleo / yi-hack_ha_integration

Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner, yi-hack-Allwinner-v2, yi-hack-v5 and sonoff-hack
GNU General Public License v3.0
205 stars 32 forks source link

[help needed] Media Browser thumbnail issues - AUTHORIZATION headers #111

Closed dieideeistgut closed 1 year ago

dieideeistgut commented 1 year ago

Heyas, i am kind of blind finding the issue for this one - thanks for your reading time.

Since some days and after a HA update i am no longer able to get thumbs in the media browser working. They all come back with a 401 as the headers seem not beeing submitted correctly at least in my setup here (traefik in front). Videos/MP4s can be viewd though. I am running the 0.4.4 now.

automation_hass           | 2023-02-23 13:19:35.116 ERROR (MainThread) [aiohttp.server] Error handling request
automation_hass           | Traceback (most recent call last):
automation_hass           |   File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
automation_hass           |     resp = await request_handler(request)
automation_hass           |   File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
automation_hass           |     resp = await handler(request)
automation_hass           |   File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
automation_hass           |     return await handler(request)
automation_hass           |   File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
automation_hass           |     return await handler(request)
automation_hass           |   File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
automation_hass           |     return await handler(request)
automation_hass           |   File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
automation_hass           |     return await handler(request)
automation_hass           |   File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
automation_hass           |     return await handler(request)
automation_hass           |   File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
automation_hass           |     return await handler(request)
automation_hass           |   File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
automation_hass           |     result = await result
automation_hass           |   File "/config/custom_components/yi_hack/views.py", line 70, in get
automation_hass           |     return await self._handle_request(request, **kwargs)
automation_hass           |   File "/config/custom_components/yi_hack/views.py", line 107, in _handle_request
automation_hass           |     async with self._websession.request(
automation_hass           |   File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in __aenter__
automation_hass           |     self._resp = await self._coro
automation_hass           |   File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 487, in _request
automation_hass           |     raise ValueError(
automation_hass           | ValueError: Cannot combine AUTHORIZATION header with AUTH argument or credentials encoded in URL

HA is Home Assistant 2023.3.0b0 Yihack is Allwinner-V2 latest

Some hints in which way to dig may already help me out. I know there had been issues with this in the past and different versions of HA, Yi-Hack and Yi-Hack-Integration as well as with traefik.

Thanks!

roleoroleo commented 1 year ago

Did you enable http authentication in the cam?

dieideeistgut commented 1 year ago

I've set up two Cams 100% identical (y211ga and y21ga). Tried with and without http-auth. Also tried re-adding the two cams when enabling/disabling auth. Both cams had thumbs previously and i did not change anything regarding my traefik-proxy. Just did the update of the yi-hack on the cams and the integration and thumbnails disappeared. The thumbs do exist on the cams and the thumbnail-creation bash script runs fine. I'll be looking into this.

dieideeistgut commented 1 year ago

Became ill 4 days ago. Just to keep this updated - the raised error is from aiohttp:

https://github.com/aio-libs/aiohttp/blob/3058c72dc417cf7fabcc5a1d71e5238f93469012/aiohttp/client.py#L441

Looking into this now even more.

roleoroleo commented 1 year ago

I installed traefik and reconfigured my ha. All is working properly. I don't know how to replicate the problem.

dieideeistgut commented 1 year ago

Are you using any special configs/labels for traefik that i may have missed? I'll setup a clean instance later and retry - without http-authenitication on the cam.

roleoroleo commented 1 year ago

Are you using any special configs/labels for traefik that i may have missed?

It's my first installation, so it's very very simple:

No http authentication in the cams.

dieideeistgut commented 1 year ago

Managed to get it working finally on both cams. Resolution was as follows and a combination of various things:

Thanks a ton again for all this greatness and your commitment here. I'll close this.