Skip to content

Non UTF-8 characters in byte data #472

@Kane610

Description

@Kane610

home-assistant/core#116223 (comment)

I had a similar issue when upgrading my HA instance from 2024.1.5 to 2024.7.2 yesterday and was about to open a PR when I saw this one that looks similar.

It is probably because you are using non UTF-8 characters in your PTZ label(s) for that camera like I do, e.g. "entrée" (vs "entree"), see in your log file

File "/usr/local/lib/python3.12/site-packages/axis/interfaces/parameters/param_cgi.py", line 39, in _api_request
return params_to_dict(bytes_data.decode()).get("root") or {}
^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 1357: invalid continuation byte
I guess that if you modify L39 of interfaces/parameters/param_cgi.py in the axis library from

    return params_to_dict(bytes_data.decode().get("root") or {}

to

    return params_to_dict(bytes_data.decode(encoding='latin-1')).get("root") or {}

it will work again. Alternative is to rename/only use UTF-8 characters for PTZ labels

Not sure why/when this changed between these two versions but somehow HA locales should be taken into account ('latin-1' is only a workaround that will work for western EU)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions