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

Integration strangely stops working after adding a new device, v5.2.2(1?), HA 2024.11.3 #1862

Open
4 tasks done
Skydev0h opened this issue Dec 6, 2024 · 1 comment
Open
4 tasks done
Labels
bug Something isn't working

Comments

@Skydev0h
Copy link

Skydev0h commented Dec 6, 2024

The problem

After adding a new device the integration stops working. Existing devices become unavailable, and new devices cannot be added.
Attempting to add a new device results in error "Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists." - the second part of the log is about this.
It is necessary to restart HA for the integration to function again.

Environment

  • Localtuya version: 5.2.2 in HACS, but 5.2.1 on integration page, even reinstalled to be sure
  • Home Assistant Core version: 2024.11.3
  • Does the device work using the Home Assistant Tuya Cloud component ?
  • Does the device work using the Tinytuya (https://github.com/jasonacox/tinytuya) command line tool ?
  • Was the device working with earlier versions of localtuya ? Which one? Kinda irrelevant.
  • Are you using the Tuya/SmartLife App in parallel Yes and no, the issue does occur in either case.

Steps to reproduce

  1. Add a new device using config flow.
  2. Most likely the new (and all old) devices will be unavailable. If not, repeat step 1.
  3. Try to add a new device - most likely it will fail with mentioned error, sometimes device does add, but does not even appear as device until HA is restarted (completely).

DP dump

Irrelevant for such issue.

Provide Home Assistant traceback/logs

hass  | 2024-12-06 03:09:32.239 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module with args ('.switch', 'custom_components.localtuya') inside the event loop by custom integration 'localtuya' at custom_components/localtuya/config_flow.py, line 200: return import_module("." + platform, integration_module).flow_schema(dps_strings) (offender: /config/custom_components/localtuya/config_flow.py, line 200: return import_module("." + platform, integration_module).flow_schema(dps_strings)), please create a bug report at https://github.com/rospogrigio/localtuya/issues
hass  | For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module
hass  | Traceback (most recent call last):
hass  |   File "<frozen runpy>", line 198, in _run_module_as_main
hass  |   File "<frozen runpy>", line 88, in _run_code
hass  |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
hass  |     sys.exit(main())
hass  |   File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
hass  |     exit_code = runner.run(runtime_conf)
hass  |   File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
hass  |     return loop.run_until_complete(setup_and_run_hass(runtime_config))
hass  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
hass  |     self.run_forever()
hass  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
hass  |     self._run_once()
hass  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
hass  |     handle._run()
hass  |   File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
hass  |     self._context.run(self._callback, *self._args)
hass  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 556, in start
hass  |     task = asyncio.Task(coro, loop=loop, eager_start=True)
hass  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
hass  |     resp = await request_handler(request)
hass  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 567, in _handle
hass  |     return await handler(request)
hass  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
hass  |     return await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
hass  |     return await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
hass  |     return await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
hass  |     return await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
hass  |     return await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
hass  |     return await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
hass  |     response = await handler(request)
hass  |   File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
hass  |     result = await handler(request, **request.match_info)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
hass  |     return await func(self, request, *args, **kwargs)
hass  |   File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 285, in post
hass  |     return await super().post(request, flow_id)
hass  |   File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
hass  |     return await method(view, request, data, *args, **kwargs)
hass  |   File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
hass  |     result = await self._flow_mgr.async_configure(flow_id, data)
hass  |   File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in async_configure
hass  |     result = await self._async_configure(flow_id, user_input)
hass  |   File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 414, in _async_configure
hass  |     result = await self._async_handle_step(
hass  |   File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step
hass  |     result: _FlowResultT = await getattr(flow, method)(user_input)
hass  |   File "/config/custom_components/localtuya/config_flow.py", line 676, in async_step_pick_entity_type
hass  |     return await self.async_step_configure_entity()
hass  |   File "/config/custom_components/localtuya/config_flow.py", line 782, in async_step_configure_entity
hass  |     schema = platform_schema(self.selected_platform, available_dps)
hass  |   File "/config/custom_components/localtuya/config_flow.py", line 194, in platform_schema
hass  |     return vol.Schema(schema).extend(flow_schema(platform, dps_strings))
hass  |   File "/config/custom_components/localtuya/config_flow.py", line 200, in flow_schema
hass  |     return import_module("." + platform, integration_module).flow_schema(dps_strings)

...

hass  | 2024-12-06 03:19:14.856 ERROR (MainThread) [custom_components.localtuya.pytuya] [064...038] Failed to get status:
hass  | Traceback (most recent call last):
hass  |   File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
hass  |     return await fut
hass  |            ^^^^^^^^^
hass  |   File "/usr/local/lib/python3.12/asyncio/locks.py", line 386, in acquire
hass  |     await fut
hass  | asyncio.exceptions.CancelledError
hass  |
hass  | The above exception was the direct cause of the following exception:
hass  |
hass  | Traceback (most recent call last):
hass  |   File "/config/custom_components/localtuya/pytuya/__init__.py", line 863, in detect_available_dps
hass  |     data = await self.status()
hass  |            ^^^^^^^^^^^^^^^^^^^
hass  |   File "/config/custom_components/localtuya/pytuya/__init__.py", line 795, in status
hass  |     status = await self.exchange(DP_QUERY)
hass  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hass  |   File "/config/custom_components/localtuya/pytuya/__init__.py", line 769, in exchange
hass  |     msg = await self.dispatcher.wait_for(seqno, payload.cmd)
hass  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hass  |   File "/config/custom_components/localtuya/pytuya/__init__.py", line 450, in wait_for
hass  |     await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
hass  |   File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for
hass  |     async with timeouts.timeout(timeout):
hass  |   File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
hass  |     raise TimeoutError from exc_val
hass  | TimeoutError

Additional information

I hope that is enough, but, if needed, I can enable more logging.

@Skydev0h Skydev0h added the bug Something isn't working label Dec 6, 2024
@spaulson500
Copy link

I get this error too with new devices. Using TinyTuya I can control the device if I specify protocol 3.5. Seems Local Tuya does not support 3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants