Skip to content

Commit 0a43d72

Browse files
Add WindTurbine (#223)
2 parents 5c949cf + 7ad4d63 commit 0a43d72

File tree

9 files changed

+74
-6
lines changed

9 files changed

+74
-6
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ When migrating:
207207
- Add `get_microgrid_info()` returning a rich `MicrogridInfo` dataclass with ID, enterprise, location, delivery area, status, and timestamps.
208208
- Add a metrics model under `frequenz.client.microgrid.metrics` including the `Metric` enum, `Bounds`, and `MetricSample`/`AggregatedMetricValue`.
209209
- Add high-level methods on `MicrogridApiClient` for listing components and connections, adding component bounds, receiving component data samples streams, and controlling active/reactive power with lifetimes.
210+
- Add `WindTurbine` component type.
210211

211212
## Bug Fixes
212213

src/frequenz/client/microgrid/component/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
UnspecifiedComponentTypes,
5959
)
6060
from ._voltage_transformer import VoltageTransformer
61+
from ._wind_turbine import WindTurbine
6162

6263
__all__ = [
6364
"AcEvCharger",
@@ -107,4 +108,5 @@
107108
"UnspecifiedEvCharger",
108109
"UnspecifiedInverter",
109110
"VoltageTransformer",
111+
"WindTurbine",
110112
]

src/frequenz/client/microgrid/component/_category.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,6 @@ class ComponentCategory(enum.Enum):
104104

105105
HVAC = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_HVAC
106106
"""A Heating, Ventilation, and Air Conditioning (HVAC) system."""
107+
108+
WIND_TURBINE = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_WIND_TURBINE
109+
"""A wind turbine."""

src/frequenz/client/microgrid/component/_component_proto.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from ._relay import Relay
6161
from ._types import ComponentTypes
6262
from ._voltage_transformer import VoltageTransformer
63+
from ._wind_turbine import WindTurbine
6364

6465
_logger = logging.getLogger(__name__)
6566

@@ -255,6 +256,7 @@ def component_from_proto_with_issues(
255256
| ComponentCategory.METER
256257
| ComponentCategory.PRECHARGER
257258
| ComponentCategory.RELAY
259+
| ComponentCategory.WIND_TURBINE
258260
):
259261
return _trivial_category_to_class(base_data.category)(
260262
id=base_data.component_id,
@@ -449,6 +451,7 @@ def _trivial_category_to_class(
449451
| Meter
450452
| Precharger
451453
| Relay
454+
| WindTurbine
452455
]:
453456
"""Return the class corresponding to a trivial component category."""
454457
return {
@@ -461,6 +464,7 @@ def _trivial_category_to_class(
461464
ComponentCategory.METER: Meter,
462465
ComponentCategory.PRECHARGER: Precharger,
463466
ComponentCategory.RELAY: Relay,
467+
ComponentCategory.WIND_TURBINE: WindTurbine,
464468
}[category]
465469

466470

src/frequenz/client/microgrid/component/_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
)
2424
from ._relay import Relay
2525
from ._voltage_transformer import VoltageTransformer
26+
from ._wind_turbine import WindTurbine
2627

2728
UnspecifiedComponentTypes: TypeAlias = (
2829
UnspecifiedBattery
@@ -59,5 +60,6 @@
5960
| ProblematicComponentTypes
6061
| Relay
6162
| VoltageTransformer
63+
| WindTurbine
6264
)
6365
"""All possible component types."""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# License: MIT
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Wind turbine component."""
5+
6+
import dataclasses
7+
from typing import Literal
8+
9+
from ._category import ComponentCategory
10+
from ._component import Component
11+
12+
13+
@dataclasses.dataclass(frozen=True, kw_only=True)
14+
class WindTurbine(Component):
15+
"""A wind turbine component."""
16+
17+
category: Literal[ComponentCategory.WIND_TURBINE] = ComponentCategory.WIND_TURBINE
18+
"""The category of this component."""

tests/client_test_cases/list_components/diverse_component_types_case.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
UnspecifiedEvCharger,
4848
UnspecifiedInverter,
4949
VoltageTransformer,
50+
WindTurbine,
5051
)
5152

5253
# No client_args or client_kwargs needed for this call
@@ -228,17 +229,21 @@ def assert_stub_method_call(stub_method: Any) -> None:
228229
id=25,
229230
category=ec_pb2.ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER,
230231
),
231-
# Problematic components
232232
ec_pb2.ElectricalComponent(
233233
id=26,
234-
category=ec_pb2.ELECTRICAL_COMPONENT_CATEGORY_UNSPECIFIED,
234+
category=ec_pb2.ELECTRICAL_COMPONENT_CATEGORY_WIND_TURBINE,
235235
),
236+
# Problematic components
236237
ec_pb2.ElectricalComponent(
237238
id=27,
238-
category=999, # type: ignore[arg-type]
239+
category=ec_pb2.ELECTRICAL_COMPONENT_CATEGORY_UNSPECIFIED,
239240
),
240241
ec_pb2.ElectricalComponent(
241242
id=28,
243+
category=999, # type: ignore[arg-type]
244+
),
245+
ec_pb2.ElectricalComponent(
246+
id=29,
242247
category=ec_pb2.ELECTRICAL_COMPONENT_CATEGORY_BATTERY,
243248
category_specific_info=ec_pb2.ElectricalComponentCategorySpecificInfo(
244249
# Mismatched: battery category with inverter metadata
@@ -292,13 +297,14 @@ def assert_client_result(result: Any) -> None:
292297
primary_voltage=0.0,
293298
secondary_voltage=0.0,
294299
),
300+
WindTurbine(id=ComponentId(26), microgrid_id=MicrogridId(0)),
295301
# Problematic components
296-
UnspecifiedComponent(id=ComponentId(26), microgrid_id=MicrogridId(0)),
302+
UnspecifiedComponent(id=ComponentId(27), microgrid_id=MicrogridId(0)),
297303
UnrecognizedComponent(
298-
id=ComponentId(27), microgrid_id=MicrogridId(0), category=999
304+
id=ComponentId(28), microgrid_id=MicrogridId(0), category=999
299305
),
300306
MismatchedCategoryComponent(
301-
id=ComponentId(28),
307+
id=ComponentId(29),
302308
microgrid_id=MicrogridId(0),
303309
category=ComponentCategory.BATTERY,
304310
category_specific_metadata={

tests/component/component_proto/test_simple.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
UnrecognizedComponent,
2929
UnspecifiedComponent,
3030
VoltageTransformer,
31+
WindTurbine,
3132
)
3233
from frequenz.client.microgrid.component._component_proto import (
3334
ComponentBaseData,
@@ -112,6 +113,7 @@ def test_category_mismatch(default_component_base_data: ComponentBaseData) -> No
112113
pytest.param(ComponentCategory.METER, Meter, id="Meter"),
113114
pytest.param(ComponentCategory.PRECHARGER, Precharger, id="Precharger"),
114115
pytest.param(ComponentCategory.RELAY, Relay, id="Relay"),
116+
pytest.param(ComponentCategory.WIND_TURBINE, WindTurbine, id="WindTurbine"),
115117
],
116118
)
117119
def test_trivial(
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# License: MIT
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Tests for WindTurbine component."""
5+
6+
7+
from frequenz.client.common.microgrid import MicrogridId
8+
from frequenz.client.common.microgrid.components import ComponentId
9+
10+
from frequenz.client.microgrid.component import ComponentCategory, WindTurbine
11+
12+
13+
def test_init() -> None:
14+
"""Test WindTurbine component initialization."""
15+
component_id = ComponentId(1)
16+
microgrid_id = MicrogridId(1)
17+
component = WindTurbine(
18+
id=component_id,
19+
microgrid_id=microgrid_id,
20+
name="wind_turbine_test",
21+
manufacturer="test_manufacturer",
22+
model_name="test_model",
23+
)
24+
25+
assert component.id == component_id
26+
assert component.microgrid_id == microgrid_id
27+
assert component.name == "wind_turbine_test"
28+
assert component.manufacturer == "test_manufacturer"
29+
assert component.model_name == "test_model"
30+
assert component.category == ComponentCategory.WIND_TURBINE

0 commit comments

Comments
 (0)