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

@@ -283,7 +283,7 @@ class IotDevice(Device):
"""Retrieve system information."""
return await self._query_helper("system", "get_sysinfo")
async def update(self, update_children: bool = True):
async def update(self, update_children_or_parent: bool = True):
"""Query the device to update the data.
Needed for properties that are decorated with `requires_update`.

View File

@@ -121,12 +121,12 @@ class IotStrip(IotDevice):
"""Return if any of the outlets are on."""
return any(plug.is_on for plug in self.children)
async def update(self, update_children: bool = True, update_parent: bool = True):
async def update(self, update_children_or_parent: bool = True):
"""Update some of the attributes.
Needed for methods that are decorated with `requires_update`.
"""
await self._update(update_children)
await self._update(update_children_or_parent)
async def _update(
self,
@@ -368,13 +368,13 @@ class IotStripPlug(IotPlug):
for module_feat in module._module_features.values():
self._add_feature(module_feat)
async def update(self, update_children: bool = True, update_parent: bool = True):
async def update(self, update_children_or_parent: bool = True):
"""Query the device to update the data.
Needed for properties that are decorated with `requires_update`.
"""
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()