rospogrigio / localtuya

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

Offline devices reported as error instead of warning #1233

Closed MickPBduece closed 5 months ago

MickPBduece commented 1 year ago

The problem

Devices that are off line are reported as an error. Creating a lot of posts to the ERROR log. There are valid use cases for devices that are off line and they should be reported as a warning or allow them to be configured as non-essential.-->

Environment

Pi / HASS / A variety of Tuya devices including some defined behind a non Tuya switch that is required

Steps to reproduce

  1. Remove power or unplug a device connected to locatuy
  2. Observe log.

DP dump

Logger: custom_components.localtuya.common Source: custom_components/localtuya/pytuya/init.py:704 Integration: LocalTuya (documentation, issues) First occurred: January 7, 2023 at 12:27:51 PM (24241 occurrences) Last logged: 1:21:46 PM

[eb5...quz] Connect to 192.168.1.170 failed [eb3...6yp] Connect to 192.168.1.169 failed [eb6...ufo] Connect to 192.168.1.220 failed [561...5a0] Connect to 192.168.1.20 failed [826...ddd] Connect to 192.168.1.14 failed Traceback (most recent call last): File "/config/custom_components/localtuya/common.py", line 186, in _make_connection self._interface = await pytuya.connect( File "/config/customcomponents/localtuya/pytuya/init.py", line 704, 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}')



## Additional information
<Having the ability to run an automation when a device becomes active indicates that having a device inactive is no an error. A warning would be more appropriate>
HelmutH1963 commented 1 year ago

I have the same problem.

markus99 commented 1 year ago

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

Would suggest skipping/ignoring any DISABLED devices - 532 occurrences of this error, for an intentionally disabled device, in a little over 2 hours is too many.

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: 9:57:32 AM (532 occurrences)
Last logged: 12:13:10 PM

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

Just upgraded to 2023.1.4, but have been seeing this previously as well.

escobarin3 commented 1 year ago

Same here.

donburch888 commented 1 year ago

Still happening in HA 2023.3

MickPBduece commented 5 months ago

Removed the the Tuya device that was wired behind a switch. No longer an issue for me