Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

## New Features

<!-- Here goes the main new features and examples or instructions on how to use them -->
- `generate-config` now derives a `generation` component type, with its
`AC_POWER_ACTIVE` formula taken from `ComponentGraph.producer_formula()`, so
the aggregated producer power is emitted alongside `consumption`.

## Bug Fixes

Expand Down
6 changes: 6 additions & 0 deletions src/frequenz/gridpool/config/_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def as_formula(derived: str) -> dict[str, str] | None:
component=None,
formula=as_formula(graph.consumer_formula()),
),
"generation": ComponentTypeConfig(
meter=None,
inverter=None,
component=None,
formula=as_formula(graph.producer_formula()),
),
"grid": ComponentTypeConfig(
meter=grid_meter_ids(graph) or None,
inverter=None,
Expand Down
4 changes: 3 additions & 1 deletion src/frequenz/gridpool/config/_microgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

from ._fields import toml_datetime_metadata

ComponentType = Literal["grid", "pv", "battery", "consumption", "chp", "ev"]
ComponentType = Literal[
"grid", "pv", "battery", "consumption", "generation", "chp", "ev"
]
"""Valid component types."""

ComponentCategory = Literal["meter", "inverter", "component"]
Expand Down
8 changes: 6 additions & 2 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ async def test_load_microgrids_from_api_derives_formulas_and_ids() -> None:
assert cfg.ctype["pv"].inverter == [4]
assert cfg.ctype["pv"].meter == [2]
assert cfg.ctype["grid"].meter == [2, 3]
assert cfg.ctype["generation"].formula == {
"AC_POWER_ACTIVE": "COALESCE(#4, #2, 0.0)"
}
# Component types absent from the microgrid are not created.
assert set(cfg.ctype) == {"grid", "consumption", "pv"}
assert set(cfg.ctype) == {"grid", "consumption", "generation", "pv"}


async def test_load_microgrids_from_api_allows_missing_enterprise_id() -> None:
Expand Down Expand Up @@ -201,4 +204,5 @@ async def test_derive_component_configs_builds_formulas_and_ids() -> None:
assert configs["pv"].inverter == [4]
assert configs["pv"].meter == [2]
assert configs["grid"].meter == [2, 3]
assert set(configs) == {"grid", "consumption", "pv"}
assert configs["generation"].formula == {"AC_POWER_ACTIVE": "COALESCE(#4, #2, 0.0)"}
assert set(configs) == {"grid", "consumption", "generation", "pv"}