Skip to content

Add energy formulas - #143

Open
Mohammad-Tayyab-Frequenz wants to merge 3 commits into
frequenz-floss:v0.x.xfrom
Mohammad-Tayyab-Frequenz:add-energy-formulas
Open

Mohammad-Tayyab-Frequenz wants to merge 3 commits into
frequenz-floss:v0.x.xfrom
Mohammad-Tayyab-Frequenz:add-energy-formulas

Conversation

@Mohammad-Tayyab-Frequenz

Copy link
Copy Markdown
Contributor

Add AC_ENERGY_ACTIVE, AC_ENERGY_ACTIVE_CONSUMED, and AC_ENERGY_ACTIVE_DELIVERED to _derive_component_configs function.

@Mohammad-Tayyab-Frequenz
Mohammad-Tayyab-Frequenz requested review from Marenz and removed request for a team October 19, 2026 18:55
@github-actions github-actions Bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:docs Affects the documentation labels Oct 19, 2026
Comment thread src/frequenz/gridpool/config/_load.py Resolved
Signed-off-by: Mohammad Tayyab <Mohammad.Tayyab@neustrom.de>
Signed-off-by: Mohammad Tayyab <Mohammad.Tayyab@neustrom.de>
Signed-off-by: Mohammad Tayyab <Mohammad.Tayyab@neustrom.de>

@Marenz Marenz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The centralizing fix is the right shape, but the fallback isn't safe yet. formula_for_metric reuses the AC_POWER_ACTIVE formula for AC_ENERGY_ACTIVE_CONSUMED/DELIVERED. The real consumption/grid formulas use subtraction and MAX(x - y, 0.0) to pick between bidirectional meters — that arithmetic doesn't make sense applied to energy counters, which are already non-negative and direction-resolved. It also means consumed and delivered end up with the identical fallback formula, nothing tells them apart. Tests only cover a plain sum (#12+#23), so this doesn't show up.

Also: mypy now fails under ci_checks_max on tests/test_config.py:129 (indexed assignment into an Optional dict), and the branch still conflicts with v0.x.x (RELEASE_NOTES.md, _load.py, _microgrid.py, from #144's generation type) — needs a rebase before this can land.

formula = self.formula.get(_POWER_FORMULA_METRIC)
return formula

def cids(self, metric: str = "") -> list[int]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this, I am not aware if it is used anywhere.

@cwasicki

Copy link
Copy Markdown
Collaborator

The real consumption/grid formulas use subtraction and MAX(x - y, 0.0) to pick between bidirectional meters

Is this still true, I think the clamping was removed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants