Skip to content

Commit 2f5c185

Browse files
committed
fixup! Implement ListConnections
Add active_at().
1 parent 74a70ad commit 2f5c185

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/frequenz/client/microgrid/component/_connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""Component connection."""
55

66
import dataclasses
7+
from datetime import datetime, timezone
78
from functools import cached_property
89

910
from .._id import ComponentId
@@ -58,10 +59,14 @@ def __post_init__(self) -> None:
5859
if self.source == self.destination:
5960
raise ValueError("Source and destination components must be different")
6061

62+
def active_at(self, timestamp: datetime) -> bool:
63+
"""Check whether this connection is active at a specific timestamp."""
64+
return self.operational_lifetime.active_at(timestamp)
65+
6166
@cached_property
6267
def active(self) -> bool:
6368
"""Whether this connection is currently active."""
64-
return self.operational_lifetime.active
69+
return self.active_at(datetime.now(timezone.utc))
6570

6671
def __str__(self) -> str:
6772
"""Return a human-readable string representation of this instance."""

0 commit comments

Comments
 (0)