v1alpha8
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8 ¤
Conversion of electrical component enums from/to protobuf v1alpha8.
Attributes¤
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.AbstractTypedTypes
module-attribute
¤
Type alias for all abstract electrical component classes that have a type enum.
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.ConcreteTypedTypes
module-attribute
¤
ConcreteTypedTypes: TypeAlias = (
LiIonBattery
| NaIonBattery
| UnspecifiedBattery
| AcEvCharger
| DcEvCharger
| HybridEvCharger
| UnspecifiedEvCharger
| BatteryInverter
| PvInverter
| HybridInverter
| UnspecifiedInverter
)
Type alias for all concrete electrical component classes that have a type enum.
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.ConcreteTypelessTypes
module-attribute
¤
ConcreteTypelessTypes: TypeAlias = (
SpecifiedConcreteTypelessTypes
| UnspecifiedElectricalComponent
)
Type alias for all concrete electrical component classes that don't have a type enum.
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.ConvertibleElectricalComponentTypes
module-attribute
¤
ConvertibleElectricalComponentTypes: TypeAlias = (
ConcreteTypedTypes
| AbstractTypedTypes
| ConcreteTypelessTypes
)
Type alias for all classes that can be converted to protobuf category/subtype pairs.
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.ProtoTypeEnums
module-attribute
¤
ProtoTypeEnums: TypeAlias = (
electrical_components_pb2.BatteryType.ValueType
| electrical_components_pb2.EvChargerType.ValueType
| electrical_components_pb2.InverterType.ValueType
)
Type alias for all protobuf type enums for electrical components.
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.SpecifiedConcreteTypelessTypes
module-attribute
¤
SpecifiedConcreteTypelessTypes: TypeAlias = (
Breaker
| CapacitorBank
| Chp
| Converter
| CryptoMiner
| Electrolyzer
| GridConnectionPoint
| Hvac
| Meter
| Plc
| PowerTransformer
| Precharger
| StaticTransferSwitch
| SteamBoiler
| UninterruptiblePowerSupply
| WindTurbine
)
Type alias for all specified concrete electrical component classes without a type enum.
Functions:¤
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_category_from_proto ¤
electrical_component_category_from_proto(
message: ValueType,
) -> ElectricalComponentCategory | int
Convert a protobuf ElectricalComponentCategory value to an enum member.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ElectricalComponentCategory | int
|
The corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_category.py
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_category_to_proto ¤
electrical_component_category_to_proto(
category: ElectricalComponentCategory,
) -> ValueType
Convert an ElectricalComponentCategory enum member to a protobuf value.
| PARAMETER | DESCRIPTION |
|---|---|
category
|
The
|
| RETURNS | DESCRIPTION |
|---|---|
ValueType
|
The corresponding protobuf |
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_category.py
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_class_from_proto ¤
electrical_component_class_from_proto(
category: ValueType,
subtype: ProtoTypeEnums | None = None,
) -> type[
AbstractTypedTypes
| ConcreteTypedTypes
| ConcreteTypelessTypes
| UnrecognizedBattery
| UnrecognizedEvCharger
| UnrecognizedInverter
| UnrecognizedElectricalComponent
]
Convert a protobuf (category, subtype) pair to an electrical component class.
This is the inverse of
electrical_component_class_to_proto:
every input it can produce round-trips back to the matching class here.
Returns the class only — never an instance — because the protobuf identity
pair does not carry the rest of the component state.
Conversion rules:
(BATTERY, None)→Battery(abstract).(BATTERY, BATTERY_TYPE_UNSPECIFIED)→UnspecifiedBattery.(BATTERY, BATTERY_TYPE_LI_ION)→LiIonBattery.(BATTERY, BATTERY_TYPE_NA_ION)→NaIonBattery.(BATTERY, <unknown subtype int>)→UnrecognizedBattery.(EV_CHARGER, None)→EvCharger(abstract).(EV_CHARGER, EV_CHARGER_TYPE_UNSPECIFIED)→UnspecifiedEvCharger.(EV_CHARGER, EV_CHARGER_TYPE_AC)→AcEvCharger.(EV_CHARGER, EV_CHARGER_TYPE_DC)→DcEvCharger.(EV_CHARGER, EV_CHARGER_TYPE_HYBRID)→HybridEvCharger.(EV_CHARGER, <unknown subtype int>)→UnrecognizedEvCharger.(INVERTER, None)→Inverter(abstract).(INVERTER, INVERTER_TYPE_UNSPECIFIED)→UnspecifiedInverter.(INVERTER, INVERTER_TYPE_BATTERY)→BatteryInverter.(INVERTER, INVERTER_TYPE_PV)→PvInverter.(INVERTER, INVERTER_TYPE_HYBRID)→HybridInverter.(INVERTER, <unknown subtype int>)→UnrecognizedInverter.(UNSPECIFIED, None)→UnspecifiedElectricalComponent.(<any other typeless category>, None)→ its concrete typeless class (Breaker,Meter, ... one per category).(<any known typeless category>, <non-None subtype>)→ raisesValueError.(<unknown category int>, <any subtype>)→UnrecognizedElectricalComponent(subtype silently dropped).
Notes
- For typed categories the abstract base
(
Battery/EvCharger/Inverter) is returned only whensubtype is None; passing the concreteTYPE_UNSPECIFIEDint returns the correspondingUnspecified*class instead. This is the same distinctionelectrical_component_class_to_protomakes on the way out. - For known typeless categories any non-
Nonesubtype is an error because the protobuf wire format has no such combination. - For unknown categories the subtype is silently dropped — the integer category alone is enough to mark the component as unrecognized, and the caller passed the subtype in so they already have it.
| PARAMETER | DESCRIPTION |
|---|---|
category
|
A protobuf electrical component category value.
TYPE:
|
subtype
|
A protobuf subtype value (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
type[AbstractTypedTypes | ConcreteTypedTypes | ConcreteTypelessTypes | UnrecognizedBattery | UnrecognizedEvCharger | UnrecognizedInverter | UnrecognizedElectricalComponent]
|
The corresponding electrical component class. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_electrical_component.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | |
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_class_to_proto ¤
electrical_component_class_to_proto(
component: (
LiIonBattery
| NaIonBattery
| UnspecifiedBattery
| type[
LiIonBattery | NaIonBattery | UnspecifiedBattery
]
),
) -> tuple[ValueType, ValueType]
electrical_component_class_to_proto(
component: UnrecognizedBattery,
) -> tuple[ValueType, int]
electrical_component_class_to_proto(
component: type[Battery],
) -> tuple[ValueType, ValueType | None]
electrical_component_class_to_proto(
component: (
AcEvCharger
| DcEvCharger
| HybridEvCharger
| UnspecifiedEvCharger
| type[
AcEvCharger
| DcEvCharger
| HybridEvCharger
| UnspecifiedEvCharger
]
),
) -> tuple[ValueType, ValueType]
electrical_component_class_to_proto(
component: UnrecognizedEvCharger,
) -> tuple[ValueType, int]
electrical_component_class_to_proto(
component: type[EvCharger],
) -> tuple[ValueType, ValueType | None]
electrical_component_class_to_proto(
component: (
BatteryInverter
| PvInverter
| HybridInverter
| UnspecifiedInverter
| type[
BatteryInverter
| PvInverter
| HybridInverter
| UnspecifiedInverter
]
),
) -> tuple[ValueType, ValueType]
electrical_component_class_to_proto(
component: UnrecognizedInverter,
) -> tuple[ValueType, int]
electrical_component_class_to_proto(
component: type[Inverter],
) -> tuple[ValueType, ValueType | None]
electrical_component_class_to_proto(
component: (
ConcreteTypelessTypes | type[ConcreteTypelessTypes]
),
) -> tuple[ValueType, None]
electrical_component_class_to_proto(
component: UnrecognizedElectricalComponent,
) -> tuple[int, None]
electrical_component_class_to_proto(
component: MismatchedCategoryElectricalComponent,
) -> tuple[int, None]
electrical_component_class_to_proto(
component: (
ElectricalComponentTypes
| type[ConvertibleElectricalComponentTypes]
),
) -> tuple[ValueType | int, ProtoTypeEnums | int | None]
Convert an electrical component class or instance to its protobuf identity.
Returns the (category, subtype) pair the protobuf wire format uses for
the given component. This is the inverse of
electrical_component_class_from_proto
for the classes and abstract bases it knows about.
Conversion rules (C = class, I = instance):
LiIonBattery/NaIonBattery/UnspecifiedBattery(CorI) →(BATTERY, <matching BATTERY_TYPE_*>).UnrecognizedBatteryinstance →(BATTERY, instance.type)— preserves the raw int.AcEvCharger/DcEvCharger/HybridEvCharger/UnspecifiedEvCharger(CorI) →(EV_CHARGER, <matching EV_CHARGER_TYPE_*>).UnrecognizedEvChargerinstance →(EV_CHARGER, instance.type).BatteryInverter/PvInverter/HybridInverter/UnspecifiedInverter(CorI) →(INVERTER, <matching INVERTER_TYPE_*>).UnrecognizedInverterinstance →(INVERTER, instance.type).- The abstract bases
Battery/EvCharger/Inverter(class only) →( <that category>, None). - Any concrete typeless class —
Breaker,CapacitorBank, ...,WindTurbine,GridConnectionPoint,PowerTransformer— (CorI) →( <that category>, None). UnspecifiedElectricalComponent(CorI) →(UNSPECIFIED, None).UnrecognizedElectricalComponentinstance →(instance.category, None)— preserves the raw int.MismatchedCategoryElectricalComponentinstance →(instance.category, None).- The per-family
UnrecognizedBattery/UnrecognizedEvCharger/UnrecognizedInverter(class only) →( <that family's category>, None)(the raw int is unavailable).
Key invariants:
- The abstract typed bases
Battery,EvCharger,Inverterare distinct from theirUnspecified*counterparts on the wire: abstract bases emitsubtype=None, theUnspecified*classes emitsubtype=<...TYPE_UNSPECIFIED>(the concrete protobuf 0 value). This mirrors howelectrical_component_class_from_protoreads them back. Unrecognized*andMismatchedCategoryElectricalComponentare only meaningful as instances because the raw, possibly out-of-range category or subtype int lives on the instance. Passing the per-familyUnrecognizedBattery/UnrecognizedEvCharger/UnrecognizedInverteras classes still succeeds (returning(category, None)), but the raw int is unavailable. Passing the top-levelUnrecognizedElectricalComponentorMismatchedCategoryElectricalComponentas classes raisesTypeErrorbecause no category is recoverable.
Note
Due to the way mypy resolves overloads, passing one of the abstract
typed bases (e.g. Battery) returns the static type
tuple[category, <subtype-enum> | None]: at runtime the subtype is
always None. Callers that already know they are passing an abstract
base usually just discard the subtype.
| PARAMETER | DESCRIPTION |
|---|---|
component
|
An electrical component class or instance to encode.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ValueType | int, ProtoTypeEnums | int | None]
|
The |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_electrical_component.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_connection_from_proto ¤
electrical_component_connection_from_proto(
message: ElectricalComponentConnection,
) -> ElectricalComponentConnectionTypes
Create an electrical component connection from a protobuf message.
A self-referencing connection (same source and destination component) is
returned as a SelfReferencingElectricalComponentConnection, which surfaces
that malformed state at the type level.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert. |
| RETURNS | DESCRIPTION |
|---|---|
ElectricalComponentConnectionTypes
|
One of the concrete connection types. |
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_electrical_component_connection.py
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_diagnostic_code_from_proto ¤
electrical_component_diagnostic_code_from_proto(
message: ValueType,
) -> ElectricalComponentDiagnosticCode | int
Convert a protobuf ElectricalComponentDiagnosticCode value to an enum member.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ElectricalComponentDiagnosticCode | int
|
The corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_diagnostic_code.py
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_diagnostic_code_to_proto ¤
electrical_component_diagnostic_code_to_proto(
diagnostic_code: ElectricalComponentDiagnosticCode,
) -> ValueType
Convert an ElectricalComponentDiagnosticCode enum member to a protobuf value.
| PARAMETER | DESCRIPTION |
|---|---|
diagnostic_code
|
The
|
| RETURNS | DESCRIPTION |
|---|---|
ValueType
|
The corresponding protobuf |
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_diagnostic_code.py
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_from_proto ¤
electrical_component_from_proto(
message: ElectricalComponent,
) -> ElectricalComponentTypes
Convert a protobuf message to an electrical component instance.
Malformed or forward-incompatible input is surfaced through the returned
type rather than a side channel: an unspecified category yields an
UnspecifiedElectricalComponent, an unrecognized one an
UnrecognizedElectricalComponent, a category that disagrees with its
carried info a MismatchedCategoryElectricalComponent, and an unspecified
or unrecognized battery, EV charger or inverter type the matching
Unrecognized* class (which preserves the raw wire type).
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ElectricalComponentTypes
|
The resulting electrical component instance. |
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_electrical_component.py
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 | |
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_state_code_from_proto ¤
electrical_component_state_code_from_proto(
message: ValueType,
) -> ElectricalComponentStateCode | int
Convert a protobuf ElectricalComponentStateCode value to an enum member.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ElectricalComponentStateCode | int
|
The corresponding
|
Source code in src/frequenz/client/common/microgrid/electrical_components/proto/v1alpha8/_state_code.py
frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_state_code_to_proto ¤
electrical_component_state_code_to_proto(
state_code: ElectricalComponentStateCode,
) -> ValueType
Convert an ElectricalComponentStateCode enum member to a protobuf value.
| PARAMETER | DESCRIPTION |
|---|---|
state_code
|
The
|
| RETURNS | DESCRIPTION |
|---|---|
ValueType
|
The corresponding protobuf |