Repeated Errors on Disabled Device

I’m using a Global plug that’s integrated with HA via LocalTuya to control lights on a Christmas tree. With the holiday season over, the device has been unplugged and packed away with the decorations. I’ve also disabled the device in the LocalTuya integration. Despite this, I’m seeing repeated error’s in HA logs advising:

OSError: [Errno 113] Connect call failed (‘192.168.86.104’, 6668)

There error repeats continuously, with updates occurring several times an hour. Why I’m I seeing these error’s when the device has been disabled? I thought disabling the device would stop HA from attempting to connect to the device. FWIW - I did restart HA however the errors continue to flood the log. Is there a way to stop HA from recording errors for this device?

Here’s a copy of the error message from the logs. Note, HA was restarted around 10:00 am today…

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: 10:51:44 AM (200 occurrences)
Last logged: 2:09:42 PM

[280...6a9] Connect to 192.168.86.104 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.86.104', 6668)

Have you disabled the device or its entities? You disable entities through the Settings dialog. You disable the device by clicking on the 3-dots at the bottom right of the integration. I would think this should not happen if the device is disabled rather than entities.

You can also change the logging level for an integration. Something along the lines of:

logger:
  default: error
  logs:
    homeassistant.components.localtuya: critical

I think that would be the right name above, but I have not tested.

It appears I’ve disabled the entity! How does one disable a single device? Using disable from the three-dots at the bottom right of the LocalTuya integration, disables all devices (six). It seems there isn’t a provision to disable a single device.

It looks like I need to either remove the device of change the log to stop the erroneous errors.

Michael suggested using a logger: entry in the configuration file. His suggestion, with a minor tweak, has eliminated localtuya errors I was seeing in the log.

He suggested;

I found the following works for me:

logger:
  default: error
  logs:
    custom_components.localtuya.common: critical

Thank you @michaelblight for the suggestion.

2 Likes