1010from typing import Any , Self , SupportsInt , TypeAlias , cast , final
1111
1212# pylint: enable=no-name-in-module
13- from frequenz .api .common .v1 .microgrid .components . battery_pb2 import (
13+ from frequenz .api .common .v1alpha8 .microgrid .electrical_components . electrical_components_pb2 import (
1414 BatteryType as PBBatteryType ,
1515)
16- from frequenz .api .common .v1 .microgrid .components . ev_charger_pb2 import (
16+ from frequenz .api .common .v1alpha8 .microgrid .electrical_components . electrical_components_pb2 import (
1717 EvChargerType as PBEvChargerType ,
1818)
19- from frequenz .api .common .v1 .microgrid .components . inverter_pb2 import (
19+ from frequenz .api .common .v1alpha8 .microgrid .electrical_components . electrical_components_pb2 import (
2020 InverterType as PBInverterType ,
2121)
2222
3333from google .protobuf .struct_pb2 import Struct
3434
3535from frequenz .client .base .conversion import to_datetime , to_timestamp
36- from frequenz .client .common .microgrid .components import ComponentCategory
36+ from frequenz .client .common .v1alpha8 .microgrid .electrical_components import (
37+ ElectricalComponentCategory ,
38+ )
39+ from frequenz .client .common .v1alpha8 .streaming import Event
3740
3841from .recurrence import Frequency , RecurrenceRule , Weekday
3942
@@ -81,7 +84,7 @@ class InverterType(Enum):
8184 BATTERY = PBInverterType .INVERTER_TYPE_BATTERY
8285 """Battery inverter."""
8386
84- SOLAR = PBInverterType .INVERTER_TYPE_SOLAR
87+ SOLAR = PBInverterType .INVERTER_TYPE_PV
8588 """Solar inverter."""
8689
8790 HYBRID = PBInverterType .INVERTER_TYPE_HYBRID
@@ -92,28 +95,28 @@ class InverterType(Enum):
9295class TargetCategory :
9396 """Represents a category and optionally a type."""
9497
95- target : ComponentCategory | BatteryType | EvChargerType | InverterType
98+ target : ElectricalComponentCategory | BatteryType | EvChargerType | InverterType
9699 """The target category of the dispatch.
97100
98101 Implicitly derived from the types.
99102 """
100103
101104 @property
102- def category (self ) -> ComponentCategory :
105+ def category (self ) -> ElectricalComponentCategory :
103106 """Get the category of the target.
104107
105108 Returns:
106109 The category of the target.
107110 """
108111 match self .target :
109- case ComponentCategory ():
112+ case ElectricalComponentCategory ():
110113 return self .target
111114 case BatteryType ():
112- return ComponentCategory .BATTERY
115+ return ElectricalComponentCategory .BATTERY
113116 case EvChargerType ():
114- return ComponentCategory .EV_CHARGER
117+ return ElectricalComponentCategory .EV_CHARGER
115118 case InverterType ():
116- return ComponentCategory .INVERTER
119+ return ElectricalComponentCategory .INVERTER
117120
118121 @property
119122 def type (self ) -> BatteryType | EvChargerType | InverterType | None :
@@ -151,7 +154,11 @@ def __new__(cls, *ids: SupportsInt) -> Self:
151154
152155# Define the union of types that can be passed to TargetCategories constructor
153156TargetCategoryInputType = (
154- TargetCategory | ComponentCategory | BatteryType | InverterType | EvChargerType
157+ TargetCategory
158+ | ElectricalComponentCategory
159+ | BatteryType
160+ | InverterType
161+ | EvChargerType
155162)
156163"""Type for the input to TargetCategories constructor."""
157164
@@ -181,7 +188,8 @@ def __new__(cls, *categories_input: TargetCategoryInputType) -> Self:
181188 if isinstance (item , TargetCategory ):
182189 processed_elements .append (item )
183190 elif isinstance (
184- item , (ComponentCategory , BatteryType , InverterType , EvChargerType )
191+ item ,
192+ (ElectricalComponentCategory , BatteryType , InverterType , EvChargerType ),
185193 ):
186194 # Wrap raw categories/types into TargetCategory instances
187195 processed_elements .append (TargetCategory (target = item ))
@@ -236,15 +244,15 @@ def _target_components_from_protobuf(
236244 case "component_categories" :
237245 return TargetCategories (
238246 * map (
239- ComponentCategory .from_proto ,
247+ ElectricalComponentCategory .from_proto ,
240248 pb_target .component_categories .categories ,
241249 )
242250 )
243251 case "component_categories_types" :
244252 return TargetCategories (
245253 * map (
246254 lambda cat_and_type : _extract_category_type (cat_and_type )
247- or ComponentCategory .from_proto (cat_and_type .category ),
255+ or ElectricalComponentCategory .from_proto (cat_and_type .category ),
248256 pb_target .component_categories_types .categories ,
249257 )
250258 )
@@ -617,15 +625,6 @@ def to_protobuf(self) -> PBDispatch:
617625 )
618626
619627
620- class Event (Enum ):
621- """Enum representing the type of event that occurred during a dispatch operation."""
622-
623- UNSPECIFIED = StreamMicrogridDispatchesResponse .Event .EVENT_UNSPECIFIED
624- CREATED = StreamMicrogridDispatchesResponse .Event .EVENT_CREATED
625- UPDATED = StreamMicrogridDispatchesResponse .Event .EVENT_UPDATED
626- DELETED = StreamMicrogridDispatchesResponse .Event .EVENT_DELETED
627-
628-
629628@dataclass (kw_only = True , frozen = True )
630629class DispatchEvent :
631630 """Represents an event that occurred during a dispatch operation."""
0 commit comments