Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with integration after HA update to 2024.11.3 . Integration is stop working #1856

Open
MarekOleksik opened this issue Nov 27, 2024 · 1 comment

Comments

@MarekOleksik
Copy link

Ten błąd pochodzi z niestandardowej integracji.

Rejestrator: homeassistant
Źródło: custom_components/localtuya/discovery.py:67
integracja: LocalTuya integration (dokumentacja, Problemy)
Pierwsze zdarzenie: 14:43:34 (11310 zdarzenia)
Ostatnio zalogowany: 22:37:13

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 0xcb in position 0: invalid continuation byte

@crwilcox
Copy link

crwilcox commented Nov 28, 2024

I initially suspected my issue on upgrade was related to this, but it turned out the issues was about entities and format. I was able to get going again by 'editing' each entity and submitting. I didn't change any settings, but it seems resubmitting in localtuya config got things moving.

2024-11-28 10:34:30.135 ERROR (MainThread) [homeassistant.components.climate] Error adding entity None for domain climate with platform localtuya
Traceback (most recent call last):
...
KeyError: 'min_temperature_const'

The above said, I did dig into this issue a bit, and had patched locally before reverting my change as my debug logs didn't have this error. If you locally change to use latin-1 (aka 'latin-1', 'iso_8859_1' and '8859') it may get you past the failure and into seeing the content. I can't be sure this works, but you could at least change line 67 and get the data when the exception occurs and maybe see what's going wrong.

Latin-1 is a simple encoding and will at least avoid the continuation error. https://docs.python.org/3/library/codecs.html#encodings-and-unicode

Line 30:

    return _unpad(decryptor.update(message) + decryptor.finalize()).decode("latin-1")

Line 67:

            data = data.decode('latin-1')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants