localtuya icon indicating copy to clipboard operation
localtuya copied to clipboard

Exception in callback _SelectorDatagramTransport._read_ready()

Open BettySwallocks opened this issue 1 year ago • 15 comments

My logs are getting filled with errors (every few seconds) like this:

2023-12-15 15:07:45.646 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready()
Traceback (most recent call last):
File "/config/custom_components/localtuya/discovery.py", line 65, in datagram_received
data = decrypt_udp(data)
^^^^^^^^^^^^^^^^^
File "/config/custom_components/localtuya/discovery.py", line 30, in decrypt_udp
return _unpad(decryptor.update(message) + decryptor.finalize()).decode()
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 186, in finalize
data = self._ctx.finalize()
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 222, in finalize
raise ValueError(
ValueError: The length of the provided data is not a multiple of the block length.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1163, in _read_ready
self._protocol.datagram_received(data, addr)
File "/config/custom_components/localtuya/discovery.py", line 67, in datagram_received
data = data.decode()
^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 4: invalid continuation byte

Any ideas folks?

BettySwallocks avatar Dec 16 '23 18:12 BettySwallocks