rospogrigio / localtuya

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

Ledvance lamps stopped working in HA. How to trace the problem? #1309

Open aritorhamo opened 1 year ago

aritorhamo commented 1 year ago

Hello,

My Ledvance WiFi lamps have totally stopped reacting to Home Assistant controls in any way. I can switch on the "Light" toggle on the Dashboard (without any effect), but not the toggles for each individual lamp. The lamps are "Unavailable". The lamps used to work pretty well until a few weeks ago, but then the situation started to deteriorate, and now they don't work at all. I have tried every toggle and trick I could come up with , but it hasn't helped (I don’t understand much about Home Assistant’s workings, but I did my best). I don't know what the problem could be, because I haven't changed anything (except added some scenes).

The last thing I tried was to reload the device ID and local key for each device with print-local-keys.py to see if they have changed, but they are the same as when I first installed the devices. I also see the same device IDs when I choose “Edit a device” in LocalTuya integration, but if I choose “Add a new device”, I see nothing, although I deleted one of the devices/lamps from HA as an experiment. I assume that getting the IDs and keys out with print-local-keys.py means that Home Assistant should be able to “see” the lamps (there’s nothing wrong with the WiFi connection or anything like that)?

Here’s an error message for one of the lamps from home-assistant.log: 2023-02-28 13:01:39.250 ERROR (MainThread) [custom_components.localtuya.common] [bf4...qq3] Connect to 192.168.100.17 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 187, in _make_connection self._interface = await pytuya.connect( File "/config/custom_components/localtuya/pytuya/__init__.py", line 1163, 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.100.17', 6668)

In addition to similar lines for other lamps, there was this one:

2023-02-28 06:54:35.087 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

Home assistant seems to be trying to connect to the lamps, because it keeps writing that kind of updates to the log file even when I’m not actively doing anything with HA.

Additional information:

My system: PC with Linux Mint 21.1 Linux kernel: 5.15.0-60 Home Assistant version: 2023.1.7 HACS version: 1.30.1 LocalTuya version: 5.0.0 Python version: 3.10.7

I'd greatly appreciate any help and comments.

SteffenM-DE commented 1 year ago

Hi, here too. It seems stop working after HA update 2023.3.0

aritorhamo commented 1 year ago

It seems stop working after HA update 2023.3.0

Hi! I'm sorry to hear that. I was hoping that the new version would fix it to me. Well, in the name of optimism I'll try upgrading anyway. I didn't know that the new version was published, so thanks for bringing that up.

aritorhamo commented 1 year ago

Sorry for closing this accidentally. I tried to take the check mark away from the button "Close with comment"...

Uriziel01 commented 1 year ago

My nightlamp BM02_XB (NiteBird/Gosund) also stopped working after HA update to 2023.3.1 (device was just unavailable all the time), I've tried to remove it and add it once more but I'm unable to add it now because it fails after some time as in the error below

image

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:450
Integration: LocalTuya ([documentation](https://github.com/rospogrigio/localtuya/), [issues](https://github.com/rospogrigio/localtuya/issues))
First occurred: 17:49:29 (4 occurrences)
Last logged: 17:54:20

[075...474] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, 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.10/asyncio/tasks.py", line 456, 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/pytuya/__init__.py", line 857, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 789, in status
    status = await self.exchange(DP_QUERY)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 763, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 450, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
Uriziel01 commented 1 year ago

@rospogrigio Do you think the fix introduced in 5.1.0-beta Fixed devices not reconnecting any more in several cases. is relevant here and it's work a try or this is something different? It's a lamp in my daughter's room so my WAF is dropping fast right now 😄