Backwards compatabilty

This commit is contained in:
sdb9696
2024-06-29 09:24:30 +01:00
parent 00bf59be6c
commit 77ac6ca148
6 changed files with 143 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ from __future__ import annotations
import logging
from typing import Any
from warnings import warn
from ..device_type import DeviceType
from ..deviceconfig import DeviceConfig
@@ -36,12 +37,25 @@ class SmartChildDevice(SmartDevice):
self._id = info["device_id"]
self.protocol = _ChildProtocolWrapper(self._id, parent.protocol)
async def update(self, update_children_or_parent: bool = True):
async def update(
self,
update_children_or_parent: bool = True,
*,
update_children: bool | None = None,
):
"""Update the device.
Calling update directly on a child device will update the parent
and only this child.
"""
if update_children is not None:
warn(
"update_children is deprecated, use update_children_or_parent",
DeprecationWarning,
stacklevel=1,
)
update_children_or_parent = False
if update_children_or_parent:
await self._parent._update(called_from_child=self)
else:

View File

@@ -7,6 +7,7 @@ import logging
from collections.abc import Mapping, Sequence
from datetime import datetime, timedelta, timezone
from typing import Any, cast
from warnings import warn
from ..aestransport import AesTransport
from ..device import Device, WifiNetwork
@@ -147,8 +148,21 @@ class SmartDevice(Device):
if "child_device" in self._components and not self.children:
await self._initialize_children()
async def update(self, update_children_or_parent: bool = True):
async def update(
self,
update_children_or_parent: bool = True,
*,
update_children: bool | None = None,
):
"""Update the device."""
if update_children is not None:
warn(
"update_children is deprecated, use update_children_or_parent",
DeprecationWarning,
stacklevel=1,
)
update_children_or_parent = update_children
await self._update(update_children_or_parent)
async def _update(