-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
- Loading branch information
Showing
5 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# License: MIT | ||
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH | ||
|
||
"""Common code and utilities for Frequenz API clients.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# License: MIT | ||
# Copyright © 2023 Frequenz Energy-as-a-Service GmbH | ||
|
||
"""Common code and utilities for Frequenz API clients.""" |
74 changes: 74 additions & 0 deletions
74
src/frequenz/client/common/microgrid/components/components.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# License: MIT | ||
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH | ||
|
||
"""Defines the components that can be used in a microgrid.""" | ||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
|
||
# pylint: disable=no-name-in-module | ||
from frequenz.api.common.v1.microgrid.components.components_pb2 import ( | ||
ComponentCategory as PBComponentCategory, | ||
) | ||
|
||
# pylint: enable=no-name-in-module | ||
|
||
|
||
class ComponentCategory(Enum): | ||
"""Possible types of microgrid component.""" | ||
|
||
NONE = PBComponentCategory.COMPONENT_CATEGORY_UNSPECIFIED | ||
"""Unspecified component category.""" | ||
|
||
GRID = PBComponentCategory.COMPONENT_CATEGORY_GRID | ||
"""Grid component.""" | ||
|
||
METER = PBComponentCategory.COMPONENT_CATEGORY_METER | ||
"""Meter component.""" | ||
|
||
INVERTER = PBComponentCategory.COMPONENT_CATEGORY_INVERTER | ||
"""Inverter component.""" | ||
|
||
BATTERY = PBComponentCategory.COMPONENT_CATEGORY_BATTERY | ||
"""Battery component.""" | ||
|
||
EV_CHARGER = PBComponentCategory.COMPONENT_CATEGORY_EV_CHARGER | ||
"""EV charger component.""" | ||
|
||
CHP = PBComponentCategory.COMPONENT_CATEGORY_CHP | ||
"""CHP component.""" | ||
|
||
|
||
def _component_category_from_protobuf( | ||
component_category: PBComponentCategory.ValueType, | ||
) -> ComponentCategory: | ||
"""Convert a protobuf ComponentCategory message to ComponentCategory enum. | ||
For internal-only use by the `microgrid` package. | ||
Args: | ||
component_category: protobuf enum to convert | ||
Returns: | ||
Enum value corresponding to the protobuf message. | ||
""" | ||
if not any(t.value == component_category for t in ComponentCategory): | ||
return ComponentCategory.NONE | ||
|
||
return ComponentCategory(component_category) | ||
|
||
|
||
def _component_category_to_protobuf( | ||
component_category: ComponentCategory, | ||
) -> PBComponentCategory.ValueType: | ||
"""Convert a ComponentCategory enum to protobuf ComponentCategory message. | ||
For internal-only use by the `microgrid` package. | ||
Args: | ||
component_category: enum to convert | ||
Returns: | ||
Enum value corresponding to the protobuf message. | ||
""" | ||
return component_category.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters