Repository navigation
improve: Build the API subscriptions list in a single template - #675
Merged
edwardtfn merged 2 commits intoNov 5, 2026
Merged
Conversation
Contributor
Reviewer's GuideRefactors API subscription generation from multiple intermediate templates into a single consolidated Jinja template, preserving the panel’s list and ordering while reducing the Home Assistant template-cache footprint. Adds a seeded 4,000-case equivalence test with mocked inputs and state to detect behavioral changes. Sequence diagram for API subscription list renderingsequenceDiagram
participant A as Panel automation
participant J as api_subscriptions
participant H as Home Assistant state
participant P as Panel
A->>J: Render subscription template
J->>H: Read entity and thermostat state
H-->>J: Weather, temperature, calibration, and wake-up values
J->>J: Combine chips, weather, buttons, wake-up, and calibration
J->>J: Filter undefined and empty entities
J-->>A: Ordered subscription list
A->>P: Send API subscriptions
Flow diagram for consolidated API subscription generationflowchart LR
I["Blueprint inputs and entity state"] --> C["subs_chips"]
I --> T["api_subscriptions template"]
C --> T
T --> W["Weather and temperatures"]
T --> K["Custom buttons"]
T --> U["Wake-up sensors"]
T --> R["Calibration reference"]
W --> F["Filter valid subscriptions"]
K --> F
U --> F
R --> F
F --> P["Panel API subscription list"]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
edwardtfn
deleted the
improve/blueprint-api-subscriptions-single-template
branch
November 5, 2026 17:13
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.
Builds the list of API subscriptions (home page chips, weather picture, outdoor and indoor temperature, custom buttons, wake-up sensors and the temperature calibration reference) in a single template.
subs_listsandapi_subs_mappingare replaced bysubs_chips(the chip inputs, no templates) and oneapi_subscriptionstemplate that builds the whole list. The per-item comments are kept as Jinja comments.Distinct templates go from 1,013 to 1,003 (-10), widening the margin under Home Assistant's template cache of 1,024 entries, which Spook depends on. The expanded size grows slightly (+171 characters, the indentation inside the template); the file shrinks by 880 bytes.
A new equivalence test,
.github/scripts/test_api_subscriptions.py, renders the variables of both versions with mocked inputs and state (weather, outdoor and indoor temperature as empty, single entity or list, visible or not; calibration reference as empty, sensor, climate or the panel's own entities, with and without the embedded thermostat; wake-up sensors with gaps; chips and custom buttons with missing, empty, invalid and valid entities) and compares the resulting subscription list. Result againstdev: 4,000 cases, 0 differences. Deliberate mutations (component, attribute, page, sensor numbering) are all detected.Related to #657 and #636.
Summary by Sourcery
Consolidate API subscription construction into one template without changing the subscriptions sent to the panel.
Enhancements:
Tests: