Skip to content

Commit 90e2131

Browse files
Rework the grid connection point check to make it more readable
Co-authored-by: Daniel Zullo <[email protected]> Signed-off-by: Leandro Lucarella <[email protected]>
1 parent b31c7d3 commit 90e2131

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/frequenz/sdk/timeseries/grid.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,15 @@ def initialize(
203203
)
204204
case 1:
205205
metadata = grid_connections[0].metadata
206-
if metadata is not None and metadata.fuse is not None:
207-
fuse = Fuse(max_current=Current.from_amperes(metadata.fuse.max_current))
208-
209206
if metadata is None:
210207
_logger.warning(
211208
"Unable to get grid metadata, the grid connection point is "
212209
"considered to have no fuse"
213210
)
214-
elif fuse is None:
211+
elif metadata.fuse is None:
215212
_logger.warning("The grid connection point does not have a fuse")
213+
else:
214+
fuse = Fuse(max_current=Current.from_amperes(metadata.fuse.max_current))
216215
case _:
217216
raise RuntimeError(
218217
f"Expected at most one grid connection, got {grid_connections_count}"

0 commit comments

Comments
 (0)