Skip to content

Commit 8c21744

Browse files
committed
Add component types aliases
These aliases are type unions for all supported components, and for all known problematic, unspecified and unrecognized components. These include the specific types of components with sub-types, like batteries, EV chargers and inverters. These type aliases only include concrete types, the base types are not included, this way they can be used as type hints where match statements should be used. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 509ae9c commit 8c21744

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
)
5151
from ._relay import Relay
5252
from ._status import ComponentStatus
53+
from ._types import (
54+
ComponentTypes,
55+
ProblematicComponentTypes,
56+
UnrecognizedComponentTypes,
57+
UnspecifiedComponentTypes,
58+
)
5359
from ._voltage_transformer import VoltageTransformer
5460

5561
__all__ = [
@@ -62,6 +68,7 @@
6268
"Component",
6369
"ComponentCategory",
6470
"ComponentStatus",
71+
"ComponentTypes",
6572
"Converter",
6673
"CryptoMiner",
6774
"DcEvCharger",
@@ -82,14 +89,17 @@
8289
"NaIonBattery",
8390
"Precharger",
8491
"ProblematicComponent",
92+
"ProblematicComponentTypes",
8593
"Relay",
8694
"SolarInverter",
8795
"UnrecognizedBattery",
8896
"UnrecognizedComponent",
97+
"UnrecognizedComponentTypes",
8998
"UnrecognizedEvCharger",
9099
"UnrecognizedInverter",
91100
"UnspecifiedBattery",
92101
"UnspecifiedComponent",
102+
"UnspecifiedComponentTypes",
93103
"UnspecifiedEvCharger",
94104
"UnspecifiedInverter",
95105
"VoltageTransformer",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# License: MIT
2+
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
3+
4+
"""All known component types."""
5+
6+
from typing import TypeAlias
7+
8+
from ._battery import BatteryTypes, UnrecognizedBattery, UnspecifiedBattery
9+
from ._chp import Chp
10+
from ._converter import Converter
11+
from ._crypto_miner import CryptoMiner
12+
from ._electrolyzer import Electrolyzer
13+
from ._ev_charger import EvChargerTypes, UnrecognizedEvCharger, UnspecifiedEvCharger
14+
from ._fuse import Fuse
15+
from ._grid_connection_point import GridConnectionPoint
16+
from ._hvac import Hvac
17+
from ._inverter import InverterTypes, UnrecognizedInverter, UnspecifiedInverter
18+
from ._meter import Meter
19+
from ._precharger import Precharger
20+
from ._problematic import (
21+
MismatchedCategoryComponent,
22+
UnrecognizedComponent,
23+
UnspecifiedComponent,
24+
)
25+
from ._relay import Relay
26+
from ._voltage_transformer import VoltageTransformer
27+
28+
UnspecifiedComponentTypes: TypeAlias = (
29+
UnspecifiedBattery
30+
| UnspecifiedComponent
31+
| UnspecifiedEvCharger
32+
| UnspecifiedInverter
33+
)
34+
"""All unspecified component types."""
35+
36+
UnrecognizedComponentTypes: TypeAlias = (
37+
UnrecognizedBattery
38+
| UnrecognizedComponent
39+
| UnrecognizedEvCharger
40+
| UnrecognizedInverter
41+
)
42+
43+
ProblematicComponentTypes: TypeAlias = (
44+
MismatchedCategoryComponent | UnrecognizedComponentTypes | UnspecifiedComponentTypes
45+
)
46+
"""All possible component types that has a problem."""
47+
48+
ComponentTypes: TypeAlias = (
49+
BatteryTypes
50+
| Chp
51+
| Converter
52+
| CryptoMiner
53+
| Electrolyzer
54+
| EvChargerTypes
55+
| Fuse
56+
| GridConnectionPoint
57+
| Hvac
58+
| InverterTypes
59+
| Meter
60+
| Precharger
61+
| ProblematicComponentTypes
62+
| Relay
63+
| VoltageTransformer
64+
)
65+
"""All possible component types."""

0 commit comments

Comments
 (0)