Skip to content

Commit 76dda73

Browse files
committed
Provide access to new API using new v1alpha8 module
Introduces a new module `v1alpha8` that provides all the updates/changes that the common-api introduces. Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent f1917d7 commit 76dda73

File tree

8 files changed

+739
-2
lines changed

8 files changed

+739
-2
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
## Summary
44

5-
<!-- Here goes a general summary of what this release is about -->
5+
This release introduces the `v1alpha8` module to support a new API version.
66

77
## Upgrading
88

99
- The `typing-extensions` dependency minimum version was bumped to 4.6 to support Python 3.12.
1010

1111
## New Features
1212

13+
- Provide access to new API using new `v1alpha8` module.
1314
<!-- Here goes the main new features and examples or instructions on how to use them -->
1415

1516
## Bug Fixes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ classifiers = [
2727
requires-python = ">= 3.11, < 4"
2828
dependencies = [
2929
"typing-extensions >= 4.6.0, < 5",
30-
"frequenz-api-common >= 0.6.0, < 7",
30+
"frequenz-api-common >= 0.8.0, < 9",
3131
]
3232
dynamic = ["version"]
3333

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License: MIT
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Types introduced or modified in the v1alpha8 version of the common api."""
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# License: MIT
2+
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Module to define the metrics used with the common client."""
5+
6+
from enum import Enum
7+
from typing import Self
8+
9+
from frequenz.api.common.v1alpha8.metrics.metrics_pb2 import Metric as PBMetric
10+
11+
12+
class Metric(Enum):
13+
"""List of supported metrics.
14+
15+
AC energy metrics information:
16+
* This energy metric is reported directly from the component, and not a
17+
result of aggregations in our systems. If a component does not have this
18+
metric, this field cannot be populated.
19+
* Components that provide energy metrics reset this metric from time to
20+
time. This behaviour is specific to each component model. E.g., some
21+
components reset it on UTC 00:00:00.
22+
* This energy metric does not specify the timestamp since when the energy
23+
was being accumulated, and therefore can be inconsistent.
24+
"""
25+
26+
# Default value
27+
UNSPECIFIED = PBMetric.METRIC_UNSPECIFIED
28+
29+
# DC electricity metrics
30+
DC_VOLTAGE = PBMetric.METRIC_DC_VOLTAGE
31+
DC_CURRENT = PBMetric.METRIC_DC_CURRENT
32+
DC_POWER = PBMetric.METRIC_DC_POWER
33+
34+
# General AC electricity metrics
35+
AC_FREQUENCY = PBMetric.METRIC_AC_FREQUENCY
36+
AC_VOLTAGE = PBMetric.METRIC_AC_VOLTAGE
37+
AC_VOLTAGE_PHASE_1_N = PBMetric.METRIC_AC_VOLTAGE_PHASE_1_N
38+
AC_VOLTAGE_PHASE_2_N = PBMetric.METRIC_AC_VOLTAGE_PHASE_2_N
39+
AC_VOLTAGE_PHASE_3_N = PBMetric.METRIC_AC_VOLTAGE_PHASE_3_N
40+
AC_VOLTAGE_PHASE_1_PHASE_2 = PBMetric.METRIC_AC_VOLTAGE_PHASE_1_PHASE_2
41+
AC_VOLTAGE_PHASE_2_PHASE_3 = PBMetric.METRIC_AC_VOLTAGE_PHASE_2_PHASE_3
42+
AC_VOLTAGE_PHASE_3_PHASE_1 = PBMetric.METRIC_AC_VOLTAGE_PHASE_3_PHASE_1
43+
AC_CURRENT = PBMetric.METRIC_AC_CURRENT
44+
AC_CURRENT_PHASE_1 = PBMetric.METRIC_AC_CURRENT_PHASE_1
45+
AC_CURRENT_PHASE_2 = PBMetric.METRIC_AC_CURRENT_PHASE_2
46+
AC_CURRENT_PHASE_3 = PBMetric.METRIC_AC_CURRENT_PHASE_3
47+
48+
# AC power metrics
49+
AC_POWER_APPARENT = PBMetric.METRIC_AC_POWER_APPARENT
50+
AC_POWER_APPARENT_PHASE_1 = PBMetric.METRIC_AC_POWER_APPARENT_PHASE_1
51+
AC_POWER_APPARENT_PHASE_2 = PBMetric.METRIC_AC_POWER_APPARENT_PHASE_2
52+
AC_POWER_APPARENT_PHASE_3 = PBMetric.METRIC_AC_POWER_APPARENT_PHASE_3
53+
AC_POWER_ACTIVE = PBMetric.METRIC_AC_POWER_ACTIVE
54+
AC_POWER_ACTIVE_PHASE_1 = PBMetric.METRIC_AC_POWER_ACTIVE_PHASE_1
55+
AC_POWER_ACTIVE_PHASE_2 = PBMetric.METRIC_AC_POWER_ACTIVE_PHASE_2
56+
AC_POWER_ACTIVE_PHASE_3 = PBMetric.METRIC_AC_POWER_ACTIVE_PHASE_3
57+
AC_POWER_REACTIVE = PBMetric.METRIC_AC_POWER_REACTIVE
58+
AC_POWER_REACTIVE_PHASE_1 = PBMetric.METRIC_AC_POWER_REACTIVE_PHASE_1
59+
AC_POWER_REACTIVE_PHASE_2 = PBMetric.METRIC_AC_POWER_REACTIVE_PHASE_2
60+
AC_POWER_REACTIVE_PHASE_3 = PBMetric.METRIC_AC_POWER_REACTIVE_PHASE_3
61+
62+
# AC power factor
63+
AC_POWER_FACTOR = PBMetric.METRIC_AC_POWER_FACTOR
64+
AC_POWER_FACTOR_PHASE_1 = PBMetric.METRIC_AC_POWER_FACTOR_PHASE_1
65+
AC_POWER_FACTOR_PHASE_2 = PBMetric.METRIC_AC_POWER_FACTOR_PHASE_2
66+
AC_POWER_FACTOR_PHASE_3 = PBMetric.METRIC_AC_POWER_FACTOR_PHASE_3
67+
68+
# AC energy metrics - Please be careful when using and check Enum docs
69+
AC_ENERGY_APPARENT = PBMetric.METRIC_AC_ENERGY_APPARENT
70+
AC_ENERGY_APPARENT_PHASE_1 = PBMetric.METRIC_AC_ENERGY_APPARENT_PHASE_1
71+
AC_ENERGY_APPARENT_PHASE_2 = PBMetric.METRIC_AC_ENERGY_APPARENT_PHASE_2
72+
AC_ENERGY_APPARENT_PHASE_3 = PBMetric.METRIC_AC_ENERGY_APPARENT_PHASE_3
73+
AC_ENERGY_ACTIVE = PBMetric.METRIC_AC_ENERGY_ACTIVE
74+
AC_ENERGY_ACTIVE_PHASE_1 = PBMetric.METRIC_AC_ENERGY_ACTIVE_PHASE_1
75+
AC_ENERGY_ACTIVE_PHASE_2 = PBMetric.METRIC_AC_ENERGY_ACTIVE_PHASE_2
76+
AC_ENERGY_ACTIVE_PHASE_3 = PBMetric.METRIC_AC_ENERGY_ACTIVE_PHASE_3
77+
AC_ENERGY_ACTIVE_CONSUMED = PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED
78+
AC_ENERGY_ACTIVE_CONSUMED_PHASE_1 = (
79+
PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED_PHASE_1
80+
)
81+
AC_ENERGY_ACTIVE_CONSUMED_PHASE_2 = (
82+
PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED_PHASE_2
83+
)
84+
AC_ENERGY_ACTIVE_CONSUMED_PHASE_3 = (
85+
PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED_PHASE_3
86+
)
87+
AC_ENERGY_ACTIVE_DELIVERED = PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED
88+
AC_ENERGY_ACTIVE_DELIVERED_PHASE_1 = (
89+
PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED_PHASE_1
90+
)
91+
AC_ENERGY_ACTIVE_DELIVERED_PHASE_2 = (
92+
PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED_PHASE_2
93+
)
94+
AC_ENERGY_ACTIVE_DELIVERED_PHASE_3 = (
95+
PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED_PHASE_3
96+
)
97+
AC_ENERGY_REACTIVE = PBMetric.METRIC_AC_ENERGY_REACTIVE
98+
AC_ENERGY_REACTIVE_PHASE_1 = PBMetric.METRIC_AC_ENERGY_REACTIVE_PHASE_1
99+
AC_ENERGY_REACTIVE_PHASE_2 = PBMetric.METRIC_AC_ENERGY_REACTIVE_PHASE_2
100+
AC_ENERGY_REACTIVE_PHASE_3 = PBMetric.METRIC_AC_ENERGY_REACTIVE_PHASE_3
101+
102+
# AC harmonics
103+
AC_TOTAL_HARMONIC_DISTORTION_CURRENT = (
104+
PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT
105+
)
106+
AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_1 = (
107+
PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_1
108+
)
109+
AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_2 = (
110+
PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_2
111+
)
112+
AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_3 = (
113+
PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_3
114+
)
115+
116+
# General BMS metrics
117+
BATTERY_CAPACITY = PBMetric.METRIC_BATTERY_CAPACITY
118+
BATTERY_SOC_PCT = PBMetric.METRIC_BATTERY_SOC_PCT
119+
BATTERY_TEMPERATURE = PBMetric.METRIC_BATTERY_TEMPERATURE
120+
121+
# General inverter metrics
122+
INVERTER_TEMPERATURE = PBMetric.METRIC_INVERTER_TEMPERATURE
123+
INVERTER_TEMPERATURE_CABINET = PBMetric.METRIC_INVERTER_TEMPERATURE_CABINET
124+
INVERTER_TEMPERATURE_HEATSINK = PBMetric.METRIC_INVERTER_TEMPERATURE_HEATSINK
125+
INVERTER_TEMPERATURE_TRANSFORMER = PBMetric.METRIC_INVERTER_TEMPERATURE_TRANSFORMER
126+
127+
# EV charging station metrics
128+
EV_CHARGER_TEMPERATURE = PBMetric.METRIC_EV_CHARGER_TEMPERATURE
129+
130+
# General sensor metrics
131+
SENSOR_WIND_SPEED = PBMetric.METRIC_SENSOR_WIND_SPEED
132+
SENSOR_WIND_DIRECTION = PBMetric.METRIC_SENSOR_WIND_DIRECTION
133+
SENSOR_TEMPERATURE = PBMetric.METRIC_SENSOR_TEMPERATURE
134+
SENSOR_RELATIVE_HUMIDITY = PBMetric.METRIC_SENSOR_RELATIVE_HUMIDITY
135+
SENSOR_DEW_POINT = PBMetric.METRIC_SENSOR_DEW_POINT
136+
SENSOR_AIR_PRESSURE = PBMetric.METRIC_SENSOR_AIR_PRESSURE
137+
SENSOR_IRRADIANCE = PBMetric.METRIC_SENSOR_IRRADIANCE
138+
139+
@classmethod
140+
def from_proto(cls, metric: PBMetric.ValueType) -> Self:
141+
"""Convert a protobuf Metric value to Metric enum.
142+
143+
Args:
144+
metric: Metric to convert.
145+
Returns:
146+
Enum value corresponding to the protobuf message.
147+
"""
148+
if not any(m.value == metric for m in cls):
149+
return cls(Metric.UNSPECIFIED)
150+
151+
return cls(metric)
152+
153+
def to_proto(self) -> PBMetric.ValueType:
154+
"""Convert a Metric object to protobuf Metric.
155+
156+
Returns:
157+
Protobuf message corresponding to the Metric object.
158+
"""
159+
return self.value
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License: MIT
2+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3+
4+
"""Frequenz microgrid definition."""

0 commit comments

Comments
 (0)