v1.3.0 — support consumption-only (non-OZE) accounts - #1
Open
lchojnowski wants to merge 8 commits into
Open
lchojnowski wants to merge 8 commits into
lchojnowski wants to merge 8 commits into
Conversation
…OZE accounts
The portal answers HTTP 200 {"Faulted": true} on /oze/* endpoints for
consumption-only accounts — treat that as an API error instead of silently
producing null sensors. Add the two chart endpoints such accounts actually
use (CompareYear / GetDetailsEnergyConsumptionChartData), a parser for the
shared chart JSON shape, a Historia-zuzycia meter-select parser (the only
source of meterId), and a GetMeterReadingsForKU parser.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…unts OZE accounts keep the exact previous flow (billing, OZE aggregates, hourly CSV). Non-OZE accounts skip those endpoints entirely and fetch per-KU CompareYear + Details charts and meter readings instead; the newest Details category is held back from statistics until a newer one closes it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Non-OZE contracts publish consumption_current_period + meter_reading only; discovery topics of the other account type get an empty retained payload so stale entities disappear idempotently. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
test_fetch.py runs the real coordinator against the live portal with a pasted .AspNet.Cookies (no Playwright/MQTT/HA needed) and masks KU/PPE in output. test_parsers.py locks the positional OZE CSV mapping and the new non-OZE parsers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…y in UTC Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Addon zakłada konto prosumenckie (OZE) dla każdego użytkownika:
/api/oze/GetBillingData, dane godzinowe przezOzeReport/GenerateOzeReportz OZE-owymItemId,/oze/*HTTP 200
{"Faulted": true}(aGetOzeDetails→ 404,GenerateOzeReport→ 302), więc addon "działa", ale wszystkie sensory są puste,
OZE nigdy nie będą miały danych.
Co ustaliłem na koncie bez OZE (recon na żywym koncie, 2026-07)
GetPHList→HasOze: false(flaga globalna; nie ma flagi per-KU/PPE).Zamiast tego SPA używa dwóch endpointów nieobecnych w addonie:
GET /mojeon/api/CompareYearEnergyConsumptionChartData?kuId=— rocznesumy zużycia per okres rozliczeniowy (ostatni wpis = bieżący okres,
narastająco),
GET /mojeon/api/GetDetailsEnergyConsumptionChartData?kuId=&meterId=—przyrosty zużycia per odczyt licznika (LegendId = typ odczytu). Serwer
ignoruje parametry dat (stałe okno ~2 lata);
meterIdjest wymaganyi jest dostępny wyłącznie w server-side renderowanym
<select>nastronie Historia-zuzycia (addon i tak ją odwiedza przy keepalive).
GetMeterReadingsForKUdziała i zwraca narastające stany licznika.Zmiany
api.py— guard naFaulted: truew_get()(błąd zamiast cichychnull-i); metody
get_compare_year_data/get_details_chart_data/get_history_page; parsery:parse_chart_rows,parse_history_meters,parse_meter_readings(zFormatedDate, bo epoka/Date(ms)/w UTCcofa datę o dzień).
coordinator.py— dispatch poHasOze: ścieżka OZE bez zmian(billing + agregaty + hourly jak dotąd); ścieżka bez OZE pobiera wykresy
per-KU + stany licznika, buduje wiersze statystyk z zamkniętych okresów
(najnowszy, jeszcze rosnący okres jest wstrzymywany do następnego odczytu).
Przy wielu PPE pod jednym KU dane per-KU idą tylko do pierwszego PPE
(bez duplikacji statystyk).
mqtt_publisher.py— zestawy sensorów per typ konta: bez OZE tylkoconsumption_current_period+ nowymeter_reading; discovery czyściretained topici drugiego zestawu (pusty payload), więc martwe encje
znikają idempotentnie.
stats_importer.py— parametroze_keys; dla kont bez OZEimportowany jest tylko
eon_pl:imported_<PPE>(eksport byłby samymizerami).
oze_keys=Nonezachowuje dotychczasowe zachowanie.web_server.py— tabela ingress pokazuje dla kont bez OZEzużycie okresu + stan licznika zamiast pustych kresek.
test_fetch.py(nowy) — harness całego pipeline'u na wklejonymcookie (bez Playwright/MQTT/HA), maskuje KU/PPE w outputcie.
test_parsers.py(nowy) — testy offline: blokują pozycyjne mapowanieCSV OZE (kolumny 2/4/6) i pokrywają nowe parsery.
Kompatybilność z OZE
Przy
has_oze=Truekażdy call, payload, topic i statistic_id są identycznejak w v1.2.1 — dispatch to wyłącznie domyślne parametry / gałęzie
if.Jedyna różnica: odpowiedź
Faulted: trueloguje warning zamiast cichopublikować null-e. Test
test_parsers.py::test_oze_csv_positional_mappingprzybija dotychczasowy format CSV. Nie mam konta OZE — proszę o jeden
smoke-test fetcha przed merge.
Przetestowane na żywo (konto bez OZE)
HAOS x86_64, HA core 2026.7.2, tryb
manual_cookie_only:HasOze=False, 1 kontrakt, 8 wierszy statystyk,licznika 14529.52 kWh z datą i typem odczytu w atrybutach), zero encji
OZE,
eon_pl:imported_<PPE>: 8 miesięcznych przyrostów zgodnych1:1 z portalem (suma 10297.28 kWh),
eon_pl:exported_<PPE>nieobecny,wznowione z
/data,🤖 Generated with Claude Code