22# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
33
44"""Defines the components that can be used in a microgrid."""
5+
56from __future__ import annotations
67
7- from enum import Enum
8+ import enum
9+ from typing import final
810
911# pylint: disable=no-name-in-module
1012from frequenz .api .common .v1 .microgrid .components .components_pb2 import (
1618from frequenz .api .common .v1 .microgrid .components .components_pb2 import (
1719 ComponentStateCode as PBComponentStateCode ,
1820)
21+ from frequenz .core .id import BaseId
22+ from typing_extensions import deprecated
1923
2024# pylint: enable=no-name-in-module
2125
2226
23- class ComponentCategory (Enum ):
27+ @final
28+ class ComponentId (BaseId , str_prefix = "CID" ):
29+ """A unique identifier for a microgrid component."""
30+
31+
32+ @enum .unique
33+ class ComponentCategory (enum .Enum ):
2434 """Possible types of microgrid component."""
2535
2636 UNSPECIFIED = PBComponentCategory .COMPONENT_CATEGORY_UNSPECIFIED
@@ -39,16 +49,63 @@ class ComponentCategory(Enum):
3949 INVERTER = PBComponentCategory .COMPONENT_CATEGORY_INVERTER
4050 """An electricity generator, with batteries or solar energy."""
4151
52+ CONVERTER = PBComponentCategory .COMPONENT_CATEGORY_CONVERTER
53+ """A DC-DC converter."""
54+
4255 BATTERY = PBComponentCategory .COMPONENT_CATEGORY_BATTERY
4356 """A storage system for electrical energy, used by inverters."""
4457
4558 EV_CHARGER = PBComponentCategory .COMPONENT_CATEGORY_EV_CHARGER
4659 """A station for charging electrical vehicles."""
4760
61+ CRYPTO_MINER = PBComponentCategory .COMPONENT_CATEGORY_CRYPTO_MINER
62+ """A crypto miner."""
63+
64+ ELECTROLYZER = PBComponentCategory .COMPONENT_CATEGORY_ELECTROLYZER
65+ """An electrolyzer for converting water into hydrogen and oxygen."""
66+
4867 CHP = PBComponentCategory .COMPONENT_CATEGORY_CHP
4968 """A heat and power combustion plant (CHP stands for combined heat and power)."""
5069
70+ RELAY = PBComponentCategory .COMPONENT_CATEGORY_RELAY
71+ """A relay.
72+
73+ Relays generally have two states: open (connected) and closed (disconnected).
74+ They are generally placed in front of a component, e.g., an inverter, to
75+ control whether the component is connected to the grid or not.
76+ """
77+
78+ PRECHARGER = PBComponentCategory .COMPONENT_CATEGORY_PRECHARGER
79+ """A precharge module.
80+
81+ Precharging involves gradually ramping up the DC voltage to prevent any
82+ potential damage to sensitive electrical components like capacitors.
83+
84+ While many inverters and batteries come equipped with in-built precharging
85+ mechanisms, some may lack this feature. In such cases, we need to use
86+ external precharging modules.
87+ """
88+
89+ FUSE = PBComponentCategory .COMPONENT_CATEGORY_FUSE
90+ """A fuse."""
91+
92+ VOLTAGE_TRANSFORMER = PBComponentCategory .COMPONENT_CATEGORY_VOLTAGE_TRANSFORMER
93+ """A voltage transformer.
94+
95+ Voltage transformers are used to step up or step down the voltage, keeping
96+ the power somewhat constant by increasing or decreasing the current. If voltage is
97+ stepped up, current is stepped down, and vice versa.
98+
99+ Note:
100+ Voltage transformers have efficiency losses, so the output power is
101+ always less than the input power.
102+ """
103+
104+ HVAC = PBComponentCategory .COMPONENT_CATEGORY_HVAC
105+ """A Heating, Ventilation, and Air Conditioning (HVAC) system."""
106+
51107 @classmethod
108+ @deprecated ("Use `frequenz.client.common.enum_proto.enum_from_proto` instead." )
52109 def from_proto (
53110 cls , component_category : PBComponentCategory .ValueType
54111 ) -> ComponentCategory :
@@ -73,7 +130,8 @@ def to_proto(self) -> PBComponentCategory.ValueType:
73130 return self .value
74131
75132
76- class ComponentStateCode (Enum ):
133+ @enum .unique
134+ class ComponentStateCode (enum .Enum ):
77135 """All possible states of a microgrid component."""
78136
79137 UNSPECIFIED = PBComponentStateCode .COMPONENT_STATE_CODE_UNSPECIFIED
@@ -153,6 +211,7 @@ class ComponentStateCode(Enum):
153211 """The precharger circuit is closed, allowing full current to flow to the main circuit."""
154212
155213 @classmethod
214+ @deprecated ("Use `frequenz.client.common.enum_proto.enum_from_proto` instead." )
156215 def from_proto (
157216 cls , component_state : PBComponentStateCode .ValueType
158217 ) -> ComponentStateCode :
@@ -177,7 +236,8 @@ def to_proto(self) -> PBComponentStateCode.ValueType:
177236 return self .value
178237
179238
180- class ComponentErrorCode (Enum ):
239+ @enum .unique
240+ class ComponentErrorCode (enum .Enum ):
181241 """All possible errors that can occur across all microgrid component categories."""
182242
183243 UNSPECIFIED = PBComponentErrorCode .COMPONENT_ERROR_CODE_UNSPECIFIED
@@ -330,6 +390,7 @@ class ComponentErrorCode(Enum):
330390 times."""
331391
332392 @classmethod
393+ @deprecated ("Use `frequenz.client.common.enum_proto.enum_from_proto` instead." )
333394 def from_proto (
334395 cls , component_error_code : PBComponentErrorCode .ValueType
335396 ) -> ComponentErrorCode :
0 commit comments