Update sub-component batteries from parent HA entity in poller and live sync
This commit is contained in:
@@ -86,6 +86,13 @@ class Device(Base):
|
||||
return sum(c.battery_slots for c in self.children)
|
||||
return self.battery_slots
|
||||
|
||||
def installed_batteries(self):
|
||||
"""Installed batteries on this device, including its sub-components."""
|
||||
bats = [b for b in self.batteries if b.status == "installed"]
|
||||
for child in self.children:
|
||||
bats.extend(b for b in child.batteries if b.status == "installed")
|
||||
return bats
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Device {self.name}>"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user