Repository navigation
Read heat produced from the web metering page - #9
Merged
Merged
Conversation
The API token gives only the electricity a heat pump used. The heat it produced is only on the web app's metering page, so the API can now log in to the web app (cookie session) and read PlantMetering/GetData. GALEVO devices with hasMetering keep the not rounded kWh view and give totals per tab, series and period. update_energy does not call it, so request counts stay the same until the integration polls it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # tests/test_galevo_device.py
A null or wrong value in the metering answer no longer raises. The web login no longer follows its redirect, so a failing home page cannot fail a good login, one request is saved and no page with personal data is downloaded. A web 429 keeps only the block time, never the page. The 429 handling is one helper for API and web requests. hasCooling is None when the plant modes are unknown, as the web app sends it, and a device loads its features before the first metering update. Co-Authored-By: Claude Opus 5.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.
The API token gives only the electricity a heat pump used. The heat it produced is only on the web app's metering page, so
AristonAPI.get_metering_data/async_get_metering_datanow log in to the web app in one cookie session and readR2/PlantMetering/GetData. GALEVO devices withhasMeteringgetupdate_metering()andget_metering_total(tab, series, period)for heat produced and COP in the integration (plan 26). Not called fromupdate_energy, so request counts stay the same.Changes
const.py:ARISTON_WEB_USER_AGENT(browser string, the only one tested), web login/data paths, the cookie name,MeteringTab,MeteringSeries,MeteringPeriod(cloud strings) andMeteringData(answer keys).ariston_api.py:get_metering_data(gw_id, features, has_cooling)and the async twin. The web URL is the scheme and host ofapi_url. Onerequests.Session/aiohttp.ClientSession(30 s timeout) per call: login, thenGetDatawithX-Requested-With: XMLHttpRequest. Redirects are not followed: the login answer sets the cookie, so the home page is never loaded. RaisesConnectionException:("Web login failed",): no.AspNet.ApplicationCookieafter the login,("Metering answer is not JSON",): a login page,("Metering failed", <message>):okis false,(status,)for other HTTP errors (no retry; the next update tries again),(429, "blocked for N seconds")or(429, ""): blocks the account like API requests. The block is checked before each web request, so an API 429 also stops the web login. API and web share one 429 helper.galevo_device.py:update_metering()/async_update_metering()(loads the features first if they are not loaded; no request unlesshas_metering is True;hasCoolingfrom thePlantModeoptions 3/4,Nonewhen they are unknown, as the web app sends it),metering_datakeeps onlyoldestMonth,isIntensiveLogsActiveandasKwhRaw,get_metering_total(...) -> float | None(null fields and non-number values never raise),is_metering_intensive_logs_active.FakeSessionand a newFakeSyncSessionhave a cookie jar and record web requests (withallow_redirects). 33 new tests (sync and async): login and body/headers/redirects, refused login, login page,okfalse, HTTP error, 429 both ways, a 429 page not logged; device totals, missing row, null values, no metering, features loaded first,hasCooling. The new tests fail on the code before them. 146 tests, ruff clean.Notes
requestsandaiohttpagainst a local server that answers like the web app (302 with the cookie): both paths keep the cookie without following the redirect and send it toGetData; a wrong password gives "Web login failed". One update is 2 HTTP requests..AspNet.ApplicationCookie, so not following the redirect works.hasMetering: True, intensive logs false, 36 rows, and the totals match the research run of the same day (for example 2025 and yesterday's heating and DHW).ok: false.is_plant_mode_options_contains_coolingraisesTypeErrorwhen the device has noPlantModeitem. Left as is (a public property, better fixed in its own PR); the metering code checks forNonefirst.Review (/code-review)
Fixed: null fields in
get_metering_total, the login judged by the home page status (now no redirects), a web 429 page in the log,hasCoolingfalse instead of null, a silent no-op before features are loaded, the 429 code in three copies, the localjsonname that hid the module,async withfor the web response.Not changed:
GetDatawithoutGetUiDefinitionfirst: the check script shows at once if it is needed.api_urlwith a path prefix loses the prefix: the plan says scheme and host, and no such setup is known.Check on the real cloud
Done on 2026-10-25 (see Notes). It asks for the login, saves nothing, and prints only the totals (not the gateway):
check_metering.py:Expected:
hasMetering: True,intensive logs: False, and 36 rows (2 tabs × 3 series × 6 periods) with kWh that match the web app.🤖 Generated with Claude Code