PiotrMachowski / Home-Assistant-custom-components-Tauron-AMIplus

This sensor uses unofficial API to get energy usage and generation data from https://elicznik.tauron-dystrybucja.pl.
MIT License
128 stars 34 forks source link

Error: in get_values_daily m2 = re.match(r".*\"}'>(.*)</option>", match.group()) #147

Closed mmg1t closed 1 year ago

mmg1t commented 1 year ago

Cześć, W kwietniu zdechła integracja z eLicznikiem bo były prowadzone prace - tauron_amiplus rownież padł. poprawione w: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Tauron-AMIplus/issues/122 ? ... niestety albo ja coś robię bardoz źle, albo wyglada na to że mam jakieś jeszcze inne błędy w integracji.

Wykonałem upgrade 2.4.7 => 2.5.0 i niestety nie wstaje. Info w HA logu jak poniżej.

Byc może istotne:

`2023-05-15 23:30:42.246 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.tauron_amiplus`
`2023-05-15 23:30:46.526 ERROR (MainThread) [custom_components.tauron_amiplus.coordinator] Unexpected error fetching tauron_amiplus data: 'allData'`
`Traceback (most recent call last):`
`  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh`
`    self.data = await self._async_update_data()`
`  File "/config/custom_components/tauron_amiplus/coordinator.py", line 29, in _async_update_data`
`    self.store_statistics = store_statistics`
`  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run`
`    result = self.fn(*self.args, **self.kwargs)`
`  File "/config/custom_components/tauron_amiplus/coordinator.py", line 40, in _update`
`  File "/config/custom_components/tauron_amiplus/connector.py", line 103, in get_raw_data`
`    self.show_12_months = show_12_months`
`  File "/config/custom_components/tauron_amiplus/connector.py", line 115, in get_data_set`
`    data.consumption, consumption_max_cache = self.get_data_set(generation=False)`
`  File "/config/custom_components/tauron_amiplus/connector.py", line 193, in get_values_daily`
`    m2 = re.match(r".*\"}'>(.*)</option>", match.group())`
`KeyError: 'allData'`
`2023-05-15 23:31:00.762 ERROR (MainThread) [custom_components.tauron_amiplus.coordinator] Unexpected error fetching tauron_amiplus data: 'allData'`
`Traceback (most recent call last):`
`  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh`
`    self.data = await self._async_update_data()`
`  File "/config/custom_components/tauron_amiplus/coordinator.py", line 29, in _async_update_data`
`    self.store_statistics = store_statistics`
`  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run`
`    result = self.fn(*self.args, **self.kwargs)`
`  File "/config/custom_components/tauron_amiplus/coordinator.py", line 40, in _update`
`  File "/config/custom_components/tauron_amiplus/connector.py", line 103, in get_raw_data`
`    self.show_12_months = show_12_months`
`  File "/config/custom_components/tauron_amiplus/connector.py", line 115, in get_data_set`
`    data.consumption, consumption_max_cache = self.get_data_set(generation=False)`
`  File "/config/custom_components/tauron_amiplus/connector.py", line 193, in get_values_daily`
`    m2 = re.match(r".*\"}'>(.*)</option>", match.group())`
`KeyError: 'allData'`

Pozdrawiam

PiotrMachowski commented 1 year ago

Masz zainstalowane przez HACS?

mmg1t commented 1 year ago

nie, ręcznie, nie mam HACS wogole poki co, staram sie "panować nad tym co tam sie dzieje"..może zbyt ostrożnie... poki co wrzucone do custom_components/tauron_amiplus/

PiotrMachowski commented 1 year ago

Wygląda jakby coś było źle pobrane. Usuń wszystko z custom_components/tauron_amiplus i zainstaluj od nowa.

Wydaje mi się, że przez HACS się lepiej panuje jednak :)

mmg1t commented 1 year ago

w trybie debug w logu pisze jeszcze o 16stu takich elementach

2023-05-16 00:05:55.349 ERROR (MainThread) [homeassistant.components.sensor] P...........`

` Platform tauron_amiplus does not generate unique IDs. ID tauron-xxxxxxxxxxxxxxxxxx-consumption_reading already exists - ignoring sensor.tauron_amiplus_xxxxxxxxxxxxxxxxxx_current_consumption_reading`
` Platform tauron_amiplus does not generate unique IDs. ID tauron-xxxxxxxxxxxxxxxxxx-consumption_daily already exists - ignoring sensor.tauron_amiplus_xxxxxxxxxxxxxxxxxx_daily_energy_consumption`
` Platform tauron_amiplus does not generate unique IDs. ID tauron-xxxxxxxxxxxxxxxxxx-consumption_monthly already exists - ignoring sensor.tauron_amiplus_xxxxxxxxxxxxxxxxxx_monthly_energy_consumption`
` Platform tauron_amiplus does not generate unique IDs. ID tauron-xxxxxxxxxxxxxxxxxx-consumption_yearly already exists - ignoring sensor.tauron_amiplus_xxxxxxxxxxxxxxxxxx_yearly_energy_consumption`
`(...)`

PS. masz jakis patent na ładne wklejanie i formatowanie logów ? (by nie pisac backtików przy każdej linijce na początku i koncu)

PiotrMachowski commented 1 year ago

Chyba 2x skonfigurowałeś ten sam licznik.

Kod trzeba otoczyć trzema backtikami, zobacz, jak przedytowałem Twoje wpisy

mmg1t commented 1 year ago

aaa.. czyli trzy backtiki przed i trzy po :) cool 👍

pliki wgrane raczej poprawnie ... sciagnalem na boku od zera ... md5 plików się zgadza ...

homeassistant/config $ (git:master) find custom_components/tauron_amiplus/ -type f  -exec md5sum '{}' \;
7ff5e330a2146f52d9e2b62ef8304051  custom_components/tauron_amiplus/statistics.py
88299018fa4e6ea152ef8a5b42769d65  custom_components/tauron_amiplus/translations/pl.json
7fbcb6b61290ac559854c01ee224ecf3  custom_components/tauron_amiplus/translations/en.json
dc0e13b9bafa6ec046ab1bf5067d68dd  custom_components/tauron_amiplus/coordinator.py
f510fe438cb155ad181feb68969bce7b  custom_components/tauron_amiplus/services.yaml
8622d4c924e7b2d955bcd35e1d8602cb  custom_components/tauron_amiplus/sensor.py
26cc35d3925fca63176c413ef9baf181  custom_components/tauron_amiplus/__init__.py
365c5742244a8a9561f40431370bbd7c  custom_components/tauron_amiplus/strings.json
1b5f5bf3d6ccd8f01e3d454dd43b456e  custom_components/tauron_amiplus/connector.py
3e56c50194561d499952aabc9b1d76e3  custom_components/tauron_amiplus/manifest.json
51ae42ec659212a9894229b412df98b7  custom_components/tauron_amiplus/config_flow.py
8d0eacb68b23480d84a00a4d299de72d  custom_components/tauron_amiplus/diagnostics.py
4f4f1b96ae168da3339dea77cf535718  custom_components/tauron_amiplus/const.py
2df628e79b4e29c48bac8e11dda89565  custom_components/tauron_amiplus/services.py

Chyba 2x skonfigurowałeś ten sam licznik.

hmm... nie zmienialem nic w konfiguracji od ostatniego razu .. tylko nadpisalem pliki dodatku , wyłączyłem/włączyłem, kliknałem w "Konfiguruj" przycisk "Zatwierdz"(szukajac rozwiazania samemu)

w Ustawienia -> Urządzenia oraz usługi -> Integracje .... widnieje tylko 1 raz Twój dodatek

mmg1t commented 1 year ago
  • 63ed5ce - E (9 days ago) Merge pull request #138 from PiotrMachowski/dev - Piotr Machowski (HEAD, tag: v2.4.13)

to samo :|

mmg1t commented 1 year ago

jeszcze jeden restart ... i jakby cos sie zmienilo ... nie ma błędów...zamyślił się:

2023-05-16 01:07:33.017 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform tauron_amiplus is taking over 10 seconds.
2023-05-16 01:08:18.609 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: sensor.tauron_amiplus
2023-05-16 01:08:23.018 ERROR (MainThread) [homeassistant.components.sensor] Setup of platform tauron_amiplus is taking longer than 60 seconds. Startup will proceed without waiting any longer.

...i cisza...

PiotrMachowski commented 1 year ago

a widzisz. To teraz już wszystko jest dobrze. Jak włączysz debug (przez UI), to zobaczysz, że pobiera dużo danych. Może to potrwać chwilę (z 5min max raczej)

mmg1t commented 1 year ago

co sie zmienilo:

PS. w debugu widze zasysa jakies potężne JSONy :)

PiotrMachowski commented 1 year ago

Ok, czyli wcześniej nie zrobiłeś restartu HA? To by wyjaśniało czemu logi nie miały sensu. Żeby zaktualizować integrację trzeba zrobić restart

w debugu widze zasysa jakies potężne JSONy :)

Tak, integracja pobiera dane dla każdego dnia osobno, co niestety trochę trwa

mmg1t commented 1 year ago

Aha 👍 :) Widzę że pojawiła się jakaś dodatkowa opcja: "Obliczanie bilansowania godzinowego dla aktualnego roku" :-)

...zdaje się że się coś przywiesiło ... "show full processlist" pod mysqlem nie pokazuje żadnych aktywnych zapytań...wykresów w "Energia" tez nie zaaktualizowało póki co ...

PiotrMachowski commented 1 year ago

Dane najpierw pobierane są do pamięci, potem dopiero lecą do bazy. Jeśli wszedłeś w konfigurację i kliknąłeś "zatwierdź", to cały proces zaczął się od nowa

mmg1t commented 1 year ago

yeaah :) zaczytał wszystko :) Wyglada że nie był to bug, tylko mój błąd.

Dzięki za pomoc!!

PS. nie kliknałem zatwierdź ... jeszcze PS.2 Kawusia juz jedzie;-)

mmg1t commented 1 year ago

User error

PiotrMachowski commented 1 year ago

Cieszę się, że działa ;) swoją drogą, to 3h temu wrzuciłem wersję 2.5.1, jeśli masz aktualnie 2.5.0, to możesz ściągnąć nowszą wersję i kiedyś zrobić restart :)

mmg1t commented 1 year ago

2.5.1 wydaje się że działa :) tj nie ma błędów w logach, nastepne wykresy sie zaczytają pewnie dopiero jutro

PiotrMachowski commented 1 year ago

Tak, wykresy za dzisiaj (poniedziałek) będą najprawdopodobniej dostępne dopiero po południu