DarkC35 / ha_linznetz

Custom component to import LINZ NETZ quater-hour reports into Home-Assistant.
MIT License
13 stars 0 forks source link

Fehler: 'utf-8' codec can't decode byte 0xab in position 1: invalid start byte #18

Open irmscher123 opened 3 weeks ago

irmscher123 commented 3 weeks ago

Since Update

there is an issue:

Logger: homeassistant.helpers.script.websocket_api_script Quelle: helpers/script.py:525 Erstmals aufgetreten: 18:26:10 (9 Vorkommnisse) Zuletzt protokolliert: 18:36:25

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'utf-8' codec can't decode byte 0xab in position 1: invalid start byte Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/linznetz/sensor.py", line 173, in import_report csv_data = get_csv_data_list_from_file(path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/linznetz/sensor.py", line 99, in get_csv_data_list_from_file csv_data = list(report_dict_reader) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/csv.py", line 115, in next self.fieldnames File "/usr/local/lib/python3.12/csv.py", line 102, in fieldnames self._fieldnames = next(self.reader) ^^^^^^^^^^^^^^^^^ File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xab in position 1: invalid start byte

maybe action and service issue ??

maybe you can help

DarkC35 commented 3 weeks ago

Cannot reproduce this error on a dev instance with version 2024.8.2 running and my own instace with 2024.5.3 is also working as usual (although the August version produces a new warning I should check sometime). Not sure which version you are using since you did not provide this information.

The error message on the bottom reads like there are some funny characters in your file (or maybe filename?) or something got messed up with the file format at some point. How did you create the file you try to import (via mail, experot from website, manually created it and inserted the date?). The files on my end all use UTF-8 encoding and LF line endings and are still structured like these ones (keep in mind that the header line is important as well): https://github.com/DarkC35/ha_linznetz/blob/master/tests/data/2022-09-18.csv

irmscher123 commented 3 weeks ago

hi! after restarting the homeassistant server it works 50%!

the main problem is the 7ps encryption

if the mail arrives from vdi@linznetz.at at (google) postbox - he only sends the smime.p7s - file to the homeassistant server.

solution - i resend it to my postbox manually and homeassistant imports the csv correctly.

thanks