JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
957 stars 80 forks source link

C200 camera seems to restart, and enters patrol mode after movement buttons are pressed #467

Closed sktoiva closed 7 months ago

sktoiva commented 7 months ago

Description

C200 camera seems to reset and go into patrol mode if movement buttons are pressed. After this the movement buttons are disabled and an error is thrown about movement not being possible when in patrol mode.

I started facing similar issue to this: #455 where the Tapo Camera Control started after an update to cause authentication failures. This was fixed with 5.4.10, but now I'm facing the issue described above.

Reproduction Steps

Press movement buttons on an active camera.

Expected behavior

Camera should move according to control presses.

If applicable, add error logs.

2023-11-19 18:55:21.345 WARNING (MainThread) [homeassistant.components.camera] Updating tapo_control camera took longer than the scheduled update interval 0:00:30 2023-11-19 18:55:23.359 DEBUG (SyncWorker_22) [custom_components.tapo_control] [pytapo] New request: 2023-11-19 18:55:23.360 DEBUG (SyncWorker_22) [custom_components.tapo_control] [pytapo] {'data': {'method': 'securePassthrough', 'params': {'request': '+Wj2KO+di85dM8/UMW8UqvrpUdVNyoEBgF+Cr4bvDPRKso1Dtm1GBtfGjmdUjyAGLls68B3oZPw39IQMDJMMYxcqy6DLx0+saEyr+RgFbtE=> 2023-11-19 18:55:23.551 DEBUG (SyncWorker_22) [custom_components.tapo_control] [pytapo] 200 2023-11-19 18:55:23.552 DEBUG (SyncWorker_22) [custom_components.tapo_control] [pytapo] {'error_code': 0, 'seq': 920, 'result': {'response': 'lhsbU4dassoRP+0kdq8IgqucTw5wYWHaicUrw7F+z3M='}} 2023-11-19 18:55:34.324 DEBUG (MainThread) [custom_components.tapo_control] mediaSync 2023-11-19 18:55:51.346 WARNING (MainThread) [homeassistant.components.camera] Updating tapo_control camera took longer than the scheduled update interval 0:00:30 2023-11-19 18:56:21.347 WARNING (MainThread) [homeassistant.components.camera] Updating tapo_control camera took longer than the scheduled update interval 0:00:30 2023-11-19 18:56:24.941 DEBUG (SyncWorker_26) [custom_components.tapo_control] [pytapo] New request: 2023-11-19 18:56:24.941 DEBUG (SyncWorker_26) [custom_components.tapo_control] [pytapo] {'data': {'method': 'securePassthrough', 'params': {'request': '+Wj2KO+di85dM8/UMW8UqvrpUdVNyoEBgF+Cr4bvDPRKso1Dtm1GBtfGjmdUjyAGLls68B3oZPw39IQMDJMMYxcqy6DLx0+saEyr+RgFbtE=> 2023-11-19 18:56:34.325 DEBUG (MainThread) [custom_components.tapo_control] mediaSync 2023-11-19 18:56:51.347 WARNING (MainThread) [homeassistant.components.camera] Updating tapo_control camera took longer than the scheduled update interval 0:00:30 2023-11-19 18:56:55.153 DEBUG (SyncWorker_26) [custom_components.tapo_control] [pytapo] 200 2023-11-19 18:56:55.153 DEBUG (SyncWorker_26) [custom_components.tapo_control] [pytapo] {'error_code': 0, 'seq': 921, 'result': {'response': 'lhsbU4dassoRP+0kdq8IgpnlWIbVRfgMYhkh91L1v08='}} 2023-11-19 18:56:55.155 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547212904896] Error: -60102, Response: {"error_code": -60102} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/button/init.py", line 124, in _async_press_action await self.async_press() File "/config/custom_components/tapo_control/button.py", line 194, in async_press await self._hass.async_add_executor_job(self._controller.moveMotor, degrees, 0) 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 1094, in moveMotor return self.performRequest( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 595, in performRequest raise Exception( Exception: Error: -60102, Response: {"error_code": -60102} 2023-11-19 18:57:21.348 WARNING (MainThread) [homeassistant.components.camera] Updating tapo_control camera took longer than the scheduled update interval 0:00:30 2023-11-19 18:57:29.529 WARNING (MainThread) [haffmpeg.tools] Timeout reading image. 2023-11-19 18:57:34.326 DEBUG (MainThread) [custom_components.tapo_control] mediaSync 2023-11-19 18:57:51.350 WARNING (MainThread) [homeassistant.components.camera] Updating tapo_control camera took longer than the scheduled update interval 0:00:30 2023-11-19 18:57:56.447 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] New request: 2023-11-19 18:57:56.448 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'data': {'method': 'securePassthrough', 'params': {'request': '+Wj2KO+di85dM8/UMW8UqvrpUdVNyoEBgF+Cr4bvDPRKso1Dtm1GBtfGjmdUjyAGVG3nagA916Lm7aDq5UG1e6IV4wnMha8btR7/fgcrvPE='> 2023-11-19 18:57:56.949 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] 200 2023-11-19 18:57:56.949 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'error_code': -40401, 'result': {'data': {'code': -40407, 'encrypt_type': ['3'], 'key': 'REDACTED', 'nonce': 'REDACTED'}}} 2023-11-19 18:57:56.949 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Refreshing stok... 2023-11-19 18:57:56.950 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Connection is secure. 2023-11-19 18:57:56.952 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] New request: 2023-11-19 18:57:56.952 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'data': {'method': 'login', 'params': {'cnonce': 'REDACTED', 'encrypt_type': '3', 'username': 'admin'}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'a> 2023-11-19 18:57:57.081 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] 200 2023-11-19 18:57:57.081 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'error_code': -40413, 'result': {'data': {'code': -40401, 'encrypt_type': ['3'], 'key': 'REDACTED', 'nonce': 'REDACTED', 'device_confirm': 'REDACTED'}}} 2023-11-19 18:57:57.081 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Status code: 200 2023-11-19 18:57:57.081 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Processing secure response. 2023-11-19 18:57:57.081 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Validating device confirm. 2023-11-19 18:57:57.082 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Signing in with digestPasswd. 2023-11-19 18:57:57.084 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] New request: 2023-11-19 18:57:57.084 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'data': {'method': 'login', 'params': {'cnonce': 'REDACTED', 'encrypt_type': '3', 'digest_passwd': 'REDACTED', 'username': 'admin'}}, 'headers': {'Host': 'REDACTED', 'Refer> 2023-11-19 18:57:57.218 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] 200 2023-11-19 18:57:57.218 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'error_code': 0, 'result': {'stok': 'REDACTED', 'user_group': 'root', 'start_seq': 589}} 2023-11-19 18:57:57.219 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Geneerating encryption tokens. 2023-11-19 18:57:57.219 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] Saving stok. 2023-11-19 18:57:57.223 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] New request: 2023-11-19 18:57:57.223 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'data': {'method': 'securePassthrough', 'params': {'request': 'l75Qm0IQRmOlG+QvFpBDNixIVInTcZJ15nMomaomcnuYaf6ycQbv3tmfkTga0ZuZMb7EWarbKS5IhIF2/wZiM4QJGez6qH9ST5FB8niPKiw='> 2023-11-19 18:57:57.509 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] 200 2023-11-19 18:57:57.509 DEBUG (SyncWorker_6) [custom_components.tapo_control] [pytapo] {'error_code': 0, 'seq': 589, 'result': {'response': '6YNu/FZuqc2ITuVDGBrSBMwgWkj8oiyy6agHR7zER5o='}} 2023-11-19 18:57:57.511 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547255837504] Error: Action cannot be done while camera is in patrol mode., Response: {"error_code": -64303} Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/button/init.py", line 124, in _async_press_action await self.async_press() File "/config/custom_components/tapo_control/button.py", line 162, in async_press await self._hass.async_add_executor_job(self._controller.moveMotor, 0, degrees) 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 1094, in moveMotor return self.performRequest( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 593, in performRequest return self.performRequest(requestData, loginRetryCount + 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 595, in performRequest raise Exception( Exception: Error: Action cannot be done while camera is in patrol mode., Response: {"error_code": -64303}

Device Firmware

1.3.9 Build 231019 Rel.29120n(4555)

Integration Version

5.4.10

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 Raspberry Pi

Search for similar issues

Yes

Additional information

No response

JurajNyiri commented 7 months ago

As discussed on Discord, camera calibrates on start (not patrol mode, which is different), that is expected.

The error message seems to be the same as when in patrol mode though.

In the logs I see when the camera restarted and then the integration regains connection, you need to wait until it calibrates to issue further commands for movement.

From the looks of it, integration works exactly as expected, if the camera restarts its the camera issue, we did not ask it to restart.

As discussed on Discord, you can try waiting longer, issuing other commands to see if they also cause the camera to reboot.

I see a lot of Updating tapo_control camera took longer than the scheduled update interval 0:00:30. Make sure to not overload the camera and it has a stable wifi connection. I own C200 as well (hw 1.0 and 3.0 and see no behavior like this).

There is nothing to fix from the integration side so closing this issue unless new information comes up.