Skip to content

Some microgrid topologies with a CHP don't work anymore #1347

@llucax

Description

@llucax

What happened?

After moving to use the frequenz-microgrid-component-graph some sites that have a CHP stopped working, with the following exception:

2026-01-20T17:03:06+0000 ERROR  frequenz.sdk.microgrid._data_sourcing.microgrid_api_source:309: Unknown component category ComponentCategory.CHP
2026-01-20T17:03:06+0000 ERROR  frequenz.sdk.microgrid._data_sourcing.microgrid_api_source:433: Unexpected error while handling data stream for component 332 (ComponentCategory.CHP), component data is not being streamed anymore
Traceback (most recent call last):
 File "/venv/lib/python3.13/site-packages/frequenz/sdk/microgrid/_data_sourcing/microgrid_api_source.py", line 386, in _handle_data_stream
  await self._check_requested_component_and_metrics(
    comp_id, category, self._req_streaming_metrics[comp_id]
  )
 File "/venv/lib/python3.13/site-packages/frequenz/sdk/microgrid/_data_sourcing/microgrid_api_source.py", line 310, in _check_requested_component_and_metrics
  raise ValueError(err)
ValueError: Unknown component category ComponentCategory.CHP
2026-01-20T17:03:06+0000 ERROR  frequenz.sdk._internal._asyncio:67: Restarting after exception
Traceback (most recent call last):
 File "/venv/lib/python3.13/site-packages/frequenz/sdk/_internal/_asyncio.py", line 62, in run_forever
  await async_callable()
 File "/venv/lib/python3.13/site-packages/frequenz/sdk/microgrid/_data_sourcing/microgrid_api_source.py", line 386, in _handle_data_stream
  await self._check_requested_component_and_metrics(
    comp_id, category, self._req_streaming_metrics[comp_id]
  )
 File "/venv/lib/python3.13/site-packages/frequenz/sdk/microgrid/_data_sourcing/microgrid_api_source.py", line 310, in _check_requested_component_and_metrics
  raise ValueError(err)
ValueError: Unknown component category ComponentCategory.CHP

What did you expect instead?

Sites to work.

Affected version(s)

v1.0.0-rc2202

Affected part(s)

Microgrid (API, component graph, etc.) (part:microgrid)

Extra information

  • The data sourcing actor doesn't support subscribing to CHP components, this should be fixed, it will be trivial to fix once we remove the legacy wrappers, as we should not care anymore about the component category when subscribing to component data with the new microgrid API.
  • It looks like the SDK component graph somehow ignored CHP in formulas, or only used the meter in front of them, so the regression probably comes from added fallbacks in the rust based component graph.

A failing site has a topology like:

Note

The CHP is virtual on this site, it can't be controller nor read, it's just there to let the meter being identified as the CHP meter.

flowchart LR
  c1["1<br/>GRID_CONNECTION_POINT"]:::grid
  c2["2<br/>METER"]:::meter

  c3["3<br/>METER"]:::meter
  c4["4<br/>METER"]:::meter
  c5["5<br/>METER"]:::meter

  c6["6<br/>CHP"]:::chp
  c7["7<br/>INVERTER (PV)"]:::pv

  c8["8<br/>INVERTER (BATTERY)"]:::inverter
  c9["9<br/>BATTERY (LI_ION)"]:::battery

  %% Connections
  c1 --> c2
  c2 --> c3
  c2 --> c4
  c2 --> c5

  c3 --> c6
  c4 --> c7
  c5 --> c8 --> c9

  %% Styles
  classDef grid fill:#eef,stroke:#335,stroke-width:1px;
  classDef meter fill:#efe,stroke:#353,stroke-width:1px;
  classDef inverter fill:#ffe,stroke:#553,stroke-width:1px;
  classDef battery fill:#fef,stroke:#535,stroke-width:1px;
  classDef pv fill:#eef,stroke:#553,stroke-width:1px;
  classDef chp fill:#eef,stroke:#553,stroke-width:1px;
Loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highAddress this as soon as possibletype:bugSomething isn't workingtype:regressionSomething isn't working, but it was working before

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions