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

maximum recursion depth exceeded on move_to_preset #443

Closed
lv913 opened this issue Nov 7, 2023 · 8 comments
Closed

maximum recursion depth exceeded on move_to_preset #443

lv913 opened this issue Nov 7, 2023 · 8 comments
Labels
Help wanted Extra attention is needed

Comments

@lv913
Copy link

lv913 commented Nov 7, 2023

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
Copy link

scetu commented Dec 3, 2023

Same problem with my three C200's.

@LaplancheMaxime
Copy link

Same with C200

@krue81
Copy link

krue81 commented Jan 22, 2024

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

@JurajNyiri
Copy link
Owner

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

@krue81
Copy link

krue81 commented Jan 22, 2024

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
Copy link
Author

lv913 commented Jan 23, 2024

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
Copy link
Owner

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 #488 for more information.

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

@JurajNyiri JurajNyiri added the Help wanted Extra attention is needed label Mar 2, 2024
@JurajNyiri
Copy link
Owner

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants