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

Tuya has lost all connectivity from Home Assistant #2083

Closed
b14ckw1d0w opened this issue Jul 7, 2024 · 3 comments
Closed

Tuya has lost all connectivity from Home Assistant #2083

b14ckw1d0w opened this issue Jul 7, 2024 · 3 comments

Comments

@b14ckw1d0w
Copy link

Describe the bug
Since yesterday, my devices have been unable to be reached from within Home Assistant while they are still online and available from Alexa and SmartLife app. I am reveiving errors in home assistant regarding these issues. All logs are attached in this report.

To Reproduce
Steps to reproduce the behavior including the device the issue was observed with:
Installed and used Tuya for switches with power monitoring successfully for a few weeks and tonight the devices cannot be reached from Home Assistant.
Restarting Home Assistant or the whole system does not remedy the situation.

Expected behavior
Devices to be reachable and responsive from within Home Assistant.

Additional context
All logs attached below.

Logger: homeassistant.util.loop
Source: util/loop.py:136
First occurred: 04:24:08 (1 occurrence)
Last logged: 04:24:08

Message:

Detected blocking call to open with args ('/config/custom_components/tuya_local/devices/smartplugv2_energyv2.yaml',) inside the event loop by custom integration 'tuya_local' at custom_components/tuya_local/helpers/device_config.py, line 101:

python
Copy code
self._config = load_yaml(filename)
Offender:

python
Copy code
/usr/src/homeassistant/homeassistant/util/yaml/loader.py, line 226: with open(fname, encoding="utf-8") as conf_file:
Please create a bug report at:
https://github.com/make-all/tuya-local/issues
For developers, please see:
https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open

Traceback (most recent call last):

scss
Copy code
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/main.py", line 223, in sys.exit(main())
File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request)
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request)
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request)
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, **request.match_info)
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 262, in post return await super().post(request)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper return await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 77, in post return await self._post_impl(request, data)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl result = await self._flow_mgr.async_init(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 343, in async_init result = await self._async_handle_step(flow, flow.init_step, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input)
File "/config/custom_components/tuya_local/config_flow.py", line 548, in async_step_init return await self.async_step_user(user_input)
File "/config/custom_components/tuya_local/config_flow.py", line 581, in async_step_user cfg = get_config(config[CONF_TYPE])
File "/config/custom_components/tuya_local/helpers/device_config.py", line 998, in get_config return TuyaDeviceConfig(fname)
File "/config/custom_components/tuya_local/helpers/device_config.py", line 101, in init self._config = load_yaml(filename)

This error originated from a custom integration.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:436
integration: Tuya Local (documentation, issues)
First occurred: 04:22:54 (7 occurrences)
Last logged: 04:24:32

Porch Light protocol error 901: Network Error: Unable to Connect
Living Room Light Switch protocol error 901: Network Error: Unable to Connect
Bedroom protocol error 901: Network Error: Unable to Connect
Cupboard protocol error 901: Network Error: Unable to Connect
Test protocol error 901: Network Error: Unable to Connect

This error originated from a custom integration.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:560
integration: Tuya Local (documentation, issues)
First occurred: 04:23:30 (125 occurrences)
Last logged: 04:26:39

Failed to fetch device status for Bedroom
Failed to fetch device status for Cupboard
Failed to fetch device status for Living Room Light Switch
Failed to fetch device status for Porch Light
Failed to fetch device status for Living Room Light

Device logs:

config_entry-tuya_local-077ff44f444f7bf9348699fee4acc619.json
config_entry-tuya_local-01J22QBSCH537SQBC6AQRS08JA.json

@b14ckw1d0w b14ckw1d0w added the bug Something isn't working label Jul 7, 2024
@b14ckw1d0w
Copy link
Author

I'd like to add that my router crashed and restarted and since then the 2 switches in question have returned but one of my lights is still unavailable in Home Assistant. I have power cycled the light and confirmed its available in Alexa and SmartLife app.

Is there any way to find out more about my problem since I now believe it is not completely a bug that should be reported here.

@make-all
Copy link
Owner

make-all commented Jul 7, 2024

The important errors here are:

Porch Light protocol error 901: Network Error: Unable to Connect
Living Room Light Switch protocol error 901: Network Error: Unable to Connect
Bedroom protocol error 901: Network Error: Unable to Connect
Cupboard protocol error 901: Network Error: Unable to Connect
Test protocol error 901: Network Error: Unable to Connect

The stack trace above that is related to the config flow (I guess you tried to edit the config to try to resolve the problem), and is not fatal, just Home Assistant recently started warning about loading local files in the event loop, as well as the network connections mentioned in the documentation, as they try to improve the performance more and more with each release.

Unfortunately the message does not say much, but it seems like a total failure to make a connection rather than any specific connection option being wrong. One thing it could be is if the router reboot caused IP addresses to change, then the IP addresses may need updating in the config.

@make-all
Copy link
Owner

make-all commented Jul 7, 2024

You might find #522 useful. I am going to close this, as I do not think this is a bug in the integration, rather a local network issue that hopefully that discussion might hold the key to.

@make-all make-all closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2024
@make-all make-all removed the bug Something isn't working label Jul 7, 2024
make-all added a commit that referenced this issue Jul 8, 2024
Avoid blocking the event loop.

Issue #2083 and others.
timlaing pushed a commit to timlaing/tuya-local that referenced this issue Aug 8, 2024
Avoid blocking the event loop.

Issue make-all#2083 and others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants