Skip to content

feat(energy): add typed energy_totals listener for calendar_history refreshes - #15

Merged
Bre77 merged 1 commit into
mainfrom
fm/pts-calendar-refresh-event
Jul 29, 2026
Merged

feat(energy): add typed energy_totals listener for calendar_history refreshes#15
Bre77 merged 1 commit into
mainfrom
fm/pts-calendar-refresh-event

Conversation

@Bre77

@Bre77 Bre77 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Intent

Adds typed listener support for Teslemetry's new energy_totals SSE event, following PR #13's live_status/site_info idiom.

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_totals notification on the uniform notification schema: id (the site id - not site_id, unlike live_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 cumulative totals object.

  • TeslemetryStreamEnergySite.listen_EnergyTotals filters on id/product_type/topic and hands the callback a typed EnergyHistoryTotals dataclass (teslemetry_stream/const.py) built from the event's totals dict.
  • The event fires only when the poll actually detects a change - silence means no change, never staleness - and has no snapshot-on-connect delivery, unlike live_status/site_info. A consumer wanting the full time series GETs the event's url via their own REST client.
  • Purely additive: no changes to existing listeners or event handling.

tests/test_energysite_events.py extends the existing PR 310 fixtures with energy_totals cases covering totals parsing, site-id filtering, and cross-listener isolation.

…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.
@Bre77
Bre77 merged commit 016a94c into main Jul 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant