rospogrigio / localtuya

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

Unreachable after setup #681

Open TheRealLink opened 2 years ago

TheRealLink commented 2 years ago

The problem

Device is unreachable after adding it by config flow.

Uses the debug method to verify, but keep getting "Unable to connect"

Tried tuya-cli, works like a charm...

❯ python3 ./test.py >id< 192.168.0.53 >key< 3.3
INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.8.12 (default, Oct 22 2021, 17:47:41)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
INFO:localtuya:Using pytuya version '8.1.0'
INFO:localtuya:TIMEOUT: No response from device >id< [192.168.0.53] after 2 attempts.
❯ tuya-cli get --ip 192.168.0.53 --id >id< --key >key< --full --protocol-version 3.3
{
  devId: '>id<',
  dps: {
    '1': true,
    '2': 'current',
    '3': 28,
    '4': 0,
    '101': 'scene_1',
    '102': 'scene_1'
  }
}

Environment

Steps to reproduce

  1. Add Domus4u light with local key to HA
  2. Device will be recovered, is unavailable and log says TimeOut

Configuration configuration.yaml or config_flow

DP dump

Provide Home Assistant taceback/logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, 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 492, in wait_for
    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 151, in _make_connection
    status = await self._interface.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 472, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 451, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 240, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Additional information

marcipre commented 2 years ago

Same problem with curtains. Worked for more than a year, now they keep switching from available to unavailable. Needless to say that they don't work anymore


Traceback (most recent call last):
File "/config/custom_components/localtuya/common.py", line 141, in _make_connection
self._interface = await pytuya.connect(
File "/config/custom_components/localtuya/pytuya/__init__.py", line 637, 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}')
TimeoutError: [Errno 110] Connect call failed ('xxx.xxx.xxx.xxx', 6668)```
akeslo commented 2 years ago

@marcipre you figure this out?

marcipre commented 2 years ago

@marcipre you figure this out?

yes, it was a router problem. I have an old netgear router modded with openwrt. for some reason, one ethernet port went crazy and started behaving abnormally, blinking as if it was communicating even without a cable connected. I isolate it, and all the network devices started working again. I know that this is a ver particular case, but maybe my experience could help someone else.

akeslo commented 2 years ago

Thanks. I'm assuming mine stopped working due to a firmware update. I had to go back to regular tuya integration :/ I cannot get this working