JurajNyiri / HomeAssistant-Tapo-Control

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

maximum recursion depth exceeded on move_to_preset #443

Closed lv913 closed 3 months ago

lv913 commented 11 months ago

Description

I have a script which runs when I want to disable cameras at my home. To disable cameras, I move them to a preset position (named "Retro"), I set privacy mode on and I do some more stuff. When moving to preset position, sometimes (not every time) I receive the error "maximum recursion depth exceeded". I can't understand what's the root cause. My camera is C210, hardware 2.0.

Reproduction Steps

My script runs the following step when receiving the error:

device_id: af2e1dcff2b6fbbd42a67c27ce5fae65 domain: select entity_id: select.tapo_1_move_to_preset type: select_option option: Retro

Expected behavior

Camera should rotate to position "Retro" and then proceed with the script execution.

If applicable, add error logs.

Logger: homeassistant.components.script.disattivazione_allarme Source: /usr/src/homeassistant/homeassistant/helpers/script.py:1781 Integration: Script (documentation, issues) First occurred: October 30, 2023 at 18:02:51 (2 occurrences) Last logged: November 6, 2023 at 17:01:10

Disattivazione allarme: Error executing script. Unexpected error for device at pos 3: maximum recursion depth exceeded Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 720, in _async_device_step await device_action.async_call_action_from_config( File "/usr/src/homeassistant/homeassistant/components/device_automation/action.py", line 71, in async_call_action_from_config await platform.async_call_action_from_config(hass, config, variables, context) File "/usr/src/homeassistant/homeassistant/components/select/device_action.py", line 121, in async_call_action_from_config await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2049, 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/select/init.py", line 106, in async_select_option await entity.async_select_option(option) File "/config/custom_components/tapo_control/select.py", line 828, in async_select_option await self.hass.async_add_executor_job(self._controller.setPreset, foundKey) 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 1031, in setPreset return self.executeFunction( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 159, in executeFunction self.setCruise(False) File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 983, in setCruise return self.executeFunction( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 159, in executeFunction self.setCruise(False) File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 983, in setCruise return self.executeFunction( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 159, in executeFunction self.setCruise(False) File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 983, in setCruise return self.executeFunction( ^^^^^^^^^^^^^^^^^^^^^

[cut]

File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 142, in executeFunction data = self.performRequest( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 193, in performRequest res = self.request( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytapo/init.py", line 87, in request response = session.request(method, url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 462, in _make_request httplib_response = conn.getresponse() ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/http/client.py", line 1378, in getresponse response.begin() File "/usr/local/lib/python3.11/http/client.py", line 337, in begin self.headers = self.msg = parse_headers(self.fp) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/http/client.py", line 236, in parse_headers return email.parser.Parser(_class=_class).parsestr(hstring) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/parser.py", line 67, in parsestr return self.parse(StringIO(text), headersonly=headersonly) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/parser.py", line 56, in parse feedparser.feed(data) File "/usr/local/lib/python3.11/email/feedparser.py", line 174, in feed self._call_parse() File "/usr/local/lib/python3.11/email/feedparser.py", line 178, in _call_parse self._parse() File "/usr/local/lib/python3.11/email/feedparser.py", line 293, in _parsegen if self._cur.get_content_maintype() == 'message': ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/message.py", line 621, in get_content_maintype ctype = self.get_content_type() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/message.py", line 605, in get_content_type value = self.get('content-type', missing) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/message.py", line 498, in get return self.policy.header_fetch_parse(k, v) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/_policybase.py", line 316, in header_fetch_parse return self._sanitize_header(name, value) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/email/_policybase.py", line 287, in _sanitize_header if _has_surrogates(value): ^^^^^^^^^^^^^^^^^^^^^^ RecursionError: maximum recursion depth exceeded

Device Firmware

1.3.7 Build 230823 Rel.55314n(4555)

Integration Version

5.3.9

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Home Assistant 2023.10.5 on docker

Search for similar issues

Yes

Additional information

No response

scetu commented 10 months ago

Same problem with my three C200's.

LaplancheMaxime commented 9 months ago

Same with C200

krue81 commented 8 months ago

I have 4 C200 and all of them exhibit the same behavior randomly...

JurajNyiri commented 8 months ago

For people experiencing this issue: Please add firmware versions and camera types.

krue81 commented 8 months ago

I have 4 C200: 2 of them are Hardware 2.0 and are on firmware: 1.3.9 Build 231019 Rel.38052n(5553) the other 2 are Hardware 1.0 and are on firmware 1.3.9 Build 231019 Rel.37378n(5553)

lv913 commented 8 months ago

I give an update, considering the new firmware released during those months: C210 hardware 2.0, firmware 1.3.11 Build 231115 rel. 85532n(4555).

JurajNyiri commented 7 months ago

Please see the latest update to FAQ.

I receive Exception: Invalid authentication data when executing an automation / script Firmwares of cameras expect messages in sequential order. Sending them in parallel can lead to 401 code from camera which shows us with this exception. You will need to send the automation actions in sequence instead, possibly with delay as well if needed. See https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues/488 for more information.

If you make the automation / script sequential, does the issue remain?

JurajNyiri commented 3 months ago

Closing due to inactivity.