From 7e8b83edb95953f40130e86e9f435abf7cb73d64 Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:40:44 +0000 Subject: [PATCH 1/3] Fix smartcam missing device id (#1343) --- kasa/smartcam/smartcamdevice.py | 1 + tests/test_device.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/kasa/smartcam/smartcamdevice.py b/kasa/smartcam/smartcamdevice.py index 0e49be26..d75c378b 100644 --- a/kasa/smartcam/smartcamdevice.py +++ b/kasa/smartcam/smartcamdevice.py @@ -200,6 +200,7 @@ class SmartCamDevice(SmartDevice): "mac": basic_info["mac"], "hwId": basic_info.get("hw_id"), "oem_id": basic_info["oem_id"], + "device_id": basic_info["dev_id"], } @property diff --git a/tests/test_device.py b/tests/test_device.py index 1d780c32..5cf75a61 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -55,6 +55,11 @@ device_classes = pytest.mark.parametrize( ) +async def test_device_id(dev: Device): + """Test all devices have a device id.""" + assert dev.device_id + + async def test_alias(dev): test_alias = "TEST1234" original = dev.alias 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 2/3] 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 From 5a596dbcc9e787a7cd034e60e61b951021b25e46 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:18:48 +0000 Subject: [PATCH 3/3] Prepare 0.8.1 --- CHANGELOG.md | 11 +++++++++++ pyproject.toml | 2 +- uv.lock | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e64db28..2ef0873f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.8.1](https://github.com/python-kasa/python-kasa/tree/0.8.1) (2024-12-06) + +This patch release fixes some issues with newly supported smartcam devices. + +[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.8.0...0.8.1) + +**Fixed bugs:** + +- Fix update errors on hubs with unsupported children [\#1344](https://github.com/python-kasa/python-kasa/pull/1344) (@sdb9696) +- Fix smartcam missing device id [\#1343](https://github.com/python-kasa/python-kasa/pull/1343) (@sdb9696) + ## [0.8.0](https://github.com/python-kasa/python-kasa/tree/0.8.0) (2024-11-26) [Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.7.7...0.8.0) diff --git a/pyproject.toml b/pyproject.toml index 506888cd..9dc265c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "python-kasa" -version = "0.8.0" +version = "0.8.1" description = "Python API for TP-Link Kasa and Tapo devices" license = {text = "GPL-3.0-or-later"} authors = [ { name = "python-kasa developers" }] diff --git a/uv.lock b/uv.lock index 12e2cb81..c6802330 100644 --- a/uv.lock +++ b/uv.lock @@ -1088,7 +1088,7 @@ wheels = [ [[package]] name = "python-kasa" -version = "0.8.0" +version = "0.8.1" source = { editable = "." } dependencies = [ { name = "aiohttp" },