make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.33k stars 519 forks source link

Tuya has lost all connectivity from Home Assistant #2083

Closed b14ckw1d0w closed 3 months ago

b14ckw1d0w commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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.