Skip to content

Add support active energy#53

Merged
Mohammad-Tayyab-Frequenz merged 3 commits intofrequenz-floss:v0.x.xfrom
Mohammad-Tayyab-Frequenz:add-support-active-energy
Mar 13, 2026
Merged

Add support active energy#53
Mohammad-Tayyab-Frequenz merged 3 commits intofrequenz-floss:v0.x.xfrom
Mohammad-Tayyab-Frequenz:add-support-active-energy

Conversation

@Mohammad-Tayyab-Frequenz
Copy link
Contributor

This PR adds default summation formulas for AC energy metrics in component type configuration, mirroring existing power behavior and deriving defaults from the configured component IDs.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds broader default formula handling in microgrid component-type configuration so AC energy metrics get sensible defaults when not explicitly configured.

Changes:

  • Extend ComponentTypeConfig.__post_init__() to populate default summation formulas for AC_ENERGY_ACTIVE, AC_ENERGY_ACTIVE_CONSUMED, and AC_ENERGY_ACTIVE_DELIVERED (and keep backward-compat handling for deprecated AC_ACTIVE_POWER).
  • Update release notes to document the new defaulting behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/frequenz/gridpool/_microgrid_config.py Adds default-formula initialization for additional AC energy metrics during config post-init.
RELEASE_NOTES.md Documents the new default summation formulas for AC energy metrics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Mohammad-Tayyab-Frequenz Mohammad-Tayyab-Frequenz force-pushed the add-support-active-energy branch 2 times, most recently from ddb36ba to 41a12cf Compare March 10, 2026 18:19
Extend the default formula handling to also cover AC_ENERGY_ACTIVE, AC_ENERGY_ACTIVE_CONSUMED, and AC_ENERGY_ACTIVE_DELIVERED.

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>
Copy link
Collaborator

@cwasicki cwasicki left a comment

Choose a reason for hiding this comment

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

Nice, thank you!


for metric in defaults:
if metric not in self.formula:
self.formula[metric] = "+".join(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's completely get rid of this, this is actually dangerous. If you prefer to break it slower can also be a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't this remove the support for manual formulas then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is adding a fallback so that if it has not been specified at this point it adds a default summing up the default CIDs. So this silently adds a formula. I think it's better to be explicit about this and fail in case we don't have a formula neither from the formula generator nor via config. Or do I misunderstand something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, got it. I was thinking we might not want to fail in that case either. But yeah, it makes sense to throw an error instead of returning potentially incorrect interpreted formulas.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make another PR for that then.

@shsms
Copy link
Collaborator

shsms commented Mar 13, 2026

Oh that's interesting. I wonder if inverters can be used as fallback sources for energy metrics. Have you tried this already? If not, I'll do some tests. If it doesn't work, we might have to disable fallback for specific formulas. That's still part of the plan, just haven't gotten to it yet.

@Mohammad-Tayyab-Frequenz
Copy link
Contributor Author

@shsms Sure, I would merge this PR now but we can take the fallback discussion to the relevant slack channel.
Thank you for the inputs!!

@Mohammad-Tayyab-Frequenz Mohammad-Tayyab-Frequenz added this pull request to the merge queue Mar 13, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 8a5e259 Mar 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants