From 1acf4e86da30ca710dbfdc9ae5c8845f724f3359 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Thu, 1 Feb 2024 19:27:01 +0100 Subject: [PATCH] Retain last two chars for children device_id (#733) --- devtools/dump_devinfo.py | 6 ++++ .../fixtures/smart/P300(EU)_1.0_1.0.13.json | 36 +++++++------------ .../fixtures/smart/P300(EU)_1.0_1.0.7.json | 12 +++---- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/devtools/dump_devinfo.py b/devtools/dump_devinfo.py index e9ec56b7..005eb799 100644 --- a/devtools/dump_devinfo.py +++ b/devtools/dump_devinfo.py @@ -60,6 +60,7 @@ def scrub(res): "alias", "bssid", "channel", + "original_device_id", # for child devices ] for k, v in res.items(): @@ -96,6 +97,11 @@ def scrub(res): v = "#MASKED_NAME#" elif isinstance(res[k], int): v = 0 + elif k == "device_id" and len(v) > 40: + # retain the last two chars when scrubbing child ids + end = v[-2:] + v = re.sub(r"\w", "0", v) + v = v[:40] + end else: v = re.sub(r"\w", "0", v) diff --git a/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.13.json b/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.13.json index 4c4402bc..0d7d4a3b 100644 --- a/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.13.json +++ b/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.13.json @@ -170,7 +170,7 @@ "ver_code": 1 } ], - "device_id": "000000000000000000000000000000000000000000" + "device_id": "000000000000000000000000000000000000000002" }, { "component_list": [ @@ -235,7 +235,7 @@ "ver_code": 1 } ], - "device_id": "000000000000000000000000000000000000000000" + "device_id": "000000000000000000000000000000000000000001" }, { "component_list": [ @@ -318,7 +318,7 @@ }, "type": "custom" }, - "device_id": "000000000000000000000000000000000000000000", + "device_id": "000000000000000000000000000000000000000002", "device_on": false, "fw_id": "00000000000000000000000000000000", "fw_ver": "1.0.13 Build 230925 Rel.150200", @@ -332,7 +332,7 @@ "nickname": "I01BU0tFRF9OQU1FIw==", "oem_id": "00000000000000000000000000000000", "on_time": 0, - "original_device_id": "8022852468EC205A8178C7CBE81FC119213BC020", + "original_device_id": "0000000000000000000000000000000000000000", "overheat_status": "normal", "position": 3, "region": "Europe/Berlin", @@ -347,7 +347,7 @@ "default_states": { "type": "last_states" }, - "device_id": "000000000000000000000000000000000000000000", + "device_id": "000000000000000000000000000000000000000001", "device_on": false, "fw_id": "00000000000000000000000000000000", "fw_ver": "1.0.13 Build 230925 Rel.150200", @@ -361,7 +361,7 @@ "nickname": "I01BU0tFRF9OQU1FIw==", "oem_id": "00000000000000000000000000000000", "on_time": 0, - "original_device_id": "8022852468EC205A8178C7CBE81FC119213BC020", + "original_device_id": "0000000000000000000000000000000000000000", "overheat_status": "normal", "position": 2, "region": "Europe/Berlin", @@ -393,7 +393,7 @@ "nickname": "I01BU0tFRF9OQU1FIw==", "oem_id": "00000000000000000000000000000000", "on_time": 0, - "original_device_id": "8022852468EC205A8178C7CBE81FC119213BC020", + "original_device_id": "0000000000000000000000000000000000000000", "overheat_status": "normal", "position": 1, "region": "Europe/Berlin", @@ -406,7 +406,7 @@ "sum": 3 }, "get_connect_cloud_state": { - "status": 0 + "status": 2 }, "get_device_info": { "avatar": "", @@ -435,12 +435,12 @@ "get_device_time": { "region": "Europe/Berlin", "time_diff": 60, - "timestamp": 1706320181 + "timestamp": 1706810351 }, "get_device_usage": { "time_usage": { - "past30": 0, - "past7": 0, + "past30": 134, + "past7": 134, "today": 0 } }, @@ -451,23 +451,13 @@ "status": 0, "upgrade_time": 5 }, - "get_latest_fw": { - "fw_size": 0, - "fw_ver": "1.0.13 Build 230925 Rel.150200", - "hw_id": "", - "need_to_upgrade": false, - "oem_id": "", - "release_date": "", - "release_note": "", - "type": 0 - }, "get_led_info": { "led_rule": "night_mode", "led_status": false, "night_mode": { - "end_time": 496, + "end_time": 489, "night_mode_type": "sunrise_sunset", - "start_time": 1034, + "start_time": 1043, "sunrise_offset": 0, "sunset_offset": 0 } diff --git a/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.7.json b/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.7.json index 1cd39621..17df5ac5 100644 --- a/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.7.json +++ b/kasa/tests/fixtures/smart/P300(EU)_1.0_1.0.7.json @@ -170,7 +170,7 @@ "ver_code": 1 } ], - "device_id": "000000000000000000000000000000000000000000" + "device_id": "000000000000000000000000000000000000000001" }, { "component_list": [ @@ -235,7 +235,7 @@ "ver_code": 1 } ], - "device_id": "000000000000000000000000000000000000000000" + "device_id": "000000000000000000000000000000000000000002" }, { "component_list": [ @@ -300,7 +300,7 @@ "ver_code": 1 } ], - "device_id": "000000000000000000000000000000000000000000" + "device_id": "000000000000000000000000000000000000000003" } ], "start_index": 0, @@ -315,7 +315,7 @@ "default_states": { "type": "last_states" }, - "device_id": "000000000000000000000000000000000000000000", + "device_id": "000000000000000000000000000000000000000001", "device_on": true, "fw_id": "00000000000000000000000000000000", "fw_ver": "1.0.7 Build 220715 Rel.200458", @@ -344,7 +344,7 @@ "default_states": { "type": "last_states" }, - "device_id": "000000000000000000000000000000000000000000", + "device_id": "000000000000000000000000000000000000000002", "device_on": true, "fw_id": "00000000000000000000000000000000", "fw_ver": "1.0.7 Build 220715 Rel.200458", @@ -373,7 +373,7 @@ "default_states": { "type": "last_states" }, - "device_id": "000000000000000000000000000000000000000000", + "device_id": "000000000000000000000000000000000000000003", "device_on": true, "fw_id": "00000000000000000000000000000000", "fw_ver": "1.0.7 Build 220715 Rel.200458",