Update sub-component batteries from parent HA entity in poller and live sync

This commit is contained in:
2026-06-10 12:28:27 -05:00
parent d41fe7f4ab
commit 2a103f52a5
4 changed files with 43 additions and 13 deletions
+7
View File
@@ -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}>"