From 5465b66dee3969ffd24be6b64dd294f0a6a978ab Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:01:44 +0000 Subject: [PATCH] Fix update errors on hubs with unsupported children (#1344) --- kasa/smart/smartdevice.py | 9 ++++++++- kasa/smartcam/smartcamdevice.py | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index 0989842a..2ded9f14 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -167,7 +167,14 @@ class SmartDevice(Device): self._last_update, "get_child_device_list", {} ): for info in child_info["child_device_list"]: - self._children[info["device_id"]]._update_internal_state(info) + child_id = info["device_id"] + if child_id not in self._children: + _LOGGER.debug( + "Skipping child update for %s, probably unsupported device", + child_id, + ) + continue + self._children[child_id]._update_internal_state(info) def _update_internal_info(self, info_resp: dict) -> None: """Update the internal device info.""" diff --git a/kasa/smartcam/smartcamdevice.py b/kasa/smartcam/smartcamdevice.py index d75c378b..0090117e 100644 --- a/kasa/smartcam/smartcamdevice.py +++ b/kasa/smartcam/smartcamdevice.py @@ -68,7 +68,14 @@ class SmartCamDevice(SmartDevice): self._last_update, "getChildDeviceList", {} ): for info in child_info["child_device_list"]: - self._children[info["device_id"]]._update_internal_state(info) + child_id = info["device_id"] + if child_id not in self._children: + _LOGGER.debug( + "Skipping child update for %s, probably unsupported device", + child_id, + ) + continue + self._children[child_id]._update_internal_state(info) async def _initialize_smart_child( self, info: dict, child_components: dict