Skip to content

Commit 355d7f8

Browse files
Expose microgrid ID and location
Signed-off-by: Daniel Zullo <[email protected]>
1 parent d6214bd commit 355d7f8

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

src/frequenz/sdk/microgrid/connection_manager.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from ._graph import ComponentGraph, _MicrogridComponentGraph
1717
from .client import MicrogridApiClient
1818
from .client._client import MicrogridGrpcClient
19-
from .metadata import Metadata
19+
from .metadata import Location, Metadata
2020

2121
# Not public default host and port
2222
_DEFAULT_MICROGRID_HOST = "[::1]"
@@ -75,6 +75,24 @@ def component_graph(self) -> ComponentGraph:
7575
component graph
7676
"""
7777

78+
@property
79+
@abstractmethod
80+
def microgrid_id(self) -> int | None:
81+
"""Get the ID of the microgrid.
82+
83+
Returns:
84+
the ID of the microgrid.
85+
"""
86+
87+
@property
88+
@abstractmethod
89+
def location(self) -> Location | None:
90+
"""Get the location of the microgrid.
91+
92+
Returns:
93+
the location of the microgrid.
94+
"""
95+
7896
async def _update_api(self, host: str, port: int) -> None:
7997
self._host = host
8098
self._port = port
@@ -116,6 +134,24 @@ def api_client(self) -> MicrogridApiClient:
116134
"""
117135
return self._api
118136

137+
@property
138+
def microgrid_id(self) -> int | None:
139+
"""Get the microgrid metadata if available.
140+
141+
Returns:
142+
the microgrid metadata if available, None otherwise.
143+
"""
144+
return self._metadata.microgrid_id if self._metadata else None
145+
146+
@property
147+
def location(self) -> Location | None:
148+
"""Get the microgrid location if available.
149+
150+
Returns:
151+
the microgrid location if available, None otherwise.
152+
"""
153+
return self._metadata.location if self._metadata else None
154+
119155
@property
120156
def component_graph(self) -> ComponentGraph:
121157
"""Get component graph.

0 commit comments

Comments
 (0)