Repository navigation
Fix timezone, stale spot price and diagnostics, JWT decoding and retries - #8
Merged
Merged
Conversation
- Revenue dates and the energy totals' year use Swedish local time (Europe/Stockholm) like the spot price already did, instead of the host timezone. HA does not set the process timezone, so a UTC container got yesterday's revenue between 00:00 and 02:00. - Spot price: a slot is only valid until the next one starts (the last one as long as the one before it), so an outdated price list yields unknown instead of its last price forever. Entries without a Value are skipped instead of raising KeyError and failing the whole refresh. - JWT expiry is decoded with urlsafe_b64decode. b64decode dropped "-" and "_", so payloads containing them always fell back to 10 minutes. - The logbook is seeded with the newest timestamp among its entries, so a newest line without a timestamp no longer disables logbook events. - CM10 diagnostics older than 3 hours, or missing, are reported as unknown instead of showing the last connection state indefinitely. - A failed slow update is retried after 5 minutes instead of waiting its full interval (up to 4 hours for news). The six last-update timestamps are replaced by one next-due map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tt2YacbPwiWKinpfhCss29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tt2YacbPwiWKinpfhCss29
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.
Follow-up to #7: fixes the remaining correctness findings (5–10) from the code review.
Changes
Europe/Stockholm, as the spot price already did, instead of the host timezone. HA does not set the process timezone, so a UTC container showed yesterday's revenue between 00:00 and 02:00. The timezone is now shared asAPI_TZinconst.py.Valueare skipped instead of raisingKeyError, which used to fail the whole refresh because slot selection runs every cycle.urlsafe_b64decode.b64decodedrops-and_, so payloads containing them always fell back to the 10-minute default expiry.Noneand logbook events never fired.CurrentinconnectionStatusis the CM10's latest report, however old. Reports older than 3 hours (DIAG_MAX_AGE), or missing ones, now clear battery temperature and internet connection instead of showing the last state indefinitely. The limit is generous because a healthy site's report can be over an hour old (seedocs/api.md).The version is bumped to 1.5.2.
Tests
test_coordinator.py(Swedish dates, retry, logbook seeding, diagnostics age),test_spot_price.py(slot validity, hourly slots, missing values) and a newtest_api.py(JWT expiry).test_after_last_slotasserted the old behaviour (the last price still shown 22 hours later), so it is replaced by tests for the new behaviour.ruff checkandruff format --checkare clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Tt2YacbPwiWKinpfhCss29
Generated by Claude Code