Consolidate update parameters

This commit is contained in:
sdb9696
2024-06-29 08:28:18 +01:00
parent ec1082a228
commit 00bf59be6c
6 changed files with 31 additions and 21 deletions

View File

@@ -36,14 +36,14 @@ class SmartChildDevice(SmartDevice):
self._id = info["device_id"]
self.protocol = _ChildProtocolWrapper(self._id, parent.protocol)
async def update(self, update_children: bool = True, update_parent: bool = True):
async def update(self, update_children_or_parent: bool = True):
"""Update the device.
Calling update directly on a child device will update the parent
and only this child.
"""
if update_parent:
await self._parent._update(update_children=False, called_from_child=self)
if update_children_or_parent:
await self._parent._update(called_from_child=self)
else:
await self._update()

View File

@@ -147,9 +147,9 @@ class SmartDevice(Device):
if "child_device" in self._components and not self.children:
await self._initialize_children()
async def update(self, update_children: bool = True, update_parent: bool = True):
async def update(self, update_children_or_parent: bool = True):
"""Update the device."""
await self._update(update_children)
await self._update(update_children_or_parent)
async def _update(
self, update_children: bool = True, called_from_child: SmartDevice | None = None