rospogrigio / localtuya

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

Disabled Devices reported as Connect Failed #1286

Open markus99 opened 1 year ago

markus99 commented 1 year ago

I have DISABLED both the DEVICE and the ENTITY in HA - seems like disabled device/entities should be ignored from the integration / logs. I have temporarily removed them from my home network - so they are technically offline as well.

Would suggest skipping/ignoring any DISABLED devices - keeps retrying the connection and failing - even though I have disabled them.

This error originated from a custom integration.

Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/__init__.py:1163
Integration: LocalTuya (documentation, issues)
First occurred: 8:59:56 AM (76 occurrences)
Last logged: 9:21:26 AM

[ebd...kfm] Connect to 192.168.##.136 failed
[ebd...hmm] Connect to 192.168.##.138 failed
[eb6...naw] Connect to 192.168.##.139 failed
[eb7...gig] Connect to 192.168.##.137 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.##.136', 6668)

The problem

Devices / Entities that have been DISABLED in HA are still trying to be connected to - and are failing. Creates unnecessary network traffic and log reports.

Prefer not to remove them entirely - as I might re-add in the future and getting the keys / setting the device back up is cumbersome.

Environment

Steps to reproduce

  1. Add device(s) to LocalTuya
  2. Disable Device / Entity in HA
  3. See log errors about connection

DP dump

Provide Home Assistant traceback/logs

put your log output between these markers

Additional information

BlueTalon6 commented 1 year ago

I have 21k+ logged errors from a device in the same situation. Would prefer not to remove, but doesn't looks like I have much of a choice.

ryanpeters-MSFT commented 10 months ago

Is there any update to this? I've disabled both the device and the entity, but I keep getting "Failed to connect" logs for the IP of my device. Thanks!

wosym commented 6 months ago

Any word from the developers? Wondering if this is something considered a bug, or working as intended.

In any case, it's pretty annoying. It also worries me that it will reduce the lifetime of my SSD, by spamming these logs all the time. (It would even be several magnitudes worse for people running HA on an SD-card)