rospogrigio / localtuya

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

Unreachable devices cause uncaught exception to be logged once per minute #960

Open pickerin opened 2 years ago

pickerin commented 2 years ago

The problem

Devices that are not reachable (unplugged, offline, network issue) force an uncaught exception. This exception is then logged once per device PER MINUTE, forever.

Environment

Steps to reproduce

  1. Configure normally
  2. Take a device offline (unplug it)
  3. Wait for logs to appear (may require a restart of HA)

Configuration configuration.yaml or config_flow

Configured via new Cloud API available in 4.0.0

DP dump

N/A

Provide Home Assistant traceback/logs

2022-07-17 13:37:35 ERROR (MainThread) [custom_components.localtuya.common] [740...e67] Connect to X.X.X.X 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.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 ('X.X.X.X', 6668)

Additional information

N/A

renoirb commented 2 years ago

I experienced this one. I'll add info