rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.95k stars 562 forks source link

Can't add new devices. "An unknown error occurred. See log for details." #1139

Open rnkhq opened 1 year ago

rnkhq commented 1 year ago

Capture3

I have added 11 devices when I set up Home Assistant. After ever since that I can't add anymore devices, It's giving me the error after submitting the 'Local key'. "An unknown error occurred. See log for details."

Here's the log:

This error originated from a custom integration.

Logger: custom_components.localtuya.common Source: custom_components/localtuya/pytuya/init.py:704 Integration: LocalTuya (documentation, issues) First occurred: 10:19:16 PM (2106 occurrences) Last logged: 11:01:39 PM

[bf4...aea] Connect to 192.168.0.120 failed [bf1...bsg] Connect to 192.168.0.182 failed [bfe...dkx] Connect to 192.168.0.112 failed [bfd...jhb] Connect to 192.168.0.197 failed [bf5...tqu] Connect to 192.168.0.114 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 186, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 704, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionResetError: [Errno 104] Connect call failed ('192.168.0.107', 6668)

I'm also facing problem with devices going offline now and then. Screenshot_20221122-225203_Chrome

By the way I have integrated tuya also to use some unsupported devices. This integration also showed error when I was trying to add it.

And after every HA restart the integration struggles to restart and sometimes fails also. Capture1

Kindly help me out here. Almost all my devices are tuya, so if they are problematic like this I might have to cancel my plans with home assistant. I'm a noob, kindly ignore my mistakes. I'll provide any information needed to diagnose this. I'm running Home Assistant supervised os on debian 11.

ajunio3 commented 1 year ago

Same problem here, some devices going "unavailable" but some identical not. Removed and readded shows "no local datapoints". need help

ajunio3 commented 1 year ago

Capturar

LASounD22 commented 1 year ago

I too have the same problem here. The last device I want to integrate and it gives me the finger ;(

For the device unavailable problem, It seems that when I power cycle the device, it becomes available again for a few minutes. Maybe a time out of some sort...

LASounD22 commented 1 year ago

Logger: homeassistant Source: custom_components/localtuya/pytuya/init.py:485 Integration: LocalTuya (documentation, issues) First occurred: 6:27:26 AM (49545 occurrences) Last logged: 8:15:24 PM

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/var/snap/home-assistant-snap/533/custom_components/localtuya/common.py", line 299, in _async_refresh await self._interface.update_dps() File "/var/snap/home-assistant-snap/533/custom_components/localtuya/pytuya/init.py", line 535, in update_dps await self.detect_available_dps() File "/var/snap/home-assistant-snap/533/custom_components/localtuya/pytuya/init.py", line 574, in detect_available_dps data = await self.status() File "/var/snap/home-assistant-snap/533/custom_components/localtuya/pytuya/init.py", line 507, in status status = await self.exchange(STATUS) File "/var/snap/home-assistant-snap/533/custom_components/localtuya/pytuya/init.py", line 485, in exchange self.transport.write(payload) AttributeError: 'NoneType' object has no attribute 'write'

tk627 commented 1 year ago

I recently added 3 Minostron coutdown timers to my house
The Specification Json is the following: { "result": { "category": "kg", "functions": [ { "code": "switch_1", "lang_config": { "false": "Off", "true": "On" }, "name": "Switch 1", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "lang_config": { "unit": "s" }, "name": "Timer 1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "switch_1", "lang_config": { "false": "Off", "true": "On" }, "name": "Switch 1", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "lang_config": { "unit": "s" }, "name": "Timer 1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1669482759658, "tid": "87f8e09c6dad11edb520b24a35dfa8b8" }

I cannot add them to my localTuya in HA with the following error: This error originated from a custom integration.

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:704 Integration: LocalTuya (documentation, issues) First occurred: 10:16:30 AM (2 occurrences) Last logged: 10:17:05 AM

Unexpected exception Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 580, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 245, in validate_input interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 704, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.69.89', 6668)

rnkhq commented 1 year ago

@LASounD22 @ajunio3 @tk627 are you guys running HA on Debian 11 supervised os?

tk627 commented 1 year ago

I'm running on a Raspberry Pi 4B with 8GB RAM, and a 200GB SSD: Home Assistant 2022.11.4 Supervisor 2022.11.2 Operating System 9.3 Frontend 20221108.0 - latest

noinlijin commented 1 year ago

I have the same error

“An unknown error occurred. See log for details.”

ajunio3 commented 1 year ago

@LASounD22 @ajunio3 @tk627 are you guys running HA on Debian 11 supervised os?

running HAOS in virtualbox

pedronunesbr commented 1 year ago

I have the same error: This error originated from a custom integration.

Logger: homeassistant Source: custom_components/localtuya/common.py:125 Integration: LocalTuya (documentation, issues) First occurred: 1:08:53 AM (6890 occurrences) Last logged: 2:16:48 AM

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 1027, in _read_ready self._protocol.datagram_received(data, addr) File "/config/custom_components/localtuya/discovery.py", line 70, in datagram_received self.device_found(decoded) File "/config/custom_components/localtuya/discovery.py", line 79, in device_found self._callback(device) File "/config/custom_components/localtuya/init.py", line 105, in _device_discovered entry = async_config_entry_by_device_id(hass, device_id) File "/config/custom_components/localtuya/common.py", line 125, in async_config_entry_by_device_id if device_id in entry.data[CONF_DEVICES]: KeyError: 'devices'

DiveJack commented 1 year ago

I have the same error: Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:704 Integration: LocalTuya integration (documentation, issues) First occurred: 10:29:32 (1 occurrences) Last logged: 10:29:32

Unexpected exception Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 580, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 245, in validate_input interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 704, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.22.126', 6668)

NeoFax75 commented 1 year ago

Same error. Just trying to add the same devices for other rooms:

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:704 Integration: LocalTuya (documentation, issues) First occurred: 05:25:16 (19 occurrences) Last logged: 05:26:51

Unexpected exception Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 580, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 245, in validate_input interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 704, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.0.140', 6668)

rnkhq commented 1 year ago

Finally I solved it with an external USB wifi adapter! Everything's solved from devices going offline, local tuya unknown error, tuya failed to setup. Also kinda worked by forget wifi and re-adding wifi. Give it a try!

Bignose3 commented 1 year ago

As no follow ups did this solve it, New to LocayTuya so tested but adding some new smart wifi plugs & they all added & worked fine Went to add 9 identical plugs (already on SmartLife) & could not add ANY that was already registered. That was last night, this morning managed to add 5 straight off, no problem. the others still failed. Similar locations & same wifi AP. I was hoping to get local working as bought 16 Antela Wifi Power monitoring plugs and via smartlife APP cloud I can only get about 7 working at a time, add any more & the first'ish registered start to go offline.

Will try the forget & re-add wifi but they are rather spread about my business premises so not immediately accessible.

bulcke commented 1 year ago

I'm having the same issue with Tuya Wifi Temperature and Humidity Sensor (with display), model TH-01.

I noticed there is no way to factory reset this model. The wifi chip will reuse the initial DHCP lease, no matter what. Even if the lease is released on the DHCP server, the device will stick to the old IP, even after having the batteries out for a while. This leads me to believe the DHCP client implementation on the device is bad. (I have seen similar issues years ago on high end iPhones actually sticking to an IP, even when connecting to totally different networks). My DHCP lease time is 5 days. If the device at least respects that, it should talk to the DHCP server (at least a renew command).

That said, I don't think the IP addressing problem is really related to the actual issue. It may be contributing however: The device will try to stay connected to online servers. Tuya app on smartphone may also try to keep connection with the device. Maybe HA/localtuya is just not able to open a network socket on the same port (6668).

jamieweavis commented 1 year ago

Restarting the Home Assistant server seems to temporarily fix this issue, I was able to add 3 smart plug devices before the error returned, restarting the server once again allowed me to add my remaining plugs... 🤔

rcarletto commented 1 year ago

Sabe issue here. Restart doesn't solve: Unexpected exception: [Errno 113] Connect call failed ('192.168.0.4', 6668) Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 595, in async_step_configure_device self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 242, in validate_input interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 1182, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.0.4', 6668)