From 85f94e4f36f3f415003509f8dad7466e72b37cff Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Sun, 9 Feb 2025 14:15:38 +0100 Subject: [PATCH 1/5] Do not crash on missing build number in fw version --- kasa/smart/smartdevice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kasa/smart/smartdevice.py b/kasa/smart/smartdevice.py index f2daf0d79..2e2dc7cd5 100644 --- a/kasa/smart/smartdevice.py +++ b/kasa/smart/smartdevice.py @@ -913,7 +913,10 @@ def _get_device_info( components, device_family ) fw_version_full = di["fw_ver"] - firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + if " " in fw_version_full: + firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + else: + firmware_version, firmware_build = fw_version_full, None _protocol, devicetype = device_family.split(".") # Brand inferred from SMART.KASAPLUG/SMART.TAPOPLUG etc. brand = devicetype[:4].lower() From ca5f9693f14761f29a292ca464d0557ee456be18 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Sun, 9 Feb 2025 15:12:10 +0100 Subject: [PATCH 2/5] Add fixture --- .../T310(US)_1.0_1.5.0_bare_version.json | 530 ++++++++++++++++++ 1 file changed, 530 insertions(+) create mode 100644 tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json diff --git a/tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json b/tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json new file mode 100644 index 000000000..c06ff49f1 --- /dev/null +++ b/tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json @@ -0,0 +1,530 @@ +{ + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "trigger_log", + "ver_code": 1 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "battery_detect", + "ver_code": 1 + }, + { + "id": "temperature", + "ver_code": 1 + }, + { + "id": "humidity", + "ver_code": 1 + }, + { + "id": "temp_humidity_record", + "ver_code": 1 + }, + { + "id": "comfort_temperature", + "ver_code": 1 + }, + { + "id": "comfort_humidity", + "ver_code": 1 + }, + { + "id": "report_mode", + "ver_code": 1 + } + ] + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_device_info": { + "at_low_battery": false, + "avatar": "sensor_t310", + "bind_count": 1, + "category": "subg.trigger.temp-hmdt-sensor", + "current_humidity": 61, + "current_humidity_exception": 1, + "current_temp": 21.0, + "current_temp_exception": 0, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_1", + "fw_ver": "1.5.0", + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.0", + "jamming_rssi": -108, + "jamming_signal_level": 2, + "lastOnboardingTimestamp": 1690859014, + "mac": "788CB5000000", + "model": "T310", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "parent_device_id": "0000000000000000000000000000000000000000", + "region": "Pacific/Auckland", + "report_interval": 8, + "rssi": -56, + "signal_level": 3, + "specs": "US", + "status": "online", + "status_follow_edge": false, + "temp_unit": "celsius", + "type": "SMART.TAPOSENSOR" + }, + "get_fw_download_state": { + "cloud_cache_seconds": 1, + "download_progress": 0, + "reboot_time": 5, + "status": 0, + "upgrade_time": 5 + }, + "get_latest_fw": { + "fw_size": 0, + "fw_ver": "1.5.0", + "hw_id": "", + "need_to_upgrade": false, + "oem_id": "", + "release_date": "", + "release_note": "", + "type": 0 + }, + "get_temp_humidity_records": { + "local_time": 1739107441, + "past24h_humidity": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 58, + 57, + 57, + 57, + 56, + 56, + 55, + 55, + 55, + 55, + 54, + 54, + 55, + 56, + 57, + 57, + 58, + 58, + 58, + 58, + 59, + 59, + 59, + 59, + 59, + 59, + 59, + 59, + 59, + 60, + 60, + 60, + 60, + 60, + 60, + 60, + 60, + 61, + 82, + 59, + 60, + 61, + 61, + 61, + 61 + ], + "past24h_humidity_exception": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 22, + 0, + 0, + 1, + 1, + 1, + 1 + ], + "past24h_temp": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 213, + 213, + 212, + 211, + 210, + 208, + 207, + 206, + 205, + 204, + 203, + 202, + 201, + 202, + 203, + 205, + 206, + 208, + 209, + 210, + 210, + 211, + 211, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 215, + 254, + 221, + 214, + 212, + 211, + 210, + 210 + ], + "past24h_temp_exception": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "temp_unit": "celsius" + }, + "get_trigger_logs": { + "logs": [], + "start_id": 0, + "sum": 0 + } +} From c86cc8b50da4a91bc150b0e5966afd9051d5fc5c Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:44:23 +0000 Subject: [PATCH 3/5] Treat new fixture as modify to existing to avoid dupe supported versions --- .../smart/child/T310(US)_1.0_1.5.0.json | 426 +++++++++++++- .../T310(US)_1.0_1.5.0_bare_version.json | 530 ------------------ 2 files changed, 409 insertions(+), 547 deletions(-) delete mode 100644 tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json diff --git a/tests/fixtures/smart/child/T310(US)_1.0_1.5.0.json b/tests/fixtures/smart/child/T310(US)_1.0_1.5.0.json index bdc4eef69..c06ff49f1 100644 --- a/tests/fixtures/smart/child/T310(US)_1.0_1.5.0.json +++ b/tests/fixtures/smart/child/T310(US)_1.0_1.5.0.json @@ -75,7 +75,6 @@ } ] }, - "get_auto_update_info": -1001, "get_connect_cloud_state": { "status": 0 }, @@ -84,25 +83,25 @@ "avatar": "sensor_t310", "bind_count": 1, "category": "subg.trigger.temp-hmdt-sensor", - "current_humidity": 49, - "current_humidity_exception": 0, - "current_temp": 21.7, + "current_humidity": 61, + "current_humidity_exception": 1, + "current_temp": 21.0, "current_temp_exception": 0, "device_id": "SCRUBBED_CHILD_DEVICE_ID_1", - "fw_ver": "1.5.0 Build 230105 Rel.180832", + "fw_ver": "1.5.0", "hw_id": "00000000000000000000000000000000", "hw_ver": "1.0", - "jamming_rssi": -111, - "jamming_signal_level": 1, - "lastOnboardingTimestamp": 1724637745, - "mac": "F0A731000000", + "jamming_rssi": -108, + "jamming_signal_level": 2, + "lastOnboardingTimestamp": 1690859014, + "mac": "788CB5000000", "model": "T310", "nickname": "I01BU0tFRF9OQU1FIw==", "oem_id": "00000000000000000000000000000000", "parent_device_id": "0000000000000000000000000000000000000000", - "region": "Australia/Canberra", - "report_interval": 16, - "rssi": -46, + "region": "Pacific/Auckland", + "report_interval": 8, + "rssi": -56, "signal_level": 3, "specs": "US", "status": "online", @@ -110,8 +109,6 @@ "temp_unit": "celsius", "type": "SMART.TAPOSENSOR" }, - "get_device_time": -1001, - "get_device_usage": -1001, "get_fw_download_state": { "cloud_cache_seconds": 1, "download_progress": 0, @@ -121,7 +118,7 @@ }, "get_latest_fw": { "fw_size": 0, - "fw_ver": "1.5.0 Build 230105 Rel.180832", + "fw_ver": "1.5.0", "hw_id": "", "need_to_upgrade": false, "oem_id": "", @@ -129,10 +126,405 @@ "release_note": "", "type": 0 }, + "get_temp_humidity_records": { + "local_time": 1739107441, + "past24h_humidity": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 58, + 57, + 57, + 57, + 56, + 56, + 55, + 55, + 55, + 55, + 54, + 54, + 55, + 56, + 57, + 57, + 58, + 58, + 58, + 58, + 59, + 59, + 59, + 59, + 59, + 59, + 59, + 59, + 59, + 60, + 60, + 60, + 60, + 60, + 60, + 60, + 60, + 61, + 82, + 59, + 60, + 61, + 61, + 61, + 61 + ], + "past24h_humidity_exception": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 22, + 0, + 0, + 1, + 1, + 1, + 1 + ], + "past24h_temp": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 213, + 213, + 212, + 211, + 210, + 208, + 207, + 206, + 205, + 204, + 203, + 202, + 201, + 202, + 203, + 205, + 206, + 208, + 209, + 210, + 210, + 211, + 211, + 212, + 212, + 212, + 212, + 212, + 212, + 212, + 213, + 213, + 213, + 213, + 213, + 213, + 213, + 215, + 254, + 221, + 214, + 212, + 211, + 210, + 210 + ], + "past24h_temp_exception": [ + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + -1000, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "temp_unit": "celsius" + }, "get_trigger_logs": { "logs": [], "start_id": 0, "sum": 0 - }, - "qs_component_nego": -1001 + } } diff --git a/tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json b/tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json deleted file mode 100644 index c06ff49f1..000000000 --- a/tests/fixtures/smart/child/T310(US)_1.0_1.5.0_bare_version.json +++ /dev/null @@ -1,530 +0,0 @@ -{ - "component_nego": { - "component_list": [ - { - "id": "device", - "ver_code": 2 - }, - { - "id": "quick_setup", - "ver_code": 3 - }, - { - "id": "trigger_log", - "ver_code": 1 - }, - { - "id": "time", - "ver_code": 1 - }, - { - "id": "device_local_time", - "ver_code": 1 - }, - { - "id": "account", - "ver_code": 1 - }, - { - "id": "synchronize", - "ver_code": 1 - }, - { - "id": "cloud_connect", - "ver_code": 1 - }, - { - "id": "iot_cloud", - "ver_code": 1 - }, - { - "id": "firmware", - "ver_code": 1 - }, - { - "id": "localSmart", - "ver_code": 1 - }, - { - "id": "battery_detect", - "ver_code": 1 - }, - { - "id": "temperature", - "ver_code": 1 - }, - { - "id": "humidity", - "ver_code": 1 - }, - { - "id": "temp_humidity_record", - "ver_code": 1 - }, - { - "id": "comfort_temperature", - "ver_code": 1 - }, - { - "id": "comfort_humidity", - "ver_code": 1 - }, - { - "id": "report_mode", - "ver_code": 1 - } - ] - }, - "get_connect_cloud_state": { - "status": 0 - }, - "get_device_info": { - "at_low_battery": false, - "avatar": "sensor_t310", - "bind_count": 1, - "category": "subg.trigger.temp-hmdt-sensor", - "current_humidity": 61, - "current_humidity_exception": 1, - "current_temp": 21.0, - "current_temp_exception": 0, - "device_id": "SCRUBBED_CHILD_DEVICE_ID_1", - "fw_ver": "1.5.0", - "hw_id": "00000000000000000000000000000000", - "hw_ver": "1.0", - "jamming_rssi": -108, - "jamming_signal_level": 2, - "lastOnboardingTimestamp": 1690859014, - "mac": "788CB5000000", - "model": "T310", - "nickname": "I01BU0tFRF9OQU1FIw==", - "oem_id": "00000000000000000000000000000000", - "parent_device_id": "0000000000000000000000000000000000000000", - "region": "Pacific/Auckland", - "report_interval": 8, - "rssi": -56, - "signal_level": 3, - "specs": "US", - "status": "online", - "status_follow_edge": false, - "temp_unit": "celsius", - "type": "SMART.TAPOSENSOR" - }, - "get_fw_download_state": { - "cloud_cache_seconds": 1, - "download_progress": 0, - "reboot_time": 5, - "status": 0, - "upgrade_time": 5 - }, - "get_latest_fw": { - "fw_size": 0, - "fw_ver": "1.5.0", - "hw_id": "", - "need_to_upgrade": false, - "oem_id": "", - "release_date": "", - "release_note": "", - "type": 0 - }, - "get_temp_humidity_records": { - "local_time": 1739107441, - "past24h_humidity": [ - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - 58, - 57, - 57, - 57, - 56, - 56, - 55, - 55, - 55, - 55, - 54, - 54, - 55, - 56, - 57, - 57, - 58, - 58, - 58, - 58, - 59, - 59, - 59, - 59, - 59, - 59, - 59, - 59, - 59, - 60, - 60, - 60, - 60, - 60, - 60, - 60, - 60, - 61, - 82, - 59, - 60, - 61, - 61, - 61, - 61 - ], - "past24h_humidity_exception": [ - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 22, - 0, - 0, - 1, - 1, - 1, - 1 - ], - "past24h_temp": [ - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - 213, - 213, - 212, - 211, - 210, - 208, - 207, - 206, - 205, - 204, - 203, - 202, - 201, - 202, - 203, - 205, - 206, - 208, - 209, - 210, - 210, - 211, - 211, - 212, - 212, - 212, - 212, - 212, - 212, - 212, - 213, - 213, - 213, - 213, - 213, - 213, - 213, - 215, - 254, - 221, - 214, - 212, - 211, - 210, - 210 - ], - "past24h_temp_exception": [ - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - -1000, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 4, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "temp_unit": "celsius" - }, - "get_trigger_logs": { - "logs": [], - "start_id": 0, - "sum": 0 - } -} From 9e0e65cdae371320db3cf6b196619aed64a583db Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:45:32 +0000 Subject: [PATCH 4/5] Add child temp_humidity_record to smartcam dumpdevinfo --- devtools/dump_devinfo.py | 17 ----------------- devtools/helpers/smartrequests.py | 1 + 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/devtools/dump_devinfo.py b/devtools/dump_devinfo.py index a0fff0e5c..bbe1e8130 100644 --- a/devtools/dump_devinfo.py +++ b/devtools/dump_devinfo.py @@ -725,15 +725,6 @@ async def get_smart_test_calls(protocol: SmartProtocol): successes = [] child_device_components = {} - extra_test_calls = [ - SmartCall( - module="temp_humidity_records", - request=SmartRequest.get_raw_request("get_temp_humidity_records").to_dict(), - should_succeed=False, - child_device_id="", - ), - ] - click.echo("Testing component_nego call ..", nl=False) responses = await _make_requests_or_exit( protocol, @@ -812,8 +803,6 @@ async def get_smart_test_calls(protocol: SmartProtocol): click.echo(f"Skipping {component_id}..", nl=False) click.echo(click.style("UNSUPPORTED", fg="yellow")) - test_calls.extend(extra_test_calls) - # Child component calls for child_device_id, child_components in child_device_components.items(): test_calls.append( @@ -839,12 +828,6 @@ async def get_smart_test_calls(protocol: SmartProtocol): else: click.echo(f"Skipping {component_id}..", nl=False) click.echo(click.style("UNSUPPORTED", fg="yellow")) - # Add the extra calls for each child - for extra_call in extra_test_calls: - extra_child_call = dataclasses.replace( - extra_call, child_device_id=child_device_id - ) - test_calls.append(extra_child_call) return test_calls, successes diff --git a/devtools/helpers/smartrequests.py b/devtools/helpers/smartrequests.py index 3756cb956..1ff379160 100644 --- a/devtools/helpers/smartrequests.py +++ b/devtools/helpers/smartrequests.py @@ -425,6 +425,7 @@ def get_component_requests(component_id, ver_code): "get_trigger_logs", SmartRequest.GetTriggerLogsParams() ) ], + "temp_humidity_record": [SmartRequest.get_raw_request("get_temp_humidity_records")], "double_click": [SmartRequest.get_raw_request("get_double_click_info")], "child_device": [ SmartRequest.get_raw_request("get_child_device_list"), From cf165fc4d99788f1791b172161c3ce4a924147ea Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:09:00 +0000 Subject: [PATCH 5/5] Guard for no build number in all device types --- kasa/cli/device.py | 2 +- kasa/device.py | 2 +- kasa/iot/iotdevice.py | 5 ++++- kasa/smartcam/smartcamchild.py | 5 ++++- kasa/smartcam/smartcamdevice.py | 5 ++++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/kasa/cli/device.py b/kasa/cli/device.py index a10f485d4..7610a7cdf 100644 --- a/kasa/cli/device.py +++ b/kasa/cli/device.py @@ -48,7 +48,7 @@ async def state(ctx, dev: Device): ) echo( f"Firmware: {dev.device_info.firmware_version}" - f" {dev.device_info.firmware_build}" + f"{' ' + build if (build := dev.device_info.firmware_build) else ''}" ) echo(f"MAC (rssi): {dev.mac} ({dev.rssi})") if verbose: diff --git a/kasa/device.py b/kasa/device.py index d86a565e4..c4ea41e2e 100644 --- a/kasa/device.py +++ b/kasa/device.py @@ -161,7 +161,7 @@ class DeviceInfo: device_type: DeviceType hardware_version: str firmware_version: str - firmware_build: str + firmware_build: str | None requires_auth: bool region: str | None diff --git a/kasa/iot/iotdevice.py b/kasa/iot/iotdevice.py index 851f21ccc..d1de7f9e6 100755 --- a/kasa/iot/iotdevice.py +++ b/kasa/iot/iotdevice.py @@ -760,7 +760,10 @@ def _get_device_info( device_family = sys_info.get("type", sys_info.get("mic_type")) device_type = IotDevice._get_device_type_from_sys_info(info) fw_version_full = sys_info["sw_ver"] - firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + if " " in fw_version_full: + firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + else: + firmware_version, firmware_build = fw_version_full, None auth = bool(discovery_info and ("mgt_encrypt_schm" in discovery_info)) return DeviceInfo( diff --git a/kasa/smartcam/smartcamchild.py b/kasa/smartcam/smartcamchild.py index d26144647..cb9d8e989 100644 --- a/kasa/smartcam/smartcamchild.py +++ b/kasa/smartcam/smartcamchild.py @@ -103,7 +103,10 @@ def _get_device_info( model = cifp["device_model"] device_type = SmartCamDevice._get_device_type_from_sysinfo(cifp) fw_version_full = cifp["sw_ver"] - firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + if " " in fw_version_full: + firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + else: + firmware_version, firmware_build = fw_version_full, None return DeviceInfo( short_name=model, long_name=model, diff --git a/kasa/smartcam/smartcamdevice.py b/kasa/smartcam/smartcamdevice.py index 1bf58532f..3beda36bc 100644 --- a/kasa/smartcam/smartcamdevice.py +++ b/kasa/smartcam/smartcamdevice.py @@ -47,7 +47,10 @@ def _get_device_info( long_name = discovery_info["device_model"] if discovery_info else short_name device_type = SmartCamDevice._get_device_type_from_sysinfo(basic_info) fw_version_full = basic_info["sw_version"] - firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + if " " in fw_version_full: + firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1) + else: + firmware_version, firmware_build = fw_version_full, None return DeviceInfo( short_name=basic_info["device_model"], long_name=long_name,