JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
1.03k stars 85 forks source link

Recordings stop working after some time #356

Closed esistgut closed 12 months ago

esistgut commented 1 year ago

Description

Media recordings work without problems for some time but after a while I get "Unknown error" when opening the daily directory.

Reproduction Steps

I can't seem to notice an obvious path to get the error, reloading the extension makes it work again.

Expected behavior

The list of me recordings should be visible without errors.

If applicable, add error logs.

2023-06-01 14:39:31.938 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [3717853016] Error handling message: Unknown error (unknown_error) Esistgut from MYIP (Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 170, in websocket_browse_media
    media = await async_browse_media(hass, msg.get("media_content_id", ""))
  File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 121, in async_browse_media
    item = await _get_media_item(hass, media_content_id, None).async_browse()
  File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 79, in async_browse
    return await self.async_media_source().async_browse_media(self)
  File "/config/custom_components/tapo_control/media_source.py", line 152, in async_browse_media
    recordingsForDay = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/pytapo/__init__.py", line 589, in getRecordings
    result = self.executeFunction(
  File "/usr/local/lib/python3.10/site-packages/pytapo/__init__.py", line 137, in executeFunction
    raise Exception(
Exception: Error: -71103, Response: {"method": "searchVideoOfDay", "result": {}, "error_code": -71103}

Device Firmware

Firmware: 1.3.3 Build 230111 Rel.11786n(4555) Hardware: 2.0

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Docker on rpi 4

Search for similar issues

Yes

Additional information

No response

Casadomoticap commented 1 year ago

I have the same problem

AnzeSI commented 1 year ago

The same is happening to me. As you mentioned, reloading the extensions solves the problem temporarily, but in this case, the motion sensor turns unavailable until some motion is detected, which might stop some automations from triggering.

sereros commented 1 year ago

The noise sensor is having the same issue. It works fine for about a day, but after a day I have to reload the integration for having a working noise sensor.

JurajNyiri commented 1 year ago

Could you try with the latest beta please?

AnzeSI commented 1 year ago

I installed the 5.3.0 beta 2 and for now, it seems to work. The problem is, that the unknown error was usually shown after some time (days) that the integration was running. So I will keep checking if it happens again. However, when I installed the new version, I immediately went to check the recordings folder. When I tried to access the camera I was shown an error that the library is still being synchronised. I waited a minute and tried again and it was (and still is) working. That never happened to me before, but I also never had so many recordings on the camera.

JurajNyiri commented 1 year ago

@AnzeSI thank you, yes that is a new functionality in support of the background sync feature. It only happens at the start of the HA / integration, is not blocking and shouldn't take more than a couple of minutes.

AnzeSI commented 1 year ago

I was testing the latest version today and just went into the recordings folder multiple times today. Just now it gave the unknown error when I wanted to access the folder for any date. I can select the camera and I see folders for each day the recording was made. When I tried to access one level deeper, by selecting the folder (it does not matter which one), I get an unknown error.

JurajNyiri commented 1 year ago

Please paste the error from logs.

AnzeSI commented 1 year ago

At the time I tried to access the files, those two errors were recorded in the log.

First error:

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/tapo_control/utils.py:131 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 14:43:33 (14 occurrences) Last logged: 14:52:45

[545936630544] Error handling message: Unknown error (unknown_error) Anže Ferčec from 46.123.240.182 (Mozilla/5.0 (iPhone; CPU iPhone OS 16_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2023.4 (io.robbie.HomeAssistant; build:2023.460; iOS 16.5.1) Mobile/HomeAssistant, like Safari) [545687667216] Error handling message: Unknown error (unknown_error) Anže Ferčec from 46.123.240.182 (Mozilla/5.0 (iPhone; CPU iPhone OS 16_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2023.4 (io.robbie.HomeAssistant; build:2023.460; iOS 16.5.1) Mobile/HomeAssistant, like Safari) [546077532944] Error handling message: Unknown error (unknown_error) Anže Ferčec from 46.123.240.182 (Mozilla/5.0 (iPhone; CPU iPhone OS 16_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2023.4 (io.robbie.HomeAssistant; build:2023.460; iOS 16.5.1) Mobile/HomeAssistant, like Safari) [545730043856] Error handling message: Unknown error (unknown_error) Anže Ferčec from 46.123.240.182 (Mozilla/5.0 (iPhone; CPU iPhone OS 16_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2023.4 (io.robbie.HomeAssistant; build:2023.460; iOS 16.5.1) Mobile/HomeAssistant, like Safari) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/media_source/init.py", line 174, in websocket_browse_media media = await async_browse_media(hass, msg.get("media_content_id", "")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/media_source/init.py", line 125, in async_browse_media item = await _get_media_item(hass, media_content_id, None).async_browse() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 79, in async_browse return await self.async_media_source().async_browse_media(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/media_source.py", line 169, in async_browse_media recordingsForDay = await getRecordings(self.hass, entry, date) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/utils.py", line 131, in getRecordings recordingsForDay = await hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 586, in getRecordings result = self.executeFunction( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 138, in executeFunction raise Exception( Exception: Error: -71103, Response: {"method": "searchVideoOfDay", "result": {}, "error_code": -71103}

Second error:

Logger: custom_components.tapo_control Source: custom_components/tapo_control/init.py:648 Integration: Tapo: Cameras Control (documentation, issues) First occurred: 14:11:35 (1899 occurrences) Last logged: 14:52:56

HTTPSConnectionPool(host='10.0.0.109', port=443): Max retries exceeded with url: /stok=5adf0138f649614a27ed703a5f62eabc/ds (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f0d4b7990>: Failed to establish a new connection: [Errno 111] Connection refused')) HTTPSConnectionPool(host='10.0.0.109', port=443): Max retries exceeded with url: /stok=5adf0138f649614a27ed703a5f62eabc/ds (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f15b08cd0>: Failed to establish a new connection: [Errno 111] Connection refused')) Error: -60102, Response: {"method": "searchDateWithVideo", "result": {}, "error_code": -60102} Error: -71103, Response: {"method": "searchVideoOfDay", "result": {}, "error_code": -71103}

JurajNyiri commented 1 year ago

Fixed in 5.3.0.beta.9.2.

JurajNyiri commented 12 months ago

Fixed in 5.3.0.