rospogrigio / localtuya

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

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 1: invalid start byte #1576

Open StefanoGiu opened 10 months ago

StefanoGiu commented 10 months ago

The problem

Log full of errors...

Environment

Steps to reproduce

error is continuous in log

Provide Home Assistant traceback/logs

Traceback (most recent call last):
  File "\.homeassistant\custom_components\localtuya\discovery.py", line 65, in datagram_received
    data = decrypt_udp(data)
           ^^^^^^^^^^^^^^^^^
  File "\.homeassistant\custom_components\localtuya\discovery.py", line 30, in decrypt_udp
    return _unpad(decryptor.update(message) + decryptor.finalize()).decode()
                                              ^^^^^^^^^^^^^^^^^^^^
  File "\Python\Python311\Lib\site-packages\cryptography\hazmat\primitives\ciphers\base.py", line 186, in finalize
    data = self._ctx.finalize()
           ^^^^^^^^^^^^^^^^^^^^
  File "\Python\Python311\Lib\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 "\Python\Python311\Lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "\Python\Python311\Lib\asyncio\proactor_events.py", line 607, in _loop_reading
    self._protocol.datagram_received(data, addr)
  File "\.homeassistant\custom_components\localtuya\discovery.py", line 67, in datagram_received
    data = data.decode()
           ^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 1: invalid start byte
StefanoGiu commented 10 months ago

Is this component mantained or deprecated? How comes there are so many errors in the log?

raptyk commented 1 day ago

Same here:

Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
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()
                                              ^^^^^^^^^^^^^^^^^^^^
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.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1238, 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 0x9a in position 0: invalid start byte