feat(energy): add typed energy_totals listener for calendar_history refreshes - #15
Merged
Conversation
…efreshes Teslemetry/api PR 316 adds server-side polling of energy calendar history, publishing a compact energy_totals notification (id/product_type/topic/ url/createdAt/isCache/totals) instead of the full document. Adds listen_EnergyTotals on TeslemetryStreamEnergySite plus the typed EnergyHistoryTotals dataclass to expose the cumulative totals.
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.
Intent
Adds typed listener support for Teslemetry's new
energy_totalsSSE event, following PR #13'slive_status/site_infoidiom.Teslemetry/api PR 316 added server-side 5-minute polling of energy calendar history (kind=energy, period=day). Instead of broadcasting the full history document, the stream carries a compact
energy_totalsnotification on the uniform notification schema:id(the site id - notsite_id, unlikelive_status/site_info),product_type("energy_site"),topic("energy_totals"),url(the canonical REST path to re-fetch the full document),createdAt,isCache, plus a compact per-type cumulativetotalsobject.TeslemetryStreamEnergySite.listen_EnergyTotalsfilters onid/product_type/topicand hands the callback a typedEnergyHistoryTotalsdataclass (teslemetry_stream/const.py) built from the event'stotalsdict.live_status/site_info. A consumer wanting the full time series GETs the event'surlvia their own REST client.tests/test_energysite_events.pyextends the existing PR 310 fixtures withenergy_totalscases covering totals parsing, site-id filtering, and cross-listener isolation.