|
16 | 16 | from ._graph import ComponentGraph, _MicrogridComponentGraph
|
17 | 17 | from .client import MicrogridApiClient
|
18 | 18 | from .client._client import MicrogridGrpcClient
|
19 |
| -from .metadata import Metadata |
| 19 | +from .metadata import Location, Metadata |
20 | 20 |
|
21 | 21 | # Not public default host and port
|
22 | 22 | _DEFAULT_MICROGRID_HOST = "[::1]"
|
@@ -75,6 +75,24 @@ def component_graph(self) -> ComponentGraph:
|
75 | 75 | component graph
|
76 | 76 | """
|
77 | 77 |
|
| 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 | + |
78 | 96 | async def _update_api(self, host: str, port: int) -> None:
|
79 | 97 | self._host = host
|
80 | 98 | self._port = port
|
@@ -116,6 +134,24 @@ def api_client(self) -> MicrogridApiClient:
|
116 | 134 | """
|
117 | 135 | return self._api
|
118 | 136 |
|
| 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 | + |
119 | 155 | @property
|
120 | 156 | def component_graph(self) -> ComponentGraph:
|
121 | 157 | """Get component graph.
|
|
0 commit comments