Hello all,
I have 16 devices connected with Local Tuya and today, after about a couple of months without any problems, HA reports me two switches are not available. Yet the switches are present in the Local Tuya list, are connected to wifi and work without problems with Smart Life and Alexa. I tried to re-register them in Local Tuya, but it tells me they already exist. I looked for a way to delete them from Local Tuya and then re-enter them, but I could not find anything about it.
Can you help me? Thank you
Sometimes, i need to open tuya app and send a command to my localtuya devices. Then in next couple of minutes, they come back to life
I don’t remember if I used Smart Life before the switches became unavailable, but it’s been more than 24 hours since it happened.
If you have deleted those two switches from Local Tuya but they are still existing with HA you can not readd them because as you have already found it out Local Tuya considers them as already existing switches and refuses to add them.
What you can do is the following (careful though!):
-
Backup the following three files from the /config/.storage/ directory:
core.device_registry
core.config_entries
core.restore_state -
Now edit each of the above files and remove all of the entries referring to those two switches from them.
-
Restart Home Assistant.
You should be able to readd those two switches through Local Tuya now.
But let me point this out again: Be very careful when tampering with those files and keep the backups ready for just in case!
Hello @Tamsy ,
thanks for the instructions. I did as you told me, but now even seeing the two switches nothing has changed: they continue not to be available. However, I have seen that the log reports connection errors relating to the affected switches (ip error), but I do not understand what the problem is. Here is a part of the log:
2022-01-13 00:31:22 ERROR (MainThread) [custom_components.localtuya.common] [eb7…gn8] Connect to 192.168.0.195 failed
Traceback (most recent call last):
File “/config/custom_components/localtuya/common.py”, line 145, in _make_connection
self._interface = await pytuya.connect(
File “/config/custom_components/localtuya/pytuya/init.py”, line 669, in connect
_, protocol = await loop.create_connection(
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1056, in create_connection
raise exceptions[0]
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1041, in create_connection
sock = await self._connect_sock(
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 955, in _connect_sock
await self.sock_connect(sock, address)
File “/usr/local/lib/python3.9/asyncio/selector_events.py”, line 502, in sock_connect
return await fut
File “/usr/local/lib/python3.9/asyncio/selector_events.py”, line 537, in _sock_connect_cb
raise OSError(err, f’Connect call failed {address}')
OSError: [Errno 113] Connect call failed (‘192.168.0.195’, 6668)
2022-01-13 00:31:22 ERROR (MainThread) [custom_components.localtuya.common] [eb8…iv5] Connect to 192.168.0.183 failed
Traceback (most recent call last):
File “/config/custom_components/localtuya/common.py”, line 145, in _make_connection
self._interface = await pytuya.connect(
File “/config/custom_components/localtuya/pytuya/init.py”, line 669, in connect
_, protocol = await loop.create_connection(
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1056, in create_connection
raise exceptions[0]
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 1041, in create_connection
sock = await self._connect_sock(
File “/usr/local/lib/python3.9/asyncio/base_events.py”, line 955, in _connect_sock
await self.sock_connect(sock, address)
File “/usr/local/lib/python3.9/asyncio/selector_events.py”, line 502, in sock_connect
return await fut
File “/usr/local/lib/python3.9/asyncio/selector_events.py”, line 537, in _sock_connect_cb
raise OSError(err, f’Connect call failed {address}')
OSError: [Errno 113] Connect call failed (‘192.168.0.183’, 6668)
I checked the two IPs for errors and it is precisely those of the two switches that are not available. I really don’t understand what the problem could be that they can’t connect.
I solved the problem. I thought that failure of the ip connection could depend on the fact that the port indicated in the log could be occupied by another user. Then through the router I disconnected and reconnected the two switches from the network and now they started working again. I honestly don’t know who they might have stayed connected to (maybe Smart Life?). However, the important thing is to have solved it and to have understood what the problem could be in case it happens again in future.
Thank you all for collaboration.
p.s.: I apologize for my English, I’m Italian
Excellent
PS. Please mark the problem as solved so other users experiencing similar are getting an easier time when searching the forum.