Repository navigation
Share reference stores between pools for all and explicit components - #1476
Merged
Merged
Conversation
A pool created without component IDs, or with an empty set, was keyed by an empty set, so it didn't share its reference store with the power manager's pool for the same components, and each tracked the power bounds of the same components on its own. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The data pipeline warns when the same pool is created twice at the same priority, but it compared a string of the component IDs. Two equal sets of component IDs can print in different orders, so the warning was sometimes missed. The key now also holds the pool's reference store class, so pools of different types that have no components don't warn about each other. The warning now names the components the pool resolved to, not the `component_ids` argument, which is `None` or an empty set when no IDs are given. It also names the right `new_*_pool()` function. Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Marenz
approved these changes
Oct 30, 2026
Marenz
left a comment
Contributor
There was a problem hiding this comment.
Looks good. I checked that the new tests fail on v1.x.x and pass here, and that sharing the store is safe: everything in it depends only on the component set.
A few small things:
- The warnings still name the old parameters (
ev_charger_ids=%s,pv_inverter_ids=%s,battery_ids=%s,steam_boiler_ids=%sin_data_pipeline.py); the keyword iscomponent_idsnow. Since this PR already edits those strings, maybe fix them too. - The release note describes the mechanism, but the visible bug was worse: with 11 or more batteries, two pools for the same components at the same priority got differently spelled channel names, and one of them never got
power_statusupdates (I reproduced this onv1.x.x). Maybe say that in the note. - Nit:
assert all_pool.power_status is explicit_pool.power_statusintest_pools_for_all_components_share_reference_storeswould pin that symptom directly. - Nit: the 6-component test relies on the graph-built set printing in a different order than
frozenset(ids), which only holds becauseall_component_ids()now uses a generator. An assert on that premise (or a more general comment) would keep it from silently losing its point. - Nit, maybe a follow-up:
ReportRequest.get_channel_name()still builds the name from the text of the set; sorting the IDs there would remove the order dependency for good.
llucax
reviewed
Oct 30, 2026
llucax
left a comment
Contributor
There was a problem hiding this comment.
🤖 rAIview (AI review here!)
I found no additional issues to raise. Resolving the component IDs before choosing the reference-store key consistently shares state between equivalent pools, while including the store class in the duplicate-warning key keeps different pool types separate. I found no breaking API changes or new security concerns.
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.
A pool created without component IDs was keyed by an empty set, so it didn't share its reference store with the pool the power manager creates for the explicit IDs of the same components. This branch keys the stores by the resolved component IDs, and fixes the duplicate-pool warning, which had the same keying problem.
Changes
ComponentPoolReferenceStore.resolve_component_ids()turnsNoneor an empty set into all the IDs of the pool's type._DataPipeline.new_*_pool()uses the result as the store key and passes it to the store, so the key andstore.component_idsare the same set.(store class, IDs, priority)instead of the text of the IDs. Equal sets can print in different orders, so the old key sometimes missed duplicates, and pools of different types without components warned about each other. The warning now prints the resolved IDs and the rightnew_*_pool()name.test_pool_for_all_components_warns_like_explicit_ids. Its comment explains why a key made from the text of the IDs fails there.ReportRequest.get_channel_name()). Before, two pools for the same batteries at the same priority could get names that didn't match, so the second pool'spower_statuschannel never got a sender. Sharing one store fixes that.