rospogrigio / localtuya

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

Tuya Devices offline after the update #868

Open Stea73 opened 2 years ago

Stea73 commented 2 years ago

Updated the integration Configured the IOT API account

The problem

the system detects all the devices, but after a while they turn into offline/unavailable

THe message I get when accessing the detailed info is the following: **_This entity is currently unavailable and is an orphan to a removed, changed or dysfunctional integration or device.

If the entity is no longer in use, you can clean it up by removing it._**

If I reload the integration and restart the system, I briefly get them online again (and then they go offline)

Environment

"home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.6.5", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.9.12", "docker": true, "arch": "armv7l", "os_name": "Linux", "os_version": "5.15.32-v7", "supervisor": "2022.05.3", "host_os": "Home Assistant OS 8.2", "docker_version": "20.10.14", "chassis": "embedded", "run_as_root": true

Additional information

File "/config/custom_components/localtuya/pytuya/init.py", line 247, in wait_for await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

THIS HAPPENS ON SEVERAL LOCAL IPs (all Localtuya): 2022-06-15 00:27:10 ERROR (MainThread) [custom_components.localtuya.common] [bfc...xoi] Connect to 192.168.1.164 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 160, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 669, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1065, in create_connection raise exceptions[0] File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 499, in sock_connect return await fut File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 534, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.1.164', 6668)

lishan89uc commented 2 years ago

Do you happen to have an Asus router? For me the same thing happen but everything worked again after I restarted the router. If this works for you please tell me what router you are using afterwards, because this is not only affecting localtuya devices, it is also affecting air print and homekit devices.

Stea73 commented 2 years ago

I don't have an Asus router. However the issue persists after reboot.

erwin commented 2 years ago

ROUTER: UniFi USG SWITCH: Unifi Switch WiFi AP: UAP AC Lite

I was having the exact same issue that Stea73 reported, except mine was limited only to the Tuya Smart Plugs that I have. Other Tuya devices upgraded normally.

I was very deeply skeptical that rebooting a router could fix this problem... I tested connecting to the devices via tuya-cli --set --dps 1 true and sure enough the devices were operating normally, but localtuya just couldn't connect to them.

I restarted home assistant and my router and APs (not the same devices) but that didn't fix it.

Eventually I removed my Tuya Smart Plugs from the HA > Integration > LocalTuya > Devices, restarted the router, restarted the APs, and then used the new config flow to add the Tuya Smart Plugs, and I was able to detect and add the Tuya Smart Plugs and everything is working normally again.

NOTE: When I tried to remove my Smart Plugs in Home Assistant and then add them again BEFORE I restarted the router, they would fail to add and I would see a similar error in the log. It may be possible to simply restart the router and then restart home assistant and be back online - but I just wanted to document exactly what I did and the exact result.

I will miss my localtuya.yaml but this does look like a much better way to go, especially for new users.

 Traceback (most recent call last):
File "/config/custom_components/localtuya/common.py", line 160, 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 1065, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 499, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 534, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.164', 6668)
almighty059 commented 2 years ago

@Stea73 I'm having the same problem.

Stea73 commented 2 years ago

ROUTER: UniFi USG SWITCH: Unifi Switch WiFi AP: UAP AC Lite

I was having the exact same issue that Stea73 reported, except mine was limited only to the Tuya Smart Plugs that I have. Other Tuya devices upgraded normally.

I was very deeply skeptical that rebooting a router could fix this problem... I tested connecting to the devices via tuya-cli --set --dps 1 true and sure enough the devices were operating normally, but localtuya just couldn't connect to them.

I restarted home assistant and my router and APs (not the same devices) but that didn't fix it.

Eventually I removed my Tuya Smart Plugs from the HA > Integration > LocalTuya > Devices, restarted the router, restarted the APs, and then used the new config flow to add the Tuya Smart Plugs, and I was able to detect and add the Tuya Smart Plugs and everything is working normally again.

NOTE: When I tried to remove my Smart Plugs in Home Assistant and then add them again BEFORE I restarted the router, they would fail to add and I would see a similar error in the log. It may be possible to simply restart the router and then restart home assistant and be back online - but I just wanted to document exactly what I did and the exact result.

I will miss my localtuya.yaml but this does look like a much better way to go, especially for new users.

 Traceback (most recent call last):
File "/config/custom_components/localtuya/common.py", line 160, 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 1065, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 499, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 534, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.164', 6668)

Thanks for the info! I'll try with a device or 2 and check what happens!

antonio1475 commented 2 years ago

Same here, devices unavailable minutes after restarting. Since downgrading to 3.5 didn't work, I removed the Cloud API Account (LocalTuya > Configure > Reconfigure Cloud API Account > delete fields > Save. Restart) and no issues since then (hours ago).

I suppose if I already had added the devices manually with the local key, there's no point to have Cloud API Account (especially if it breaks things)?

@erwin so you said that removing the devices & re-adding them solved the issue and no more unavailable?

bax137 commented 2 years ago

I had the same issue with one smart plug (another one, exactly the same and installed at the same time had no issue after the upgrade) and one multi smart plug. They were seen as online on the tuya cloud but unavailable in hass. I tried to restart the integration and hass without effect.

Finally, I resolved the problem with these actions:

mira1218 commented 2 years ago

I have a similar problem, mine is a wall light switch though,

have anyone figure out other ways I could try?

erwin commented 2 years ago

@mira1218 if you originally were using configuration.yaml to configure your localtuya stuff, make sure to comment that out and then restart.

Ideas to try for troubleshooting:

  1. hard power off router/switch/APs (wait for ~10 sec for all capacitors to release charge) and then start back up
  2. remove the problem device(s) from the home assistant configuration
  3. restart home assistant
  4. individually re-add the problem device via the "config flow" wizard

I would also recommend using the tuya-cli command to to make sure you're able to actually connect to your tuya device over the network and toggle it on/off. Perhaps the device needs a factory reset and new secret key...

Something like this (of course replace all the xxx's with your actual values)

# tuya-cli set --id ebxxxxxxxxxxxxxxxxxxxx --key d2xxxxxxxxxxxxxx --ip 192.168.1.xxx --dps 1 --set false --protocol-version 3.3
# tuya-cli set --id ebxxxxxxxxxxxxxxxxxxxx --key d2xxxxxxxxxxxxxx --ip 192.168.1.xxx --dps 1 --set true  --protocol-version 3.3

https://github.com/TuyaAPI/cli

Saentist commented 2 years ago

@erwin there is noting connected to router. If you use some cheap router with not use static leases and expect to get new IP explain how this will help?

image

mira1218 commented 2 years ago

@erwin thank you very much after a hard power off the router and home assistant, things are back to normal!

Stea73 commented 2 years ago

I hard reset the main router and the slave one and the APs, and then turn them on again. I removed the devices (not the entities) Despite localtuya stated that the devices were added, I had to restart HA to have devices/entities available. Unfortunately they are still unavailable.

What did I do wrong?

Saentist commented 2 years ago

I hard reset the main router and the slave one and the APs, and then turn them on again. I removed the devices (not the entities) Despite localtuya stated that the devices were added, I had to restart HA to have devices/entities available. Unfortunately they are still unavailable.

What did I do wrong?

is your error messages same?

Logger: homeassistant
Source: custom_components/localtuya/common.py:117
Integration: LocalTuya integration (documentation, issues)
First occurred: 00:04:29 ч. (74421 occurrences)
Last logged: 10:25:41 ч.

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1026, 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 117, in async_config_entry_by_device_id
    if device_id in entry.data[CONF_DEVICES]:
KeyError: 'devices'

and this one

Logger: aiohttp.server
Source: custom_components/localtuya/config_flow.py:460
Integration: LocalTuya integration (documentation, issues)
First occurred: 01:22:04 ч. (1 occurrences)
Last logged: 01:22:04 ч.

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 220, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 266, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 260, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 335, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 368, in async_step_init
    return await self.async_step_add_device()
  File "/config/custom_components/localtuya/config_flow.py", line 457, in async_step_add_device
    devices = {
  File "/config/custom_components/localtuya/config_flow.py", line 460, in <dictcomp>
    if dev["gwId"] not in self.config_entry.data[CONF_DEVICES]
KeyError: 'devices'

And this one

Logger: homeassistant.config_entries
Source: custom_components/localtuya/__init__.py:278
Integration: LocalTuya integration (documentation, issues)
First occurred: 00:04:30 ч. (1 occurrences)
Last logged: 00:04:30 ч.

Error setting up entry localtuya for localtuya
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 339, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/localtuya/__init__.py", line 278, in async_setup_entry
    for dev_id in entry.data[CONF_DEVICES]:
KeyError: 'devices'

My guess is the migration block something in exiting entity's also search not working after migration, but work on clear installed OS (I test on fresh OVA image latest version of all)

Q. Where is stored device configuration of Localtuya?

Saentist commented 2 years ago

For people with believe problem is in router

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:669
Integration: LocalTuya integration (documentation, issues)
First occurred: 18 юни 2022 г., 22:08:11 ч. (4 occurrences)
Last logged: 18 юни 2022 г., 22:10:53 ч.

[bff...bfn] Connect to 192.168.1.182 failed
[bf9...o2o] Connect to 192.168.1.184 failed
[bf9...o2o] Connect to 192.168.1.84 failed
[bff...bfn] Connect to 192.168.1.82 failed
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 160, 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 1065, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 499, in sock_connect
    return await fut
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 534, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.182', 6668)

Error from working integration, but on router changed dhcp leases ip's Error demonstrate that localtuya expecting ip, and not compare it to local ARP table of MAC addresses.

Stea73 commented 2 years ago

yes, the error is

2022-06-19 15:15:19 ERROR (MainThread) [custom_components.localtuya.common] [635...5dc] Connect to 192.168.1.165 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 160, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 669, in connect , protocol = await loop.create_connection( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1065, in create_connection raise exceptions[0] File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 499, in sock_connect return await fut File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 534, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.1.165', 6668)

Not sure I understand the solution

lishan89uc commented 2 years ago

Apology: I am sorry everyone, I think I am the one who brought about the whole router confusion let me explain myself more carefully.

This is my current router setup:

Asus Ai-Mesh as follows:

RP-AC1900---RT-AX89X---GT-AC5300---Home Assistant
               |
             Modem

Background: These are all asus routers with aimesh and a ethernet backhaul.Currently whatever wifi device I connect to the RT-AX89X will randomly stop working. So it has been setup so that all the iot device will connect through either RP-AC1900 or GT-AC5300.

Anecdote: After the update, everything else except 6/10 local tuya devices was working correctly. I checked with the tuya app that the devices are indeed connected and controllable through the app. It was then that some of my wemo device went offline. After some troubleshooting, and because of past experience, I decided to restart the router. In this past this fixed my wemo switches, except this time it fixed everything tuya included.

Troubleshooting: In case you are interested in my unscientific troubleshooting, while the switches showed as unavailable on home assistant, I did a dp dump using tuyadebug and did get a valid response. Since my a few wemo switches also went offline, I also check to see if they were reachable at http://192.168.X.XXX:49153/setup.xml and also got a response. Also in response to

Error from working integration, but on router changed dhcp leases ip's

In my setup at least the dhcp leases are reserved and I checked the list of devices on the router and the ip of the tuya switches were unchanged.

Conclusion: I am not going to pretend I remotely understand why this is happening. However whether it is by coincidence or if it is related, whenever the devices go offline my brother printer would be unable to airprint until I force it to join another ai-mesh node then switch it back to the GT-AC5300. So my conclusion is that the RT-AX89X for some reason just does not play nice with iot device or apple devices.

fokcuk commented 2 years ago

Similar issues as of late. Local tuya devices go to Unavailable. If I reconfigure > edit device > keep everything as is and save - it starts working again. Until it stops

Stea73 commented 2 years ago

What I did was to delete the integration all together and reinstall it. So far I only tried with one device (cover). So far so good (several hours). If it works tomorrow I'll add back all the devices...

Saentist commented 2 years ago

Whatever it is problem its conected to python3.9/asyncio as result discovery and comunication to devices not work

image

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Stea73 commented 2 years ago

I confirm that deleting the integration and adding it back solves the problem (although it might be painful to add back all the devices).

That said, I have a question, if I want to add an entity (after the first creation batch), how do I do? If I select to edit a device, it will only allow me to edit any entity I already created. Should I remove the device/entities and redo it from scratch?

SirOrcrist commented 2 years ago

Yeah It's the only thing that worked for me. I tried different settings etc.. and deleting every time I got one entity right and when I have them all in place... well I have them all in place, next device. But at least you can edit everything when finished if you need too. I was kind of lucky with the upgrade to 4.0.0, had only come around installing one device in previous version. I read the readme file and the part about no yaml and "migrating should work" or something...made me think, nahh I'm doing a fresh install. So haven't had any problems exept from above and that sometimes I need to restart when I have done changes or installed some new devices.

Saentist commented 2 years ago

Where HA store configuration of Localtuya? there must be some migration problem 3.5>4.0

julianjwong commented 2 years ago

Oh man I was about to post that I'm having the same problem... BUT there's a glimmer of hope it might sort itself out? Did a major network overhaul today (well not so major, swapped out my router with a new one but it does all my DHCP. Have a cheap Tenda mesh wifi connecting all my IOT devices). Was super flakey initially but settled down. Devices started dropping off the network completely and would need a power cycle (Smartlife app showed offline). Also Localtuya was showing devices unavailable. I restarted HA and also had the same problem still despite Smartlife showing them online. Reconfigured the Cloud API settings but left all the values exactly the same and saved. After a little while devices seemed to come back online. Fingers crossed it remains ok.

julianjwong commented 2 years ago

So still noticed some flakiness last night and this morning. Some lights (random) not coming online until full restart of HA and others will go offline and come back online.

Two main error logs:

This error originated from a custom integration.

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:247
Integration: LocalTuya (documentation, issues)
First occurred: 7:43:21 AM (158 occurrences)
Last logged: 8:10:22 AM

[358...f23] Connect to 192.168.0.194 failed
[bf7...twa] Connect to 192.168.0.215 failed
[358...c22] Connect to 192.168.0.221 failed
[bf8...pfa] Connect to 192.168.0.47 failed
[bf1...3pe] Connect to 192.168.0.243 failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/locks.py", line 417, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 170, in _make_connection
    status = await self._interface.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 481, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 460, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 247, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

And

This error originated from a custom integration.

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:669
Integration: LocalTuya (documentation, issues)
First occurred: 7:43:12 AM (70 occurrences)
Last logged: 8:09:58 AM

[bfb...t8v] Connect to 192.168.0.5 failed
[358...985] Connect to 192.168.0.101 failed
[bf7...fso] Connect to 192.168.0.177 failed
[418...cb6] Connect to 192.168.0.165 failed
[358...c22] Connect to 192.168.0.221 failed
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 160, 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 1065, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 499, in sock_connect
    return await fut
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 534, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionResetError: [Errno 104] Connect call failed ('192.168.0.170', 6668)
Saentist commented 2 years ago

Where HA store configuration of Localtuya?

/config/.storage
core.config_entries
core.device_registry
core.entity_registry

Is there anything else located?

this is very unsorted files JSON format

Saentist commented 2 years ago

Is anyone with programing skills on python can confirm is this same problem https://github.com/python/cpython/issues/90274 https://stackoverflow.com/questions/35551624/how-can-i-close-a-datagramtransport-as-soon-one-datagram-is-sent

I start to think that HA have hidden firewall with block something.

Stea73 commented 2 years ago

Inremoced the integration and reinstall it from scratch nd works like a charm.

Saentist commented 2 years ago

Inremoced the integration and reinstall it from scratch nd works like a charm.

if you have 5 devices ok but with 10 times more ... not so. its better to be found where is problem not to found alternative way to skip it.

Stea73 commented 2 years ago

Yeah that's a bit painful i have 20+. If you setup the api server it,'s less painful

lishan89uc commented 2 years ago

This is why I think it is stupid for them to move away from config.yaml. It makes things 100x harder for non-novice users, at the risk of sounding elitist. But! the new add process is pretty awesome and simple so I guess that makes up for it.

Stea73 commented 2 years ago

What i don't like is that once you added a device there is no way to add entities after the first time. Or at least I couldn't find how to do it

Saentist commented 2 years ago

What i don't like is that once you added a device there is no way to add entities after the first time. Or at least I couldn't find how to do it

Me also.

Selecting "switch" and he ask for voltage's??? All devices are now sensors??? Before was device with sensor's. Cloud API just GET device name as in Tuya app and local key, but not take anything else

Wizard need to be completely rewritten ex:

Power Plug
{
    '1': True,  -- outlet output status (true/false) (button)
    '9': 0,
    '17': 1,
    '18': 736,  -- mA - current (sensor)
    '19': 1123, -- W  - consumption (sensor)
    '20': 2250, -- V  - voltage (sensor)
    '21': 1,
    '22': 630,
    '23': 27621,
    '24': 16292,
    '25': 2560,
    '26': 0,
    '38': 'memory', -- relay_status /on, off, memory(last state)/ 
    '41': '',
    '42': '',
    '46': True  -- overcharge protection (true/false) 

Wizard need to ask Q. what device type you have A. (drop-down) powerplug Q. I found this DPS can you define what is what (plus suggestion) A, multiline table each line DPS: enabled check box, number from detection, value from detection, dropdown menu type, unit of measurement, visual representation of result with Back Cancel Finish buttons.

manually can be edited in

/config/.storage
core.config_entries
core.device_registry
core.entity_registry
gianlucaf81 commented 2 years ago

I removed the Cloud API Account (LocalTuya > Configure > Reconfigure Cloud API Account > delete fields > Save. Restart) and no issues since then (hours ago).

This worked for me. Thanks

paulomar commented 1 year ago

I removed the Cloud API Account (LocalTuya > Configure > Reconfigure Cloud API Account > delete fields > Save. Restart) and no issues since then (hours ago).

This worked for me. Thanks

Hi 'gianlucaf81', first thanks for attempting to help solve this issue. Can you explain why this would help in the resolution of the issue, as this would just avoid the integration to contact cloud API to discover more devices (ID, Key, etc). All devices you already have would stay unchanged, what was not working, I believe will continue not working (at least for me) Can you please explain what you are trying to achieve with this change?

By the way, when you mentioned to press "Save", on your steps, I believe it should be "Submit", and when you probably need to mark the checkbox "Do not configure Cloud API account".

paulomar commented 1 year ago

Where HA store configuration of Localtuya?

/config/.storage
core.config_entries
core.device_registry
core.entity_registry

Is there anything else located?

this is very unsorted files JSON format

Hope it helps other users, I use the HomeAssistant on a Virttual Machine, so it is hosted (not containerized), in this version to access these files, the only way I found is to open the "Terminal" (you need to have this add-on installed). See more here: https://community.home-assistant.io/t/home-assistant-community-add-on-ssh-web-terminal/33820)

Stea73 commented 1 year ago

Fyi. I still get the issue from time to time. I found this workaround to get the devices available again:

It normally gets everything back online

Saentist commented 1 year ago

Fyi. I still get the issue from time to time. I found this workaround to get the devices available again:

  • disable the integration
  • restart HA
  • enable the integration
  • restart HA

It normally gets everything back online

More simple to reload integration.

Stea73 commented 1 year ago

Don't ask me why, but it doesn't work, after a short time, devices go offline again

kellcomnet2 commented 1 year ago

Same issue as others, rolling back and my devices stay online.

`Logger: custom_components.localtuya.common Source: custom_components/localtuya/pytuya/init.py:588 Integration: LocalTuya (documentation, issues) First occurred: October 29, 2022 at 7:44:27 PM (1 occurrences) Last logged: October 29, 2022 at 7:44:27 PM

[eb8...dzq] Connect to 192.168.1.136 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 170, in _make_connection status = await self._interface.status() File "/config/custom_components/localtuya/pytuya/init.py", line 481, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 466, in exchange payload = self._decode_payload(msg.payload) File "/config/custom_components/localtuya/pytuya/init.py", line 588, in _decode_payload return json.loads(payload) File "/usr/local/lib/python3.10/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`

Logger: custom_components.localtuya.common Source: custom_components/localtuya/pytuya/init.py:588 Integration: LocalTuya (documentation, issues) First occurred: October 29, 2022 at 7:44:27 PM (1 occurrences) Last logged: October 29, 2022 at 7:44:27 PM

[eb8...dzq] Connect to 192.168.1.136 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 170, in _make_connection status = await self._interface.status() File "/config/custom_components/localtuya/pytuya/init.py", line 481, in status status = await self.exchange(STATUS) File "/config/custom_components/localtuya/pytuya/init.py", line 466, in exchange payload = self._decode_payload(msg.payload) File "/config/custom_components/localtuya/pytuya/init.py", line 588, in _decode_payload return json.loads(payload) File "/usr/local/lib/python3.10/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)