frequenz-client-common 0.3.2__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {frequenz_client_common-0.3.2/src/frequenz_client_common.egg-info → frequenz_client_common-0.3.4}/PKG-INFO +18 -18
  2. frequenz_client_common-0.3.4/RELEASE_NOTES.md +18 -0
  3. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/pyproject.toml +21 -21
  4. frequenz_client_common-0.3.4/src/frequenz/client/common/enum_proto.py +76 -0
  5. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/metric/__init__.py +5 -2
  6. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/microgrid/components/__init__.py +57 -4
  7. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/__init__.py +4 -0
  8. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/metric/__init__.py +162 -0
  9. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/microgrid/__init__.py +18 -0
  10. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/microgrid/electrical_components/__init__.py +459 -0
  11. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/microgrid/sensors.py +13 -0
  12. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/pagination/__init__.py +91 -0
  13. frequenz_client_common-0.3.4/src/frequenz/client/common/v1alpha8/streaming/__init__.py +26 -0
  14. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4/src/frequenz_client_common.egg-info}/PKG-INFO +18 -18
  15. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz_client_common.egg-info/SOURCES.txt +8 -0
  16. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz_client_common.egg-info/requires.txt +17 -17
  17. frequenz_client_common-0.3.2/RELEASE_NOTES.md +0 -19
  18. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/LICENSE +0 -0
  19. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/MANIFEST.in +0 -0
  20. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/README.md +0 -0
  21. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/setup.cfg +0 -0
  22. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/__init__.py +0 -0
  23. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/conftest.py +0 -0
  24. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/microgrid/__init__.py +0 -0
  25. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/microgrid/sensors.py +0 -0
  26. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/pagination/__init__.py +0 -0
  27. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz/client/common/py.typed +0 -0
  28. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz_client_common.egg-info/dependency_links.txt +0 -0
  29. {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.4}/src/frequenz_client_common.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: frequenz-client-common
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Common code and utilities for Frequenz API clients
5
5
  Author-email: Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>
6
6
  License: MIT
@@ -21,10 +21,10 @@ Requires-Python: <4,>=3.11
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: typing-extensions<5,>=4.13.0
24
- Requires-Dist: frequenz-api-common<7,>=0.6.0
25
- Requires-Dist: frequenz-core<2,>=1.0.0
24
+ Requires-Dist: frequenz-api-common<9,>=0.8.0
25
+ Requires-Dist: frequenz-core<2,>=1.0.2
26
26
  Provides-Extra: dev-flake8
27
- Requires-Dist: flake8==7.2.0; extra == "dev-flake8"
27
+ Requires-Dist: flake8==7.3.0; extra == "dev-flake8"
28
28
  Requires-Dist: flake8-docstrings==1.7.0; extra == "dev-flake8"
29
29
  Requires-Dist: flake8-pyproject==1.2.3; extra == "dev-flake8"
30
30
  Requires-Dist: pydoclint==0.6.6; extra == "dev-flake8"
@@ -33,32 +33,32 @@ Provides-Extra: dev-formatting
33
33
  Requires-Dist: black==25.1.0; extra == "dev-formatting"
34
34
  Requires-Dist: isort==6.0.1; extra == "dev-formatting"
35
35
  Provides-Extra: dev-mkdocs
36
- Requires-Dist: Markdown==3.8; extra == "dev-mkdocs"
36
+ Requires-Dist: Markdown==3.8.2; extra == "dev-mkdocs"
37
37
  Requires-Dist: black==25.1.0; extra == "dev-mkdocs"
38
38
  Requires-Dist: mike==2.1.3; extra == "dev-mkdocs"
39
39
  Requires-Dist: mkdocs-gen-files==0.5.0; extra == "dev-mkdocs"
40
40
  Requires-Dist: mkdocs-literate-nav==0.6.2; extra == "dev-mkdocs"
41
41
  Requires-Dist: mkdocs-macros-plugin==1.3.7; extra == "dev-mkdocs"
42
- Requires-Dist: mkdocs-material==9.6.12; extra == "dev-mkdocs"
43
- Requires-Dist: mkdocstrings[python]==0.29.1; extra == "dev-mkdocs"
44
- Requires-Dist: mkdocstrings-python==1.16.10; extra == "dev-mkdocs"
45
- Requires-Dist: frequenz-repo-config[lib]==0.13.3; extra == "dev-mkdocs"
42
+ Requires-Dist: mkdocs-material==9.6.16; extra == "dev-mkdocs"
43
+ Requires-Dist: mkdocstrings[python]==0.30.0; extra == "dev-mkdocs"
44
+ Requires-Dist: mkdocstrings-python==1.16.12; extra == "dev-mkdocs"
45
+ Requires-Dist: frequenz-repo-config[lib]==0.13.5; extra == "dev-mkdocs"
46
46
  Provides-Extra: dev-mypy
47
- Requires-Dist: mypy==1.15.0; extra == "dev-mypy"
48
- Requires-Dist: types-Markdown==3.8.0.20250415; extra == "dev-mypy"
47
+ Requires-Dist: mypy==1.17.1; extra == "dev-mypy"
48
+ Requires-Dist: types-Markdown==3.8.0.20250708; extra == "dev-mypy"
49
49
  Requires-Dist: frequenz-client-common[dev-mkdocs,dev-noxfile,dev-pytest]; extra == "dev-mypy"
50
50
  Provides-Extra: dev-noxfile
51
51
  Requires-Dist: nox==2025.5.1; extra == "dev-noxfile"
52
- Requires-Dist: frequenz-repo-config[lib]==0.13.3; extra == "dev-noxfile"
52
+ Requires-Dist: frequenz-repo-config[lib]==0.13.5; extra == "dev-noxfile"
53
53
  Provides-Extra: dev-pylint
54
- Requires-Dist: pylint==3.3.6; extra == "dev-pylint"
54
+ Requires-Dist: pylint==3.3.7; extra == "dev-pylint"
55
55
  Requires-Dist: frequenz-client-common[dev-mkdocs,dev-noxfile,dev-pytest]; extra == "dev-pylint"
56
56
  Provides-Extra: dev-pytest
57
- Requires-Dist: pytest==8.3.5; extra == "dev-pytest"
58
- Requires-Dist: frequenz-repo-config[extra-lint-examples]==0.13.3; extra == "dev-pytest"
59
- Requires-Dist: pytest-mock==3.14.0; extra == "dev-pytest"
60
- Requires-Dist: pytest-asyncio==0.26.0; extra == "dev-pytest"
61
- Requires-Dist: async-solipsism==0.7; extra == "dev-pytest"
57
+ Requires-Dist: pytest==8.4.1; extra == "dev-pytest"
58
+ Requires-Dist: frequenz-repo-config[extra-lint-examples]==0.13.5; extra == "dev-pytest"
59
+ Requires-Dist: pytest-mock==3.14.1; extra == "dev-pytest"
60
+ Requires-Dist: pytest-asyncio==1.1.0; extra == "dev-pytest"
61
+ Requires-Dist: async-solipsism==0.8; extra == "dev-pytest"
62
62
  Provides-Extra: dev
63
63
  Requires-Dist: frequenz-client-common[dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]; extra == "dev"
64
64
  Dynamic: license-file
@@ -0,0 +1,18 @@
1
+ # Frequenz Client Common Library Release Notes
2
+
3
+ ## Summary
4
+
5
+ This release introduces the `v1alpha8` module to support a new API version.
6
+
7
+ ## Upgrading
8
+
9
+ <!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10
+
11
+ ## New Features
12
+
13
+ - Provide access to new API using new `v1alpha8` module.
14
+ - Mapping for the new `Event` message has been added.
15
+
16
+ ## Bug Fixes
17
+
18
+ - Updated display of protobuf version warnings
@@ -3,9 +3,9 @@
3
3
 
4
4
  [build-system]
5
5
  requires = [
6
- "setuptools == 80.3.1",
6
+ "setuptools == 80.9.0",
7
7
  "setuptools_scm[toml] == 8.3.1",
8
- "frequenz-repo-config[lib] == 0.13.3",
8
+ "frequenz-repo-config[lib] == 0.13.5",
9
9
  ]
10
10
  build-backend = "setuptools.build_meta"
11
11
 
@@ -27,8 +27,8 @@ classifiers = [
27
27
  requires-python = ">= 3.11, < 4"
28
28
  dependencies = [
29
29
  "typing-extensions >= 4.13.0, < 5",
30
- "frequenz-api-common >= 0.6.0, < 7",
31
- "frequenz-core >= 1.0.0, < 2",
30
+ "frequenz-api-common >= 0.8.0, < 9",
31
+ "frequenz-core >= 1.0.2, < 2",
32
32
  ]
33
33
  dynamic = ["version"]
34
34
 
@@ -38,43 +38,43 @@ email = "floss@frequenz.com"
38
38
 
39
39
  [project.optional-dependencies]
40
40
  dev-flake8 = [
41
- "flake8 == 7.2.0",
41
+ "flake8 == 7.3.0",
42
42
  "flake8-docstrings == 1.7.0",
43
- "flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
43
+ "flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
44
44
  "pydoclint == 0.6.6",
45
45
  "pydocstyle == 6.3.0",
46
46
  ]
47
47
  dev-formatting = ["black == 25.1.0", "isort == 6.0.1"]
48
48
  dev-mkdocs = [
49
- "Markdown == 3.8",
49
+ "Markdown == 3.8.2",
50
50
  "black == 25.1.0",
51
51
  "mike == 2.1.3",
52
52
  "mkdocs-gen-files == 0.5.0",
53
53
  "mkdocs-literate-nav == 0.6.2",
54
54
  "mkdocs-macros-plugin == 1.3.7",
55
- "mkdocs-material == 9.6.12",
56
- "mkdocstrings[python] == 0.29.1",
57
- "mkdocstrings-python == 1.16.10",
58
- "frequenz-repo-config[lib] == 0.13.3",
55
+ "mkdocs-material == 9.6.16",
56
+ "mkdocstrings[python] == 0.30.0",
57
+ "mkdocstrings-python == 1.16.12",
58
+ "frequenz-repo-config[lib] == 0.13.5",
59
59
  ]
60
60
  dev-mypy = [
61
- "mypy == 1.15.0",
62
- "types-Markdown == 3.8.0.20250415",
61
+ "mypy == 1.17.1",
62
+ "types-Markdown == 3.8.0.20250708",
63
63
  # For checking the noxfile, docs/ script, and tests
64
64
  "frequenz-client-common[dev-mkdocs,dev-noxfile,dev-pytest]",
65
65
  ]
66
- dev-noxfile = ["nox == 2025.5.1", "frequenz-repo-config[lib] == 0.13.3"]
66
+ dev-noxfile = ["nox == 2025.5.1", "frequenz-repo-config[lib] == 0.13.5"]
67
67
  dev-pylint = [
68
- "pylint == 3.3.6",
68
+ "pylint == 3.3.7",
69
69
  # For checking the noxfile, docs/ script, and tests
70
70
  "frequenz-client-common[dev-mkdocs,dev-noxfile,dev-pytest]",
71
71
  ]
72
72
  dev-pytest = [
73
- "pytest == 8.3.5",
74
- "frequenz-repo-config[extra-lint-examples] == 0.13.3",
75
- "pytest-mock == 3.14.0",
76
- "pytest-asyncio == 0.26.0",
77
- "async-solipsism == 0.7",
73
+ "pytest == 8.4.1",
74
+ "frequenz-repo-config[extra-lint-examples] == 0.13.5",
75
+ "pytest-mock == 3.14.1",
76
+ "pytest-asyncio == 1.1.0",
77
+ "async-solipsism == 0.8",
78
78
  ]
79
79
  dev = [
80
80
  "frequenz-client-common[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
@@ -145,7 +145,6 @@ disable = [
145
145
  ]
146
146
 
147
147
  [tool.pytest.ini_options]
148
- addopts = "-vv"
149
148
  filterwarnings = [
150
149
  "error",
151
150
  "once::DeprecationWarning",
@@ -157,6 +156,7 @@ filterwarnings = [
157
156
  # characters as this is a regex.
158
157
  'ignore:Protobuf gencode version .*exactly one major version older.*:UserWarning',
159
158
  ]
159
+ addopts = "-vv"
160
160
  testpaths = ["tests", "src"]
161
161
  asyncio_mode = "auto"
162
162
  asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,76 @@
1
+ # License: MIT
2
+ # Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3
+
4
+ """Conversion of protobuf int enums to Python enums."""
5
+
6
+ import enum
7
+ from typing import Literal, TypeVar, overload
8
+
9
+ EnumT = TypeVar("EnumT", bound=enum.Enum)
10
+ """A type variable that is bound to an enum."""
11
+
12
+
13
+ @overload
14
+ def enum_from_proto(
15
+ value: int, enum_type: type[EnumT], *, allow_invalid: Literal[False]
16
+ ) -> EnumT: ...
17
+
18
+
19
+ @overload
20
+ def enum_from_proto(
21
+ value: int, enum_type: type[EnumT], *, allow_invalid: Literal[True] = True
22
+ ) -> EnumT | int: ...
23
+
24
+
25
+ def enum_from_proto(
26
+ value: int, enum_type: type[EnumT], *, allow_invalid: bool = True
27
+ ) -> EnumT | int:
28
+ """Convert a protobuf int enum value to a python enum.
29
+
30
+ Example:
31
+ ```python
32
+ import enum
33
+
34
+ from proto import proto_pb2 # Just an example. pylint: disable=import-error
35
+
36
+ @enum.unique
37
+ class SomeEnum(enum.Enum):
38
+ # These values should match the protobuf enum values.
39
+ UNSPECIFIED = 0
40
+ SOME_VALUE = 1
41
+
42
+ enum_value = enum_from_proto(proto_pb2.SomeEnum.SOME_ENUM_SOME_VALUE, SomeEnum)
43
+ # -> SomeEnum.SOME_VALUE
44
+
45
+ enum_value = enum_from_proto(42, SomeEnum)
46
+ # -> 42
47
+
48
+ enum_value = enum_from_proto(
49
+ proto_pb2.SomeEnum.SOME_ENUM_UNKNOWN_VALUE, SomeEnum, allow_invalid=False
50
+ )
51
+ # -> ValueError
52
+ ```
53
+
54
+ Args:
55
+ value: The protobuf int enum value.
56
+ enum_type: The python enum type to convert to.
57
+ allow_invalid: If `True`, return the value as an `int` if the value is not
58
+ a valid member of the enum (this allows for forward-compatibility with new
59
+ enum values defined in the protocol but not added to the Python enum yet).
60
+ If `False`, raise a `ValueError` if the value is not a valid member of the
61
+ enum.
62
+
63
+ Returns:
64
+ The resulting python enum value if the protobuf value is known, otherwise
65
+ the input value converted to a plain `int`.
66
+
67
+ Raises:
68
+ ValueError: If `allow_invalid` is `False` and the value is not a valid member
69
+ of the enum.
70
+ """
71
+ try:
72
+ return enum_type(value)
73
+ except ValueError:
74
+ if allow_invalid:
75
+ return value
76
+ raise
@@ -3,16 +3,18 @@
3
3
 
4
4
  """Module to define the metrics used with the common client."""
5
5
 
6
- from enum import Enum
6
+ import enum
7
7
  from typing import Self
8
8
 
9
9
  # pylint: disable=no-name-in-module
10
10
  from frequenz.api.common.v1.metrics.metric_sample_pb2 import Metric as PBMetric
11
+ from typing_extensions import deprecated
11
12
 
12
13
  # pylint: enable=no-name-in-module
13
14
 
14
15
 
15
- class Metric(Enum):
16
+ @enum.unique
17
+ class Metric(enum.Enum):
16
18
  """List of supported metrics.
17
19
 
18
20
  AC energy metrics information:
@@ -140,6 +142,7 @@ class Metric(Enum):
140
142
  SENSOR_IRRADIANCE = PBMetric.METRIC_SENSOR_IRRADIANCE
141
143
 
142
144
  @classmethod
145
+ @deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
143
146
  def from_proto(cls, metric: PBMetric.ValueType) -> Self:
144
147
  """Convert a protobuf Metric value to Metric enum.
145
148
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
- from enum import Enum
8
+ import enum
9
9
  from typing import final
10
10
 
11
11
  # pylint: disable=no-name-in-module
@@ -19,6 +19,7 @@ from frequenz.api.common.v1.microgrid.components.components_pb2 import (
19
19
  ComponentStateCode as PBComponentStateCode,
20
20
  )
21
21
  from frequenz.core.id import BaseId
22
+ from typing_extensions import deprecated
22
23
 
23
24
  # pylint: enable=no-name-in-module
24
25
 
@@ -28,7 +29,8 @@ class ComponentId(BaseId, str_prefix="CID"):
28
29
  """A unique identifier for a microgrid component."""
29
30
 
30
31
 
31
- class ComponentCategory(Enum):
32
+ @enum.unique
33
+ class ComponentCategory(enum.Enum):
32
34
  """Possible types of microgrid component."""
33
35
 
34
36
  UNSPECIFIED = PBComponentCategory.COMPONENT_CATEGORY_UNSPECIFIED
@@ -47,16 +49,63 @@ class ComponentCategory(Enum):
47
49
  INVERTER = PBComponentCategory.COMPONENT_CATEGORY_INVERTER
48
50
  """An electricity generator, with batteries or solar energy."""
49
51
 
52
+ CONVERTER = PBComponentCategory.COMPONENT_CATEGORY_CONVERTER
53
+ """A DC-DC converter."""
54
+
50
55
  BATTERY = PBComponentCategory.COMPONENT_CATEGORY_BATTERY
51
56
  """A storage system for electrical energy, used by inverters."""
52
57
 
53
58
  EV_CHARGER = PBComponentCategory.COMPONENT_CATEGORY_EV_CHARGER
54
59
  """A station for charging electrical vehicles."""
55
60
 
61
+ CRYPTO_MINER = PBComponentCategory.COMPONENT_CATEGORY_CRYPTO_MINER
62
+ """A crypto miner."""
63
+
64
+ ELECTROLYZER = PBComponentCategory.COMPONENT_CATEGORY_ELECTROLYZER
65
+ """An electrolyzer for converting water into hydrogen and oxygen."""
66
+
56
67
  CHP = PBComponentCategory.COMPONENT_CATEGORY_CHP
57
68
  """A heat and power combustion plant (CHP stands for combined heat and power)."""
58
69
 
70
+ RELAY = PBComponentCategory.COMPONENT_CATEGORY_RELAY
71
+ """A relay.
72
+
73
+ Relays generally have two states: open (connected) and closed (disconnected).
74
+ They are generally placed in front of a component, e.g., an inverter, to
75
+ control whether the component is connected to the grid or not.
76
+ """
77
+
78
+ PRECHARGER = PBComponentCategory.COMPONENT_CATEGORY_PRECHARGER
79
+ """A precharge module.
80
+
81
+ Precharging involves gradually ramping up the DC voltage to prevent any
82
+ potential damage to sensitive electrical components like capacitors.
83
+
84
+ While many inverters and batteries come equipped with in-built precharging
85
+ mechanisms, some may lack this feature. In such cases, we need to use
86
+ external precharging modules.
87
+ """
88
+
89
+ FUSE = PBComponentCategory.COMPONENT_CATEGORY_FUSE
90
+ """A fuse."""
91
+
92
+ VOLTAGE_TRANSFORMER = PBComponentCategory.COMPONENT_CATEGORY_VOLTAGE_TRANSFORMER
93
+ """A voltage transformer.
94
+
95
+ Voltage transformers are used to step up or step down the voltage, keeping
96
+ the power somewhat constant by increasing or decreasing the current. If voltage is
97
+ stepped up, current is stepped down, and vice versa.
98
+
99
+ Note:
100
+ Voltage transformers have efficiency losses, so the output power is
101
+ always less than the input power.
102
+ """
103
+
104
+ HVAC = PBComponentCategory.COMPONENT_CATEGORY_HVAC
105
+ """A Heating, Ventilation, and Air Conditioning (HVAC) system."""
106
+
59
107
  @classmethod
108
+ @deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
60
109
  def from_proto(
61
110
  cls, component_category: PBComponentCategory.ValueType
62
111
  ) -> ComponentCategory:
@@ -81,7 +130,8 @@ class ComponentCategory(Enum):
81
130
  return self.value
82
131
 
83
132
 
84
- class ComponentStateCode(Enum):
133
+ @enum.unique
134
+ class ComponentStateCode(enum.Enum):
85
135
  """All possible states of a microgrid component."""
86
136
 
87
137
  UNSPECIFIED = PBComponentStateCode.COMPONENT_STATE_CODE_UNSPECIFIED
@@ -161,6 +211,7 @@ class ComponentStateCode(Enum):
161
211
  """The precharger circuit is closed, allowing full current to flow to the main circuit."""
162
212
 
163
213
  @classmethod
214
+ @deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
164
215
  def from_proto(
165
216
  cls, component_state: PBComponentStateCode.ValueType
166
217
  ) -> ComponentStateCode:
@@ -185,7 +236,8 @@ class ComponentStateCode(Enum):
185
236
  return self.value
186
237
 
187
238
 
188
- class ComponentErrorCode(Enum):
239
+ @enum.unique
240
+ class ComponentErrorCode(enum.Enum):
189
241
  """All possible errors that can occur across all microgrid component categories."""
190
242
 
191
243
  UNSPECIFIED = PBComponentErrorCode.COMPONENT_ERROR_CODE_UNSPECIFIED
@@ -338,6 +390,7 @@ class ComponentErrorCode(Enum):
338
390
  times."""
339
391
 
340
392
  @classmethod
393
+ @deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
341
394
  def from_proto(
342
395
  cls, component_error_code: PBComponentErrorCode.ValueType
343
396
  ) -> ComponentErrorCode:
@@ -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."""
@@ -0,0 +1,162 @@
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
+ import enum
7
+ from typing import Self
8
+
9
+ from frequenz.api.common.v1alpha8.metrics.metrics_pb2 import Metric as PBMetric
10
+ from typing_extensions import deprecated
11
+
12
+
13
+ @enum.unique
14
+ class Metric(enum.Enum):
15
+ """List of supported metrics.
16
+
17
+ AC energy metrics information:
18
+ * This energy metric is reported directly from the component, and not a
19
+ result of aggregations in our systems. If a component does not have this
20
+ metric, this field cannot be populated.
21
+ * Components that provide energy metrics reset this metric from time to
22
+ time. This behaviour is specific to each component model. E.g., some
23
+ components reset it on UTC 00:00:00.
24
+ * This energy metric does not specify the timestamp since when the energy
25
+ was being accumulated, and therefore can be inconsistent.
26
+ """
27
+
28
+ # Default value
29
+ UNSPECIFIED = PBMetric.METRIC_UNSPECIFIED
30
+
31
+ # DC electricity metrics
32
+ DC_VOLTAGE = PBMetric.METRIC_DC_VOLTAGE
33
+ DC_CURRENT = PBMetric.METRIC_DC_CURRENT
34
+ DC_POWER = PBMetric.METRIC_DC_POWER
35
+
36
+ # General AC electricity metrics
37
+ AC_FREQUENCY = PBMetric.METRIC_AC_FREQUENCY
38
+ AC_VOLTAGE = PBMetric.METRIC_AC_VOLTAGE
39
+ AC_VOLTAGE_PHASE_1_N = PBMetric.METRIC_AC_VOLTAGE_PHASE_1_N
40
+ AC_VOLTAGE_PHASE_2_N = PBMetric.METRIC_AC_VOLTAGE_PHASE_2_N
41
+ AC_VOLTAGE_PHASE_3_N = PBMetric.METRIC_AC_VOLTAGE_PHASE_3_N
42
+ AC_VOLTAGE_PHASE_1_PHASE_2 = PBMetric.METRIC_AC_VOLTAGE_PHASE_1_PHASE_2
43
+ AC_VOLTAGE_PHASE_2_PHASE_3 = PBMetric.METRIC_AC_VOLTAGE_PHASE_2_PHASE_3
44
+ AC_VOLTAGE_PHASE_3_PHASE_1 = PBMetric.METRIC_AC_VOLTAGE_PHASE_3_PHASE_1
45
+ AC_CURRENT = PBMetric.METRIC_AC_CURRENT
46
+ AC_CURRENT_PHASE_1 = PBMetric.METRIC_AC_CURRENT_PHASE_1
47
+ AC_CURRENT_PHASE_2 = PBMetric.METRIC_AC_CURRENT_PHASE_2
48
+ AC_CURRENT_PHASE_3 = PBMetric.METRIC_AC_CURRENT_PHASE_3
49
+
50
+ # AC power metrics
51
+ AC_POWER_APPARENT = PBMetric.METRIC_AC_POWER_APPARENT
52
+ AC_POWER_APPARENT_PHASE_1 = PBMetric.METRIC_AC_POWER_APPARENT_PHASE_1
53
+ AC_POWER_APPARENT_PHASE_2 = PBMetric.METRIC_AC_POWER_APPARENT_PHASE_2
54
+ AC_POWER_APPARENT_PHASE_3 = PBMetric.METRIC_AC_POWER_APPARENT_PHASE_3
55
+ AC_POWER_ACTIVE = PBMetric.METRIC_AC_POWER_ACTIVE
56
+ AC_POWER_ACTIVE_PHASE_1 = PBMetric.METRIC_AC_POWER_ACTIVE_PHASE_1
57
+ AC_POWER_ACTIVE_PHASE_2 = PBMetric.METRIC_AC_POWER_ACTIVE_PHASE_2
58
+ AC_POWER_ACTIVE_PHASE_3 = PBMetric.METRIC_AC_POWER_ACTIVE_PHASE_3
59
+ AC_POWER_REACTIVE = PBMetric.METRIC_AC_POWER_REACTIVE
60
+ AC_POWER_REACTIVE_PHASE_1 = PBMetric.METRIC_AC_POWER_REACTIVE_PHASE_1
61
+ AC_POWER_REACTIVE_PHASE_2 = PBMetric.METRIC_AC_POWER_REACTIVE_PHASE_2
62
+ AC_POWER_REACTIVE_PHASE_3 = PBMetric.METRIC_AC_POWER_REACTIVE_PHASE_3
63
+
64
+ # AC power factor
65
+ AC_POWER_FACTOR = PBMetric.METRIC_AC_POWER_FACTOR
66
+ AC_POWER_FACTOR_PHASE_1 = PBMetric.METRIC_AC_POWER_FACTOR_PHASE_1
67
+ AC_POWER_FACTOR_PHASE_2 = PBMetric.METRIC_AC_POWER_FACTOR_PHASE_2
68
+ AC_POWER_FACTOR_PHASE_3 = PBMetric.METRIC_AC_POWER_FACTOR_PHASE_3
69
+
70
+ # AC energy metrics - Please be careful when using and check Enum docs
71
+ AC_ENERGY_APPARENT = PBMetric.METRIC_AC_ENERGY_APPARENT
72
+ AC_ENERGY_APPARENT_PHASE_1 = PBMetric.METRIC_AC_ENERGY_APPARENT_PHASE_1
73
+ AC_ENERGY_APPARENT_PHASE_2 = PBMetric.METRIC_AC_ENERGY_APPARENT_PHASE_2
74
+ AC_ENERGY_APPARENT_PHASE_3 = PBMetric.METRIC_AC_ENERGY_APPARENT_PHASE_3
75
+ AC_ENERGY_ACTIVE = PBMetric.METRIC_AC_ENERGY_ACTIVE
76
+ AC_ENERGY_ACTIVE_PHASE_1 = PBMetric.METRIC_AC_ENERGY_ACTIVE_PHASE_1
77
+ AC_ENERGY_ACTIVE_PHASE_2 = PBMetric.METRIC_AC_ENERGY_ACTIVE_PHASE_2
78
+ AC_ENERGY_ACTIVE_PHASE_3 = PBMetric.METRIC_AC_ENERGY_ACTIVE_PHASE_3
79
+ AC_ENERGY_ACTIVE_CONSUMED = PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED
80
+ AC_ENERGY_ACTIVE_CONSUMED_PHASE_1 = (
81
+ PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED_PHASE_1
82
+ )
83
+ AC_ENERGY_ACTIVE_CONSUMED_PHASE_2 = (
84
+ PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED_PHASE_2
85
+ )
86
+ AC_ENERGY_ACTIVE_CONSUMED_PHASE_3 = (
87
+ PBMetric.METRIC_AC_ENERGY_ACTIVE_CONSUMED_PHASE_3
88
+ )
89
+ AC_ENERGY_ACTIVE_DELIVERED = PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED
90
+ AC_ENERGY_ACTIVE_DELIVERED_PHASE_1 = (
91
+ PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED_PHASE_1
92
+ )
93
+ AC_ENERGY_ACTIVE_DELIVERED_PHASE_2 = (
94
+ PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED_PHASE_2
95
+ )
96
+ AC_ENERGY_ACTIVE_DELIVERED_PHASE_3 = (
97
+ PBMetric.METRIC_AC_ENERGY_ACTIVE_DELIVERED_PHASE_3
98
+ )
99
+ AC_ENERGY_REACTIVE = PBMetric.METRIC_AC_ENERGY_REACTIVE
100
+ AC_ENERGY_REACTIVE_PHASE_1 = PBMetric.METRIC_AC_ENERGY_REACTIVE_PHASE_1
101
+ AC_ENERGY_REACTIVE_PHASE_2 = PBMetric.METRIC_AC_ENERGY_REACTIVE_PHASE_2
102
+ AC_ENERGY_REACTIVE_PHASE_3 = PBMetric.METRIC_AC_ENERGY_REACTIVE_PHASE_3
103
+
104
+ # AC harmonics
105
+ AC_TOTAL_HARMONIC_DISTORTION_CURRENT = (
106
+ PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT
107
+ )
108
+ AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_1 = (
109
+ PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_1
110
+ )
111
+ AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_2 = (
112
+ PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_2
113
+ )
114
+ AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_3 = (
115
+ PBMetric.METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_3
116
+ )
117
+
118
+ # General BMS metrics
119
+ BATTERY_CAPACITY = PBMetric.METRIC_BATTERY_CAPACITY
120
+ BATTERY_SOC_PCT = PBMetric.METRIC_BATTERY_SOC_PCT
121
+ BATTERY_TEMPERATURE = PBMetric.METRIC_BATTERY_TEMPERATURE
122
+
123
+ # General inverter metrics
124
+ INVERTER_TEMPERATURE = PBMetric.METRIC_INVERTER_TEMPERATURE
125
+ INVERTER_TEMPERATURE_CABINET = PBMetric.METRIC_INVERTER_TEMPERATURE_CABINET
126
+ INVERTER_TEMPERATURE_HEATSINK = PBMetric.METRIC_INVERTER_TEMPERATURE_HEATSINK
127
+ INVERTER_TEMPERATURE_TRANSFORMER = PBMetric.METRIC_INVERTER_TEMPERATURE_TRANSFORMER
128
+
129
+ # EV charging station metrics
130
+ EV_CHARGER_TEMPERATURE = PBMetric.METRIC_EV_CHARGER_TEMPERATURE
131
+
132
+ # General sensor metrics
133
+ SENSOR_WIND_SPEED = PBMetric.METRIC_SENSOR_WIND_SPEED
134
+ SENSOR_WIND_DIRECTION = PBMetric.METRIC_SENSOR_WIND_DIRECTION
135
+ SENSOR_TEMPERATURE = PBMetric.METRIC_SENSOR_TEMPERATURE
136
+ SENSOR_RELATIVE_HUMIDITY = PBMetric.METRIC_SENSOR_RELATIVE_HUMIDITY
137
+ SENSOR_DEW_POINT = PBMetric.METRIC_SENSOR_DEW_POINT
138
+ SENSOR_AIR_PRESSURE = PBMetric.METRIC_SENSOR_AIR_PRESSURE
139
+ SENSOR_IRRADIANCE = PBMetric.METRIC_SENSOR_IRRADIANCE
140
+
141
+ @classmethod
142
+ @deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
143
+ def from_proto(cls, metric: PBMetric.ValueType) -> Self:
144
+ """Convert a protobuf Metric value to Metric enum.
145
+
146
+ Args:
147
+ metric: Metric to convert.
148
+ Returns:
149
+ Enum value corresponding to the protobuf message.
150
+ """
151
+ if not any(m.value == metric for m in cls):
152
+ return cls(Metric.UNSPECIFIED)
153
+
154
+ return cls(metric)
155
+
156
+ def to_proto(self) -> PBMetric.ValueType:
157
+ """Convert a Metric object to protobuf Metric.
158
+
159
+ Returns:
160
+ Protobuf message corresponding to the Metric object.
161
+ """
162
+ return self.value
@@ -0,0 +1,18 @@
1
+ # License: MIT
2
+ # Copyright © 2025 Frequenz Energy-as-a-Service GmbH
3
+
4
+ """Frequenz microgrid definition."""
5
+
6
+ from typing import final
7
+
8
+ from frequenz.core.id import BaseId
9
+
10
+
11
+ @final
12
+ class EnterpriseId(BaseId, str_prefix="EID"):
13
+ """A unique identifier for an enterprise account."""
14
+
15
+
16
+ @final
17
+ class MicrogridId(BaseId, str_prefix="MID"):
18
+ """A unique identifier for a microgrid."""