Skip to content

Commit 983f3de

Browse files
committed
fixup! Implement ListComponents
Add Component.identity property
1 parent c9d299d commit 983f3de

File tree

1 file changed

+10
-0
lines changed
  • src/frequenz/client/microgrid/component

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ def active(self) -> bool:
117117
"""Whether this component is currently active."""
118118
return self.active_at(datetime.now(timezone.utc))
119119

120+
@property
121+
def identity(self) -> tuple[ComponentId, MicrogridId]:
122+
"""The identity of this component.
123+
124+
This uses the component ID and microgrid ID to identify a component
125+
without considering the other attributes, so even if a component state
126+
changed, the identity remains the same.
127+
"""
128+
return (self.id, self.microgrid_id)
129+
120130
def __str__(self) -> str:
121131
"""Return a human-readable string representation of this instance."""
122132
name = f":{self.name}" if self.name else ""

0 commit comments

Comments
 (0)