Skip to content

Index

frequenz.client.common.microgrid.electrical_components ¤

Defines the electrical components that can be used in a microgrid.

Classes¤

frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory ¤

Bases: Enum

Possible types of microgrid electrical component.

Source code in src/frequenz/client/common/microgrid/electrical_components/_category.py
@enum.unique
class ElectricalComponentCategory(enum.Enum):
    """Possible types of microgrid electrical component."""

    UNSPECIFIED = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_UNSPECIFIED
    """An unknown component category.

    Useful for error handling, and marking unknown components in
    a list of components with otherwise known categories.
    """

    GRID_CONNECTION_POINT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_GRID_CONNECTION_POINT
    )
    """The point where the local microgrid is connected to the grid."""

    METER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_METER
    """A meter, for measuring electrical metrics, e.g., current, voltage, etc."""

    INVERTER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_INVERTER
    """An electricity generator, with batteries or solar energy."""

    CONVERTER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CONVERTER
    """An electricity converter, e.g., a DC-DC converter."""

    BATTERY = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_BATTERY
    """A storage system for electrical energy, used by inverters."""

    EV_CHARGER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_EV_CHARGER
    """A station for charging electrical vehicles."""

    CRYPTO_MINER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CRYPTO_MINER
    """A device for mining cryptocurrencies."""

    ELECTROLYZER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_ELECTROLYZER
    """A device for splitting water into hydrogen and oxygen using electricity."""

    CHP = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CHP
    """A heat and power combustion plant (CHP stands for combined heat and power)."""

    BREAKER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_BREAKER
    """A relay, used for switching electrical circuits on and off."""

    PRECHARGER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_PRECHARGER
    """A precharger, used for preparing electrical circuits for switching on."""

    POWER_TRANSFORMER = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER
    )
    """A transformer, used for changing the voltage of electrical circuits."""

    HVAC = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_HVAC
    """A heating, ventilation, and air conditioning (HVAC) system."""

    PLC = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_PLC
    """A programmable logic controller (PLC)."""

    STATIC_TRANSFER_SWITCH = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_STATIC_TRANSFER_SWITCH
    )
    """A static transfer switch, used for switching between power sources."""

    UNINTERRUPTIBLE_POWER_SUPPLY = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_UNINTERRUPTIBLE_POWER_SUPPLY
    )
    """An uninterruptible power supply (UPS), used to provide backup power."""

    CAPACITOR_BANK = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_CAPACITOR_BANK
    )
    """A capacitor bank, used for power factor correction and reactive power compensation."""

    WIND_TURBINE = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_WIND_TURBINE
    """A wind turbine, used to generate electricity from wind energy."""

    STEAM_BOILER = electrical_components_pb2.ELECTRICAL_COMPONENT_CATEGORY_STEAM_BOILER
    """A steam boiler, used to generate steam for heating or industrial processes."""

    @classmethod
    @deprecated(
        "frequenz.client.common.microgrid.electrical_components."
        "ElectricalComponentCategory.from_proto() is deprecated. "
        "Use frequenz.client.common.microgrid.electrical_components.proto."
        "v1alpha8.electrical_component_category_from_proto instead."
    )
    def from_proto(
        cls, component_category: PBElectricalComponentCategory.ValueType
    ) -> ElectricalComponentCategory:
        """Convert a protobuf ElectricalComponentCategory message to enum.

        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 ElectricalComponentCategory):
            return ElectricalComponentCategory.UNSPECIFIED
        return cls(component_category)

    @deprecated(
        "frequenz.client.common.microgrid.electrical_components."
        "ElectricalComponentCategory.to_proto() is deprecated. "
        "Use frequenz.client.common.microgrid.electrical_components.proto."
        "v1alpha8.electrical_component_category_to_proto instead."
    )
    def to_proto(self) -> PBElectricalComponentCategory.ValueType:
        """Convert a ElectricalComponentCategory enum to protobuf message.

        Returns:
            Enum value corresponding to the protobuf message.
        """
        return PBElectricalComponentCategory.ValueType(self.value)
Attributes¤
BATTERY class-attribute instance-attribute ¤
BATTERY = ELECTRICAL_COMPONENT_CATEGORY_BATTERY

A storage system for electrical energy, used by inverters.

BREAKER class-attribute instance-attribute ¤
BREAKER = ELECTRICAL_COMPONENT_CATEGORY_BREAKER

A relay, used for switching electrical circuits on and off.

CAPACITOR_BANK class-attribute instance-attribute ¤
CAPACITOR_BANK = (
    ELECTRICAL_COMPONENT_CATEGORY_CAPACITOR_BANK
)

A capacitor bank, used for power factor correction and reactive power compensation.

CHP class-attribute instance-attribute ¤
CHP = ELECTRICAL_COMPONENT_CATEGORY_CHP

A heat and power combustion plant (CHP stands for combined heat and power).

CONVERTER class-attribute instance-attribute ¤
CONVERTER = ELECTRICAL_COMPONENT_CATEGORY_CONVERTER

An electricity converter, e.g., a DC-DC converter.

CRYPTO_MINER class-attribute instance-attribute ¤
CRYPTO_MINER = ELECTRICAL_COMPONENT_CATEGORY_CRYPTO_MINER

A device for mining cryptocurrencies.

ELECTROLYZER class-attribute instance-attribute ¤
ELECTROLYZER = ELECTRICAL_COMPONENT_CATEGORY_ELECTROLYZER

A device for splitting water into hydrogen and oxygen using electricity.

EV_CHARGER class-attribute instance-attribute ¤
EV_CHARGER = ELECTRICAL_COMPONENT_CATEGORY_EV_CHARGER

A station for charging electrical vehicles.

GRID_CONNECTION_POINT class-attribute instance-attribute ¤
GRID_CONNECTION_POINT = (
    ELECTRICAL_COMPONENT_CATEGORY_GRID_CONNECTION_POINT
)

The point where the local microgrid is connected to the grid.

HVAC class-attribute instance-attribute ¤
HVAC = ELECTRICAL_COMPONENT_CATEGORY_HVAC

A heating, ventilation, and air conditioning (HVAC) system.

INVERTER class-attribute instance-attribute ¤
INVERTER = ELECTRICAL_COMPONENT_CATEGORY_INVERTER

An electricity generator, with batteries or solar energy.

METER class-attribute instance-attribute ¤
METER = ELECTRICAL_COMPONENT_CATEGORY_METER

A meter, for measuring electrical metrics, e.g., current, voltage, etc.

PLC class-attribute instance-attribute ¤
PLC = ELECTRICAL_COMPONENT_CATEGORY_PLC

A programmable logic controller (PLC).

POWER_TRANSFORMER class-attribute instance-attribute ¤
POWER_TRANSFORMER = (
    ELECTRICAL_COMPONENT_CATEGORY_POWER_TRANSFORMER
)

A transformer, used for changing the voltage of electrical circuits.

PRECHARGER class-attribute instance-attribute ¤
PRECHARGER = ELECTRICAL_COMPONENT_CATEGORY_PRECHARGER

A precharger, used for preparing electrical circuits for switching on.

STATIC_TRANSFER_SWITCH class-attribute instance-attribute ¤
STATIC_TRANSFER_SWITCH = (
    ELECTRICAL_COMPONENT_CATEGORY_STATIC_TRANSFER_SWITCH
)

A static transfer switch, used for switching between power sources.

STEAM_BOILER class-attribute instance-attribute ¤
STEAM_BOILER = ELECTRICAL_COMPONENT_CATEGORY_STEAM_BOILER

A steam boiler, used to generate steam for heating or industrial processes.

UNINTERRUPTIBLE_POWER_SUPPLY class-attribute instance-attribute ¤
UNINTERRUPTIBLE_POWER_SUPPLY = ELECTRICAL_COMPONENT_CATEGORY_UNINTERRUPTIBLE_POWER_SUPPLY

An uninterruptible power supply (UPS), used to provide backup power.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = ELECTRICAL_COMPONENT_CATEGORY_UNSPECIFIED

An unknown component category.

Useful for error handling, and marking unknown components in a list of components with otherwise known categories.

WIND_TURBINE class-attribute instance-attribute ¤
WIND_TURBINE = ELECTRICAL_COMPONENT_CATEGORY_WIND_TURBINE

A wind turbine, used to generate electricity from wind energy.

Functions¤
from_proto classmethod ¤
from_proto(
    component_category: ValueType,
) -> ElectricalComponentCategory

Convert a protobuf ElectricalComponentCategory message to enum.

PARAMETER DESCRIPTION
component_category

protobuf enum to convert

TYPE: ValueType

RETURNS DESCRIPTION
ElectricalComponentCategory

Enum value corresponding to the protobuf message.

Source code in src/frequenz/client/common/microgrid/electrical_components/_category.py
@classmethod
@deprecated(
    "frequenz.client.common.microgrid.electrical_components."
    "ElectricalComponentCategory.from_proto() is deprecated. "
    "Use frequenz.client.common.microgrid.electrical_components.proto."
    "v1alpha8.electrical_component_category_from_proto instead."
)
def from_proto(
    cls, component_category: PBElectricalComponentCategory.ValueType
) -> ElectricalComponentCategory:
    """Convert a protobuf ElectricalComponentCategory message to enum.

    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 ElectricalComponentCategory):
        return ElectricalComponentCategory.UNSPECIFIED
    return cls(component_category)
to_proto ¤
to_proto() -> ValueType

Convert a ElectricalComponentCategory enum to protobuf message.

RETURNS DESCRIPTION
ValueType

Enum value corresponding to the protobuf message.

Source code in src/frequenz/client/common/microgrid/electrical_components/_category.py
@deprecated(
    "frequenz.client.common.microgrid.electrical_components."
    "ElectricalComponentCategory.to_proto() is deprecated. "
    "Use frequenz.client.common.microgrid.electrical_components.proto."
    "v1alpha8.electrical_component_category_to_proto instead."
)
def to_proto(self) -> PBElectricalComponentCategory.ValueType:
    """Convert a ElectricalComponentCategory enum to protobuf message.

    Returns:
        Enum value corresponding to the protobuf message.
    """
    return PBElectricalComponentCategory.ValueType(self.value)

frequenz.client.common.microgrid.electrical_components.ElectricalComponentDiagnosticCode ¤

Bases: Enum

All diagnostics that can occur across electrical component categories.

Source code in src/frequenz/client/common/microgrid/electrical_components/_diagnostic_code.py
@enum.unique
class ElectricalComponentDiagnosticCode(enum.Enum):
    """All diagnostics that can occur across electrical component categories."""

    UNSPECIFIED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNSPECIFIED
    )
    """Default value. No specific error is specified."""

    UNKNOWN = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNKNOWN
    """The component is reporting an unknown or an undefined error.

    The sender cannot parse the component error to any of the variants below.
    """

    SWITCH_ON_FAULT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SWITCH_ON_FAULT
    )
    """The component could not be switched on."""

    UNDERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERVOLTAGE
    )
    """The component is operating under the minimum rated voltage."""

    OVERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERVOLTAGE
    )
    """The component is operating over the maximum rated voltage."""

    OVERCURRENT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT
    )
    """The component is drawing more current than the maximum rated value."""

    OVERCURRENT_CHARGING = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_CHARGING
    )
    """The component's consumption current is over the maximum rated value during charging."""

    OVERCURRENT_DISCHARGING = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_DISCHARGING
    )
    """The component's production current is over the maximum rated value during discharging."""

    OVERTEMPERATURE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERTEMPERATURE
    )
    """The component is operating over the maximum rated temperature."""

    UNDERTEMPERATURE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERTEMPERATURE
    )
    """The component is operating under the minimum rated temperature."""

    HIGH_HUMIDITY = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HIGH_HUMIDITY
    )
    """The component is exposed to high humidity levels over the maximum rated value."""

    FUSE_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FUSE_ERROR
    )
    """The component's fuse has blown."""

    PRECHARGE_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PRECHARGE_ERROR
    )
    """The component's precharge unit has failed."""

    PLAUSIBILITY_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PLAUSIBILITY_ERROR
    )
    """Plausibility issues within the system involving this component."""

    EV_UNEXPECTED_PILOT_FAILURE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_UNEXPECTED_PILOT_FAILURE
    )
    """Unexpected pilot failure in an electric vehicle (EV) component."""

    FAULT_CURRENT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FAULT_CURRENT
    )
    """Fault current detected in the component."""

    SHORT_CIRCUIT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SHORT_CIRCUIT
    )
    """Short circuit detected in the component."""

    CONFIG_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_CONFIG_ERROR
    )
    """Configuration error related to the component."""

    ILLEGAL_COMPONENT_STATE_CODE_REQUESTED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_ILLEGAL_COMPONENT_STATE_CODE_REQUESTED  # noqa: E501
    )
    """An illegal state was requested for the component."""

    HARDWARE_INACCESSIBLE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HARDWARE_INACCESSIBLE
    )
    """The hardware of the component is inaccessible."""

    INTERNAL = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INTERNAL
    """An internal error within the component."""

    UNAUTHORIZED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNAUTHORIZED
    )
    """The component is unauthorized to perform the last requested action."""

    EXCESS_LEAKAGE_CURRENT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EXCESS_LEAKAGE_CURRENT
    )
    """Excess leakage current was detected in the component."""

    LOW_SYSTEM_INSULATION_RESISTANCE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_LOW_SYSTEM_INSULATION_RESISTANCE  # noqa: E501
    )
    """Low system insulation resistance detected in the component."""

    GROUND_FAULT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GROUND_FAULT
    )
    """Ground fault detected in the component."""

    ARC_FAULT = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_ARC_FAULT
    """Arc fault detected in the component."""

    FAN_FAULT = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FAN_FAULT
    """Fan fault detected in the component."""

    HARDWARE_FAULT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HARDWARE_FAULT
    )
    """Hardware fault detected in the component."""

    PROTECTIVE_SHUTDOWN = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PROTECTIVE_SHUTDOWN
    )
    """The component performed a protective shutdown."""

    GRID_OVERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_OVERVOLTAGE
    )
    """The grid voltage is over the maximum rated value."""

    GRID_UNDERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_UNDERVOLTAGE
    )
    """The grid voltage is under the minimum rated value."""

    GRID_OVERFREQUENCY = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_OVERFREQUENCY
    )
    """The grid frequency is over the maximum rated value."""

    GRID_UNDERFREQUENCY = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_UNDERFREQUENCY
    )
    """The grid frequency is under the minimum rated value."""

    GRID_DISCONNECTED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_DISCONNECTED
    )
    """The grid is disconnected."""

    GRID_VOLTAGE_IMBALANCE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_VOLTAGE_IMBALANCE
    )
    """Voltage imbalance between grid phases."""

    GRID_ABNORMAL = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_ABNORMAL
    )
    """The grid is in an abnormal condition not covered by other grid-specific diagnostic codes."""

    EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION  # noqa: E501
    )
    """Electric vehicle (EV) cable was abruptly unplugged from the charging station."""

    EV_CHARGING_CABLE_UNPLUGGED_FROM_EV = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_EV  # noqa: E501
    )
    """Electric vehicle (EV) cable was abruptly unplugged from the vehicle."""

    EV_CHARGING_CABLE_LOCK_FAILED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_LOCK_FAILED
    )
    """Electric vehicle (EV) cable lock failure."""

    EV_CHARGING_CABLE_INVALID = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_INVALID
    )
    """Invalid electric vehicle (EV) cable."""

    EV_CONSUMER_INCOMPATIBLE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CONSUMER_INCOMPATIBLE
    )
    """Incompatible electric vehicle (EV) plug."""

    BATTERY_IMBALANCE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_IMBALANCE
    )
    """Battery system imbalance detected."""

    BATTERY_LOW_SOH = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_LOW_SOH
    )
    """Low state of health (SOH) detected in the battery."""

    BATTERY_BLOCK_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_BLOCK_ERROR
    )
    """Battery block error detected."""

    BATTERY_CONTROLLER_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CONTROLLER_ERROR
    )
    """Battery controller error detected."""

    BATTERY_RELAY_ERROR = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_RELAY_ERROR
    )
    """Battery relay error detected."""

    BATTERY_CALIBRATION_NEEDED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CALIBRATION_NEEDED
    )
    """Battery calibration is needed."""

    RELAY_CYCLE_LIMIT_REACHED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_RELAY_CYCLE_LIMIT_REACHED
    )
    """The relays have been cycled for the maximum number of times."""

    PV_REVERSAL_POLARITY = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_REVERSAL_POLARITY
    )
    """Reverse polarity condition detected on the photovoltaic (PV) side."""

    PV_UNDERPERFORMANCE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_UNDERPERFORMANCE
    )
    """The photovoltaic (PV) system is underperforming."""

    PV_FAULT = electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_FAULT
    """Fault in the photovoltaic (PV) system."""

    PV_REVERSE_CURRENT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_REVERSE_CURRENT
    )
    """Reverse current condition detected on the photovoltaic (PV) side."""

    PV_GROUND_FAULT = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_GROUND_FAULT
    )
    """Ground fault detected on the photovoltaic (PV) side."""

    INVERTER_DC_UNDERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INVERTER_DC_UNDERVOLTAGE
    )
    """The inverter DC bus voltage is under the minimum rated value."""

    INVERTER_DC_OVERVOLTAGE = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INVERTER_DC_OVERVOLTAGE
    )
    """The inverter DC bus voltage is over the maximum rated value."""

    @classmethod
    @deprecated(
        "frequenz.client.common.microgrid.electrical_components."
        "ElectricalComponentDiagnosticCode.from_proto() is deprecated. "
        "Use frequenz.client.common.microgrid.electrical_components.proto."
        "v1alpha8.electrical_component_diagnostic_code_from_proto instead."
    )
    def from_proto(
        cls, component_error_code: PBElectricalComponentDiagnosticCode.ValueType
    ) -> ElectricalComponentDiagnosticCode:
        """Convert a protobuf ElectricalComponentDiagnosticCode message to enum.

        Args:
            component_error_code: protobuf enum to convert

        Returns:
            Enum value corresponding to the protobuf message.
        """
        if not any(
            c.value == component_error_code for c in ElectricalComponentDiagnosticCode
        ):
            return ElectricalComponentDiagnosticCode.UNSPECIFIED
        return cls(component_error_code)

    @deprecated(
        "frequenz.client.common.microgrid.electrical_components."
        "ElectricalComponentDiagnosticCode.to_proto() is deprecated. "
        "Use frequenz.client.common.microgrid.electrical_components.proto."
        "v1alpha8.electrical_component_diagnostic_code_to_proto instead."
    )
    def to_proto(self) -> PBElectricalComponentDiagnosticCode.ValueType:
        """Convert a ElectricalComponentDiagnosticCode enum to protobuf message.

        Returns:
            Enum value corresponding to the protobuf message.
        """
        return PBElectricalComponentDiagnosticCode.ValueType(self.value)
Attributes¤
ARC_FAULT class-attribute instance-attribute ¤
ARC_FAULT = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_ARC_FAULT

Arc fault detected in the component.

BATTERY_BLOCK_ERROR class-attribute instance-attribute ¤
BATTERY_BLOCK_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_BLOCK_ERROR
)

Battery block error detected.

BATTERY_CALIBRATION_NEEDED class-attribute instance-attribute ¤
BATTERY_CALIBRATION_NEEDED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CALIBRATION_NEEDED

Battery calibration is needed.

BATTERY_CONTROLLER_ERROR class-attribute instance-attribute ¤
BATTERY_CONTROLLER_ERROR = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_CONTROLLER_ERROR

Battery controller error detected.

BATTERY_IMBALANCE class-attribute instance-attribute ¤
BATTERY_IMBALANCE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_IMBALANCE
)

Battery system imbalance detected.

BATTERY_LOW_SOH class-attribute instance-attribute ¤
BATTERY_LOW_SOH = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_LOW_SOH
)

Low state of health (SOH) detected in the battery.

BATTERY_RELAY_ERROR class-attribute instance-attribute ¤
BATTERY_RELAY_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_BATTERY_RELAY_ERROR
)

Battery relay error detected.

CONFIG_ERROR class-attribute instance-attribute ¤
CONFIG_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_CONFIG_ERROR
)

Configuration error related to the component.

EV_CHARGING_CABLE_INVALID class-attribute instance-attribute ¤
EV_CHARGING_CABLE_INVALID = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_INVALID

Invalid electric vehicle (EV) cable.

EV_CHARGING_CABLE_LOCK_FAILED class-attribute instance-attribute ¤
EV_CHARGING_CABLE_LOCK_FAILED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_LOCK_FAILED

Electric vehicle (EV) cable lock failure.

EV_CHARGING_CABLE_UNPLUGGED_FROM_EV class-attribute instance-attribute ¤
EV_CHARGING_CABLE_UNPLUGGED_FROM_EV = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_EV

Electric vehicle (EV) cable was abruptly unplugged from the vehicle.

EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION class-attribute instance-attribute ¤
EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CHARGING_CABLE_UNPLUGGED_FROM_STATION

Electric vehicle (EV) cable was abruptly unplugged from the charging station.

EV_CONSUMER_INCOMPATIBLE class-attribute instance-attribute ¤
EV_CONSUMER_INCOMPATIBLE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_CONSUMER_INCOMPATIBLE

Incompatible electric vehicle (EV) plug.

EV_UNEXPECTED_PILOT_FAILURE class-attribute instance-attribute ¤
EV_UNEXPECTED_PILOT_FAILURE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EV_UNEXPECTED_PILOT_FAILURE

Unexpected pilot failure in an electric vehicle (EV) component.

EXCESS_LEAKAGE_CURRENT class-attribute instance-attribute ¤
EXCESS_LEAKAGE_CURRENT = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_EXCESS_LEAKAGE_CURRENT

Excess leakage current was detected in the component.

FAN_FAULT class-attribute instance-attribute ¤
FAN_FAULT = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FAN_FAULT

Fan fault detected in the component.

FAULT_CURRENT class-attribute instance-attribute ¤
FAULT_CURRENT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FAULT_CURRENT
)

Fault current detected in the component.

FUSE_ERROR class-attribute instance-attribute ¤
FUSE_ERROR = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_FUSE_ERROR

The component's fuse has blown.

GRID_ABNORMAL class-attribute instance-attribute ¤
GRID_ABNORMAL = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_ABNORMAL
)

The grid is in an abnormal condition not covered by other grid-specific diagnostic codes.

GRID_DISCONNECTED class-attribute instance-attribute ¤
GRID_DISCONNECTED = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_DISCONNECTED
)

The grid is disconnected.

GRID_OVERFREQUENCY class-attribute instance-attribute ¤
GRID_OVERFREQUENCY = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_OVERFREQUENCY
)

The grid frequency is over the maximum rated value.

GRID_OVERVOLTAGE class-attribute instance-attribute ¤
GRID_OVERVOLTAGE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_OVERVOLTAGE
)

The grid voltage is over the maximum rated value.

GRID_UNDERFREQUENCY class-attribute instance-attribute ¤
GRID_UNDERFREQUENCY = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_UNDERFREQUENCY
)

The grid frequency is under the minimum rated value.

GRID_UNDERVOLTAGE class-attribute instance-attribute ¤
GRID_UNDERVOLTAGE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_UNDERVOLTAGE
)

The grid voltage is under the minimum rated value.

GRID_VOLTAGE_IMBALANCE class-attribute instance-attribute ¤
GRID_VOLTAGE_IMBALANCE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GRID_VOLTAGE_IMBALANCE

Voltage imbalance between grid phases.

GROUND_FAULT class-attribute instance-attribute ¤
GROUND_FAULT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_GROUND_FAULT
)

Ground fault detected in the component.

HARDWARE_FAULT class-attribute instance-attribute ¤
HARDWARE_FAULT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HARDWARE_FAULT
)

Hardware fault detected in the component.

HARDWARE_INACCESSIBLE class-attribute instance-attribute ¤
HARDWARE_INACCESSIBLE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HARDWARE_INACCESSIBLE

The hardware of the component is inaccessible.

HIGH_HUMIDITY class-attribute instance-attribute ¤
HIGH_HUMIDITY = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_HIGH_HUMIDITY
)

The component is exposed to high humidity levels over the maximum rated value.

ILLEGAL_COMPONENT_STATE_CODE_REQUESTED class-attribute instance-attribute ¤
ILLEGAL_COMPONENT_STATE_CODE_REQUESTED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_ILLEGAL_COMPONENT_STATE_CODE_REQUESTED

An illegal state was requested for the component.

INTERNAL class-attribute instance-attribute ¤
INTERNAL = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INTERNAL

An internal error within the component.

INVERTER_DC_OVERVOLTAGE class-attribute instance-attribute ¤
INVERTER_DC_OVERVOLTAGE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INVERTER_DC_OVERVOLTAGE

The inverter DC bus voltage is over the maximum rated value.

INVERTER_DC_UNDERVOLTAGE class-attribute instance-attribute ¤
INVERTER_DC_UNDERVOLTAGE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_INVERTER_DC_UNDERVOLTAGE

The inverter DC bus voltage is under the minimum rated value.

LOW_SYSTEM_INSULATION_RESISTANCE class-attribute instance-attribute ¤
LOW_SYSTEM_INSULATION_RESISTANCE = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_LOW_SYSTEM_INSULATION_RESISTANCE

Low system insulation resistance detected in the component.

OVERCURRENT class-attribute instance-attribute ¤
OVERCURRENT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT
)

The component is drawing more current than the maximum rated value.

OVERCURRENT_CHARGING class-attribute instance-attribute ¤
OVERCURRENT_CHARGING = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_CHARGING

The component's consumption current is over the maximum rated value during charging.

OVERCURRENT_DISCHARGING class-attribute instance-attribute ¤
OVERCURRENT_DISCHARGING = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERCURRENT_DISCHARGING

The component's production current is over the maximum rated value during discharging.

OVERTEMPERATURE class-attribute instance-attribute ¤
OVERTEMPERATURE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERTEMPERATURE
)

The component is operating over the maximum rated temperature.

OVERVOLTAGE class-attribute instance-attribute ¤
OVERVOLTAGE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_OVERVOLTAGE
)

The component is operating over the maximum rated voltage.

PLAUSIBILITY_ERROR class-attribute instance-attribute ¤
PLAUSIBILITY_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PLAUSIBILITY_ERROR
)

Plausibility issues within the system involving this component.

PRECHARGE_ERROR class-attribute instance-attribute ¤
PRECHARGE_ERROR = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PRECHARGE_ERROR
)

The component's precharge unit has failed.

PROTECTIVE_SHUTDOWN class-attribute instance-attribute ¤
PROTECTIVE_SHUTDOWN = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PROTECTIVE_SHUTDOWN
)

The component performed a protective shutdown.

PV_FAULT class-attribute instance-attribute ¤
PV_FAULT = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_FAULT

Fault in the photovoltaic (PV) system.

PV_GROUND_FAULT class-attribute instance-attribute ¤
PV_GROUND_FAULT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_GROUND_FAULT
)

Ground fault detected on the photovoltaic (PV) side.

PV_REVERSAL_POLARITY class-attribute instance-attribute ¤
PV_REVERSAL_POLARITY = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_REVERSAL_POLARITY

Reverse polarity condition detected on the photovoltaic (PV) side.

PV_REVERSE_CURRENT class-attribute instance-attribute ¤
PV_REVERSE_CURRENT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_REVERSE_CURRENT
)

Reverse current condition detected on the photovoltaic (PV) side.

PV_UNDERPERFORMANCE class-attribute instance-attribute ¤
PV_UNDERPERFORMANCE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_PV_UNDERPERFORMANCE
)

The photovoltaic (PV) system is underperforming.

RELAY_CYCLE_LIMIT_REACHED class-attribute instance-attribute ¤
RELAY_CYCLE_LIMIT_REACHED = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_RELAY_CYCLE_LIMIT_REACHED

The relays have been cycled for the maximum number of times.

SHORT_CIRCUIT class-attribute instance-attribute ¤
SHORT_CIRCUIT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SHORT_CIRCUIT
)

Short circuit detected in the component.

SWITCH_ON_FAULT class-attribute instance-attribute ¤
SWITCH_ON_FAULT = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_SWITCH_ON_FAULT
)

The component could not be switched on.

UNAUTHORIZED class-attribute instance-attribute ¤
UNAUTHORIZED = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNAUTHORIZED
)

The component is unauthorized to perform the last requested action.

UNDERTEMPERATURE class-attribute instance-attribute ¤
UNDERTEMPERATURE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERTEMPERATURE
)

The component is operating under the minimum rated temperature.

UNDERVOLTAGE class-attribute instance-attribute ¤
UNDERVOLTAGE = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNDERVOLTAGE
)

The component is operating under the minimum rated voltage.

UNKNOWN class-attribute instance-attribute ¤
UNKNOWN = ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNKNOWN

The component is reporting an unknown or an undefined error.

The sender cannot parse the component error to any of the variants below.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = (
    ELECTRICAL_COMPONENT_DIAGNOSTIC_CODE_UNSPECIFIED
)

Default value. No specific error is specified.

Functions¤
from_proto classmethod ¤
from_proto(
    component_error_code: ValueType,
) -> ElectricalComponentDiagnosticCode

Convert a protobuf ElectricalComponentDiagnosticCode message to enum.

PARAMETER DESCRIPTION
component_error_code

protobuf enum to convert

TYPE: ValueType

RETURNS DESCRIPTION
ElectricalComponentDiagnosticCode

Enum value corresponding to the protobuf message.

Source code in src/frequenz/client/common/microgrid/electrical_components/_diagnostic_code.py
@classmethod
@deprecated(
    "frequenz.client.common.microgrid.electrical_components."
    "ElectricalComponentDiagnosticCode.from_proto() is deprecated. "
    "Use frequenz.client.common.microgrid.electrical_components.proto."
    "v1alpha8.electrical_component_diagnostic_code_from_proto instead."
)
def from_proto(
    cls, component_error_code: PBElectricalComponentDiagnosticCode.ValueType
) -> ElectricalComponentDiagnosticCode:
    """Convert a protobuf ElectricalComponentDiagnosticCode message to enum.

    Args:
        component_error_code: protobuf enum to convert

    Returns:
        Enum value corresponding to the protobuf message.
    """
    if not any(
        c.value == component_error_code for c in ElectricalComponentDiagnosticCode
    ):
        return ElectricalComponentDiagnosticCode.UNSPECIFIED
    return cls(component_error_code)
to_proto ¤
to_proto() -> ValueType

Convert a ElectricalComponentDiagnosticCode enum to protobuf message.

RETURNS DESCRIPTION
ValueType

Enum value corresponding to the protobuf message.

Source code in src/frequenz/client/common/microgrid/electrical_components/_diagnostic_code.py
@deprecated(
    "frequenz.client.common.microgrid.electrical_components."
    "ElectricalComponentDiagnosticCode.to_proto() is deprecated. "
    "Use frequenz.client.common.microgrid.electrical_components.proto."
    "v1alpha8.electrical_component_diagnostic_code_to_proto instead."
)
def to_proto(self) -> PBElectricalComponentDiagnosticCode.ValueType:
    """Convert a ElectricalComponentDiagnosticCode enum to protobuf message.

    Returns:
        Enum value corresponding to the protobuf message.
    """
    return PBElectricalComponentDiagnosticCode.ValueType(self.value)

frequenz.client.common.microgrid.electrical_components.ElectricalComponentId ¤

Bases: BaseId

A unique identifier for a microgrid electrical component.

Source code in src/frequenz/client/common/microgrid/electrical_components/_ids.py
@final
class ElectricalComponentId(BaseId, str_prefix="CID"):
    """A unique identifier for a microgrid electrical component."""
Attributes¤
str_prefix property ¤
str_prefix: str

The prefix used for the string representation of this ID.

Functions¤
__eq__ ¤
__eq__(other: object) -> bool

Check if this instance is equal to another object.

Equality is defined as being of the exact same type and having the same underlying ID.

Source code in frequenz/core/id.py
def __eq__(self, other: object) -> bool:
    """Check if this instance is equal to another object.

    Equality is defined as being of the exact same type and having the same
    underlying ID.
    """
    # pylint thinks this is not an unidiomatic typecheck, but in this case
    # it is not. isinstance() returns True for subclasses, which is not
    # what we want here, as different ID types should never be equal.
    # pylint: disable-next=unidiomatic-typecheck
    if type(other) is not type(self):
        return NotImplemented
    # We already checked type(other) is type(self), but mypy doesn't
    # understand that, so we need to cast it to Self.
    other_id = cast(Self, other)
    return self._id == other_id._id
__hash__ ¤
__hash__() -> int

Return the hash of this instance.

The hash is based on the exact type and the underlying ID to ensure that IDs of different types but with the same numeric value have different hashes.

Source code in frequenz/core/id.py
def __hash__(self) -> int:
    """Return the hash of this instance.

    The hash is based on the exact type and the underlying ID to ensure
    that IDs of different types but with the same numeric value have different hashes.
    """
    return hash((type(self), self._id))
__init__ ¤
__init__(id_: int) -> None

Initialize this instance.

PARAMETER DESCRIPTION
id_

The numeric unique identifier.

TYPE: int

RAISES DESCRIPTION
ValueError

If the ID is negative.

Source code in frequenz/core/id.py
def __init__(self, id_: int, /) -> None:
    """Initialize this instance.

    Args:
        id_: The numeric unique identifier.

    Raises:
        ValueError: If the ID is negative.
    """
    if id_ < 0:
        raise ValueError(f"{type(self).__name__} can't be negative.")
    self._id = id_
__init_subclass__ ¤
__init_subclass__(
    *,
    str_prefix: str,
    allow_custom_name: bool = False,
    **kwargs: Any
) -> None

Initialize a subclass, set its string prefix, and perform checks.

PARAMETER DESCRIPTION
str_prefix

The string prefix for the ID type (e.g., "MID"). Must be unique across all ID types.

TYPE: str

allow_custom_name

If True, bypasses the check that the class name must end with "Id". Defaults to False.

TYPE: bool DEFAULT: False

**kwargs

Forwarded to the parent's init_subclass.

TYPE: Any DEFAULT: {}

RAISES DESCRIPTION
TypeError

If allow_custom_name is False and the class name does not end with "Id".

Source code in frequenz/core/id.py
def __init_subclass__(
    cls,
    *,
    str_prefix: str,
    allow_custom_name: bool = False,
    **kwargs: Any,
) -> None:
    """Initialize a subclass, set its string prefix, and perform checks.

    Args:
        str_prefix: The string prefix for the ID type (e.g., "MID").
            Must be unique across all ID types.
        allow_custom_name: If True, bypasses the check that the class name
            must end with "Id". Defaults to False.
        **kwargs: Forwarded to the parent's __init_subclass__.

    Raises:
        TypeError: If `allow_custom_name` is False and the class name
            does not end with "Id".
    """
    super().__init_subclass__(**kwargs)

    if str_prefix in BaseId._registered_prefixes:
        # We want to raise an exception here, but currently can't due to
        # https://github.com/frequenz-floss/frequenz-repo-config-python/issues/421
        _logger.warning(
            "Prefix '%s' is already registered. ID prefixes must be unique.",
            str_prefix,
        )
    BaseId._registered_prefixes.add(str_prefix)

    if not allow_custom_name and not cls.__name__.endswith("Id"):
        raise TypeError(
            f"Class name '{cls.__name__}' for an ID class must end with 'Id' "
            "(e.g., 'SomeId'), or use `allow_custom_name=True`."
        )

    cls._str_prefix = str_prefix
__int__ ¤
__int__() -> int

Return the numeric ID of this instance.

Source code in frequenz/core/id.py
def __int__(self) -> int:
    """Return the numeric ID of this instance."""
    return self._id
__lt__ ¤
__lt__(other: object) -> bool

Check if this instance is less than another object.

Comparison is only defined between instances of the exact same type.

Source code in frequenz/core/id.py
def __lt__(self, other: object) -> bool:
    """Check if this instance is less than another object.

    Comparison is only defined between instances of the exact same type.
    """
    # pylint: disable-next=unidiomatic-typecheck
    if type(other) is not type(self):
        return NotImplemented
    other_id = cast(Self, other)
    return self._id < other_id._id
__new__ ¤
__new__(*_: Any, **__: Any) -> Self

Create a new instance of the ID class, only if it is a subclass of BaseId.

Source code in frequenz/core/id.py
def __new__(cls, *_: Any, **__: Any) -> Self:
    """Create a new instance of the ID class, only if it is a subclass of BaseId."""
    if cls is BaseId:
        raise TypeError("BaseId cannot be instantiated directly. Use a subclass.")
    return super().__new__(cls)
__repr__ ¤
__repr__() -> str

Return the string representation of this instance.

Source code in frequenz/core/id.py
def __repr__(self) -> str:
    """Return the string representation of this instance."""
    return f"{type(self).__name__}({self._id!r})"
__str__ ¤
__str__() -> str

Return the short string representation of this instance.

Source code in frequenz/core/id.py
def __str__(self) -> str:
    """Return the short string representation of this instance."""
    return f"{self._str_prefix}{self._id}"

frequenz.client.common.microgrid.electrical_components.ElectricalComponentStateCode ¤

Bases: Enum

All possible states of a microgrid electrical component.

Source code in src/frequenz/client/common/microgrid/electrical_components/_state_code.py
@enum.unique
class ElectricalComponentStateCode(enum.Enum):
    """All possible states of a microgrid electrical component."""

    UNSPECIFIED = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_UNSPECIFIED
    """Default value when the component state is not explicitly set."""

    UNKNOWN = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_UNKNOWN
    """The component is in an unknown or undefined condition.

    This is used when the sender is unable to classify the component into any
    other state.
    """

    UNAVAILABLE = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_UNAVAILABLE
    """The component is not available for use."""

    SWITCHING_OFF = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_OFF
    )
    """The component is in the process of switching off."""

    OFF = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_OFF
    """The component has successfully switched off."""

    SWITCHING_ON = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_ON
    )
    """The component is in the process of switching on from an off state."""

    STANDBY = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_STANDBY
    """The component is in standby mode, and not immediately ready for operation."""

    READY = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_READY
    """The component is fully operational and ready for use."""

    CHARGING = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_CHARGING
    """The component is actively consuming energy."""

    DISCHARGING = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_DISCHARGING
    """The component is actively producing or releasing energy."""

    ERROR = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_ERROR
    """The component is in an error state and may need attention."""

    EV_CHARGING_CABLE_UNPLUGGED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_UNPLUGGED
    )
    """The Electric Vehicle (EV) charging cable is unplugged from the charging station."""

    EV_CHARGING_CABLE_PLUGGED_AT_STATION = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_STATION  # noqa: E501
    )
    """The EV charging cable is plugged into the charging station."""

    EV_CHARGING_CABLE_PLUGGED_AT_EV = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_EV
    )
    """The EV charging cable is plugged into the vehicle."""

    EV_CHARGING_CABLE_LOCKED_AT_STATION = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_STATION  # noqa: E501
    )
    """The EV charging cable is locked at the charging station end, ready for charging."""

    EV_CHARGING_CABLE_LOCKED_AT_EV = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_EV
    )
    """The EV charging cable is locked at the vehicle end, indicating that charging is active."""

    RELAY_OPEN = electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_RELAY_OPEN
    """The relay is in an open state, meaning no current can flow through."""

    RELAY_CLOSED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_RELAY_CLOSED
    )
    """The relay is in a closed state, allowing current to flow."""

    PRECHARGER_OPEN = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_OPEN
    )
    """The precharger circuit is open, meaning it's not currently active."""

    PRECHARGER_PRECHARGING = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_PRECHARGING
    )
    """The precharger is in a precharging state, preparing the main circuit for activation."""

    PRECHARGER_CLOSED = (
        electrical_components_pb2.ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_CLOSED
    )
    """The precharger circuit is closed, allowing full current to flow to the main circuit."""

    @classmethod
    @deprecated(
        "frequenz.client.common.microgrid.electrical_components."
        "ElectricalComponentStateCode.from_proto() is deprecated. "
        "Use frequenz.client.common.microgrid.electrical_components.proto."
        "v1alpha8.electrical_component_state_code_from_proto instead."
    )
    def from_proto(
        cls, component_state: PBElectricalComponentStateCode.ValueType
    ) -> ElectricalComponentStateCode:
        """Convert a protobuf ElectricalComponentStateCode message to enum.

        Args:
            component_state: protobuf enum to convert

        Returns:
            Enum value corresponding to the protobuf message.
        """
        if not any(c.value == component_state for c in ElectricalComponentStateCode):
            return ElectricalComponentStateCode.UNSPECIFIED
        return cls(component_state)

    @deprecated(
        "frequenz.client.common.microgrid.electrical_components."
        "ElectricalComponentStateCode.to_proto() is deprecated. "
        "Use frequenz.client.common.microgrid.electrical_components.proto."
        "v1alpha8.electrical_component_state_code_to_proto instead."
    )
    def to_proto(self) -> PBElectricalComponentStateCode.ValueType:
        """Convert a ElectricalComponentStateCode enum to protobuf message.

        Returns:
            Enum value corresponding to the protobuf message.
        """
        return PBElectricalComponentStateCode.ValueType(self.value)
Attributes¤
CHARGING class-attribute instance-attribute ¤
CHARGING = ELECTRICAL_COMPONENT_STATE_CODE_CHARGING

The component is actively consuming energy.

DISCHARGING class-attribute instance-attribute ¤
DISCHARGING = ELECTRICAL_COMPONENT_STATE_CODE_DISCHARGING

The component is actively producing or releasing energy.

ERROR class-attribute instance-attribute ¤
ERROR = ELECTRICAL_COMPONENT_STATE_CODE_ERROR

The component is in an error state and may need attention.

EV_CHARGING_CABLE_LOCKED_AT_EV class-attribute instance-attribute ¤
EV_CHARGING_CABLE_LOCKED_AT_EV = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_EV

The EV charging cable is locked at the vehicle end, indicating that charging is active.

EV_CHARGING_CABLE_LOCKED_AT_STATION class-attribute instance-attribute ¤
EV_CHARGING_CABLE_LOCKED_AT_STATION = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_LOCKED_AT_STATION

The EV charging cable is locked at the charging station end, ready for charging.

EV_CHARGING_CABLE_PLUGGED_AT_EV class-attribute instance-attribute ¤
EV_CHARGING_CABLE_PLUGGED_AT_EV = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_EV

The EV charging cable is plugged into the vehicle.

EV_CHARGING_CABLE_PLUGGED_AT_STATION class-attribute instance-attribute ¤
EV_CHARGING_CABLE_PLUGGED_AT_STATION = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_PLUGGED_AT_STATION

The EV charging cable is plugged into the charging station.

EV_CHARGING_CABLE_UNPLUGGED class-attribute instance-attribute ¤
EV_CHARGING_CABLE_UNPLUGGED = ELECTRICAL_COMPONENT_STATE_CODE_EV_CHARGING_CABLE_UNPLUGGED

The Electric Vehicle (EV) charging cable is unplugged from the charging station.

OFF class-attribute instance-attribute ¤
OFF = ELECTRICAL_COMPONENT_STATE_CODE_OFF

The component has successfully switched off.

PRECHARGER_CLOSED class-attribute instance-attribute ¤
PRECHARGER_CLOSED = (
    ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_CLOSED
)

The precharger circuit is closed, allowing full current to flow to the main circuit.

PRECHARGER_OPEN class-attribute instance-attribute ¤
PRECHARGER_OPEN = (
    ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_OPEN
)

The precharger circuit is open, meaning it's not currently active.

PRECHARGER_PRECHARGING class-attribute instance-attribute ¤
PRECHARGER_PRECHARGING = (
    ELECTRICAL_COMPONENT_STATE_CODE_PRECHARGER_PRECHARGING
)

The precharger is in a precharging state, preparing the main circuit for activation.

READY class-attribute instance-attribute ¤
READY = ELECTRICAL_COMPONENT_STATE_CODE_READY

The component is fully operational and ready for use.

RELAY_CLOSED class-attribute instance-attribute ¤
RELAY_CLOSED = ELECTRICAL_COMPONENT_STATE_CODE_RELAY_CLOSED

The relay is in a closed state, allowing current to flow.

RELAY_OPEN class-attribute instance-attribute ¤
RELAY_OPEN = ELECTRICAL_COMPONENT_STATE_CODE_RELAY_OPEN

The relay is in an open state, meaning no current can flow through.

STANDBY class-attribute instance-attribute ¤
STANDBY = ELECTRICAL_COMPONENT_STATE_CODE_STANDBY

The component is in standby mode, and not immediately ready for operation.

SWITCHING_OFF class-attribute instance-attribute ¤
SWITCHING_OFF = (
    ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_OFF
)

The component is in the process of switching off.

SWITCHING_ON class-attribute instance-attribute ¤
SWITCHING_ON = ELECTRICAL_COMPONENT_STATE_CODE_SWITCHING_ON

The component is in the process of switching on from an off state.

UNAVAILABLE class-attribute instance-attribute ¤
UNAVAILABLE = ELECTRICAL_COMPONENT_STATE_CODE_UNAVAILABLE

The component is not available for use.

UNKNOWN class-attribute instance-attribute ¤
UNKNOWN = ELECTRICAL_COMPONENT_STATE_CODE_UNKNOWN

The component is in an unknown or undefined condition.

This is used when the sender is unable to classify the component into any other state.

UNSPECIFIED class-attribute instance-attribute ¤
UNSPECIFIED = ELECTRICAL_COMPONENT_STATE_CODE_UNSPECIFIED

Default value when the component state is not explicitly set.

Functions¤
from_proto classmethod ¤
from_proto(
    component_state: ValueType,
) -> ElectricalComponentStateCode

Convert a protobuf ElectricalComponentStateCode message to enum.

PARAMETER DESCRIPTION
component_state

protobuf enum to convert

TYPE: ValueType

RETURNS DESCRIPTION
ElectricalComponentStateCode

Enum value corresponding to the protobuf message.

Source code in src/frequenz/client/common/microgrid/electrical_components/_state_code.py
@classmethod
@deprecated(
    "frequenz.client.common.microgrid.electrical_components."
    "ElectricalComponentStateCode.from_proto() is deprecated. "
    "Use frequenz.client.common.microgrid.electrical_components.proto."
    "v1alpha8.electrical_component_state_code_from_proto instead."
)
def from_proto(
    cls, component_state: PBElectricalComponentStateCode.ValueType
) -> ElectricalComponentStateCode:
    """Convert a protobuf ElectricalComponentStateCode message to enum.

    Args:
        component_state: protobuf enum to convert

    Returns:
        Enum value corresponding to the protobuf message.
    """
    if not any(c.value == component_state for c in ElectricalComponentStateCode):
        return ElectricalComponentStateCode.UNSPECIFIED
    return cls(component_state)
to_proto ¤
to_proto() -> ValueType

Convert a ElectricalComponentStateCode enum to protobuf message.

RETURNS DESCRIPTION
ValueType

Enum value corresponding to the protobuf message.

Source code in src/frequenz/client/common/microgrid/electrical_components/_state_code.py
@deprecated(
    "frequenz.client.common.microgrid.electrical_components."
    "ElectricalComponentStateCode.to_proto() is deprecated. "
    "Use frequenz.client.common.microgrid.electrical_components.proto."
    "v1alpha8.electrical_component_state_code_to_proto instead."
)
def to_proto(self) -> PBElectricalComponentStateCode.ValueType:
    """Convert a ElectricalComponentStateCode enum to protobuf message.

    Returns:
        Enum value corresponding to the protobuf message.
    """
    return PBElectricalComponentStateCode.ValueType(self.value)