From b3eb8657ceb8a43e2087fdb33bc8c404a029abb4 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:31:17 +0000 Subject: [PATCH 1/2] Fix update errors on hubs with child smartcams --- kasa/smartcam/smartcamdevice.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kasa/smartcam/smartcamdevice.py b/kasa/smartcam/smartcamdevice.py index 0e49be264..9d90f461c 100644 --- a/kasa/smartcam/smartcamdevice.py +++ b/kasa/smartcam/smartcamdevice.py @@ -68,6 +68,13 @@ def _update_children_info(self) -> None: self._last_update, "getChildDeviceList", {} ): for info in child_info["child_device_list"]: + 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 # child smartcams not supported self._children[info["device_id"]]._update_internal_state(info) async def _initialize_smart_child( From bccb501eda01cdc915a74ff961eb8f0322815420 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:55:24 +0000 Subject: [PATCH 2/2] Ensure same for smart hubs --- kasa/smart/smartdevice.py | 9 ++++++++- kasa/smartcam/smartcamdevice.py | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index 176efb710..48f50c0e8 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -167,7 +167,14 @@ def _update_children_info(self) -> None: 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 9d90f461c..7c7977fd1 100644 --- a/kasa/smartcam/smartcamdevice.py +++ b/kasa/smartcam/smartcamdevice.py @@ -74,8 +74,8 @@ def _update_children_info(self) -> None: "Skipping child update for %s, probably unsupported device", child_id, ) - continue # child smartcams not supported - self._children[info["device_id"]]._update_internal_state(info) + continue + self._children[child_id]._update_internal_state(info) async def _initialize_smart_child( self, info: dict, child_components: dict