From 2b881cfd7b3ab19952a56b4e5e7c1523a171e76c Mon Sep 17 00:00:00 2001 From: Giovanni Date: Sat, 30 Aug 2025 10:42:53 -0400 Subject: [PATCH] Add device fixture for P316M(US) (#1568) Adds device fixture and updates powerprotection module to accept the changed enabled key. --------- Co-authored-by: komodo Co-authored-by: Teemu Rytilahti --- README.md | 2 +- SUPPORTED.md | 2 + kasa/smart/modules/powerprotection.py | 9 +- tests/device_fixtures.py | 2 +- tests/fixtures/smart/P316M(US)_1.6_1.0.5.json | 3485 +++++++++++++++++ tests/smart/modules/test_powerprotection.py | 48 +- 6 files changed, 3524 insertions(+), 24 deletions(-) create mode 100644 tests/fixtures/smart/P316M(US)_1.6_1.0.5.json diff --git a/README.md b/README.md index 778ef21e..39c2d409 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,7 @@ The following devices have been tested and confirmed as working. If your device ### Supported Tapo[^1] devices - **Plugs**: P100, P110, P110M, P115, P125M, P135, TP10, TP15 -- **Power Strips**: P210M, P300, P304M, P306, TP25 +- **Power Strips**: P210M, P300, P304M, P306, P316M, TP25 - **Wall Switches**: S210, S220, S500, S500D, S505, S505D - **Bulbs**: L510B, L510E, L530B, L530E, L535E, L630 - **Light Strips**: L900-10, L900-5, L920-5, L930-5 diff --git a/SUPPORTED.md b/SUPPORTED.md index 5b65aa60..9abbefed 100644 --- a/SUPPORTED.md +++ b/SUPPORTED.md @@ -228,6 +228,8 @@ All Tapo devices require authentication.
Hub-Connected Devices may work acros - Hardware: 1.0 (UK) / Firmware: 1.0.3 - **P306** - Hardware: 1.0 (US) / Firmware: 1.1.2 +- **P316M** + - Hardware: 1.6 (US) / Firmware: 1.0.5 - **TP25** - Hardware: 1.0 (US) / Firmware: 1.0.2 diff --git a/kasa/smart/modules/powerprotection.py b/kasa/smart/modules/powerprotection.py index ff7e726d..9e6498ce 100644 --- a/kasa/smart/modules/powerprotection.py +++ b/kasa/smart/modules/powerprotection.py @@ -57,7 +57,9 @@ class PowerProtection(SmartModule): @property def enabled(self) -> bool: """Return True if child protection is enabled.""" - return self.data["get_protection_power"]["enabled"] + settings = self.data["get_protection_power"] + enabled_key = next(k for k in settings if "enabled" in k) + return settings[enabled_key] async def set_enabled(self, enabled: bool, *, threshold: int | None = None) -> dict: """Set power protection enabled. @@ -73,7 +75,10 @@ class PowerProtection(SmartModule): "Threshold out of range: %s (%s)", threshold, self.protection_threshold ) - params = {**self.data["get_protection_power"], "enabled": enabled} + enabled_key = next( + k for k in self.data["get_protection_power"] if "enabled" in k + ) + params = {**self.data["get_protection_power"], enabled_key: enabled} if threshold is not None: params["protection_power"] = threshold return await self.call("set_protection_power", params) diff --git a/tests/device_fixtures.py b/tests/device_fixtures.py index 507982bd..8b53446f 100644 --- a/tests/device_fixtures.py +++ b/tests/device_fixtures.py @@ -112,7 +112,7 @@ SWITCHES_SMART = { } SWITCHES = {*SWITCHES_IOT, *SWITCHES_SMART} STRIPS_IOT = {"HS107", "HS300", "KP303", "KP200", "KP400", "EP40"} -STRIPS_SMART = {"P300", "P304M", "TP25", "EP40M", "P210M", "P306"} +STRIPS_SMART = {"P300", "P304M", "TP25", "EP40M", "P210M", "P306", "P316M"} STRIPS = {*STRIPS_IOT, *STRIPS_SMART} DIMMERS_IOT = {"ES20M", "HS220", "KS220", "KS220M", "KS230", "KP405"} diff --git a/tests/fixtures/smart/P316M(US)_1.6_1.0.5.json b/tests/fixtures/smart/P316M(US)_1.6_1.0.5.json new file mode 100644 index 00000000..98f33d3d --- /dev/null +++ b/tests/fixtures/smart/P316M(US)_1.6_1.0.5.json @@ -0,0 +1,3485 @@ +{ + "child_devices": { + "SCRUBBED_CHILD_DEVICE_ID_1": { + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 0 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_1", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "2379878FD20427DA56CDE7809167A79E", + "hw_ver": "1.6", + "is_usb": false, + "latitude": -1879048193, + "longitude": -1879048193, + "mac": "A829481CEB5D", + "model": "P316M", + "nickname": "U21hcnQgUGx1ZyAx", + "oem_id": "B956FCA0B4CAEE8BE9E3E923D29DC8A0", + "on_off": 1, + "on_time": 2255, + "original_device_id": "8022F9F21DB6889D90BF8E7AAB04CD47242AAAF9", + "overcurrent_status": "normal", + "position": 1, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + "get_device_usage": { + "power_usage": { + "past30": 0, + "past7": 0, + "today": 0 + }, + "saved_power": { + "past30": 36, + "past7": 36, + "today": 36 + }, + "time_usage": { + "past30": 36, + "past7": 36, + "today": 36 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 0, + "energy_wh": 0, + "power_mw": 0, + "voltage_mv": 120209 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:43", + "month_energy": 0, + "month_runtime": 36, + "today_energy": 0, + "today_runtime": 36 + }, + "get_max_power": { + "max_power": 1644 + }, + "get_next_event": {}, + "get_protection_power": { + "protection_enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + } + }, + "SCRUBBED_CHILD_DEVICE_ID_2": { + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 0 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_2", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "2379878FD20427DA56CDE7809167A79E", + "hw_ver": "1.6", + "is_usb": false, + "latitude": -1879048193, + "longitude": -1879048193, + "mac": "A829481CEB5D", + "model": "P316M", + "nickname": "U21hcnQgUGx1ZyAy", + "oem_id": "B956FCA0B4CAEE8BE9E3E923D29DC8A0", + "on_off": 1, + "on_time": 2256, + "original_device_id": "8022F9F21DB6889D90BF8E7AAB04CD47242AAAF9", + "overcurrent_status": "normal", + "position": 2, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + "get_device_usage": { + "power_usage": { + "past30": 0, + "past7": 0, + "today": 0 + }, + "saved_power": { + "past30": 36, + "past7": 36, + "today": 36 + }, + "time_usage": { + "past30": 36, + "past7": 36, + "today": 36 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 0, + "energy_wh": 0, + "power_mw": 0, + "voltage_mv": 120118 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:44", + "month_energy": 0, + "month_runtime": 36, + "today_energy": 0, + "today_runtime": 36 + }, + "get_max_power": { + "max_power": 1643 + }, + "get_next_event": {}, + "get_protection_power": { + "protection_enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + } + }, + "SCRUBBED_CHILD_DEVICE_ID_3": { + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 38 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_3", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "2379878FD20427DA56CDE7809167A79E", + "hw_ver": "1.6", + "is_usb": false, + "latitude": -1879048193, + "longitude": -1879048193, + "mac": "A829481CEB5D", + "model": "P316M", + "nickname": "U21hcnQgUGx1ZyAz", + "oem_id": "B956FCA0B4CAEE8BE9E3E923D29DC8A0", + "on_off": 1, + "on_time": 2256, + "original_device_id": "8022F9F21DB6889D90BF8E7AAB04CD47242AAAF9", + "overcurrent_status": "normal", + "position": 3, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + "get_device_usage": { + "power_usage": { + "past30": 23, + "past7": 23, + "today": 23 + }, + "saved_power": { + "past30": 13, + "past7": 13, + "today": 13 + }, + "time_usage": { + "past30": 36, + "past7": 36, + "today": 36 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 335, + "energy_wh": 23, + "power_mw": 38617, + "voltage_mv": 119299 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:44", + "month_energy": 23, + "month_runtime": 36, + "today_energy": 23, + "today_runtime": 36 + }, + "get_max_power": { + "max_power": 1633 + }, + "get_next_event": {}, + "get_protection_power": { + "protection_enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + } + }, + "SCRUBBED_CHILD_DEVICE_ID_4": { + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 1 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_4", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "2379878FD20427DA56CDE7809167A79E", + "hw_ver": "1.6", + "is_usb": false, + "latitude": -1879048193, + "longitude": -1879048193, + "mac": "A829481CEB5D", + "model": "P316M", + "nickname": "U21hcnQgUGx1ZyA0", + "oem_id": "B956FCA0B4CAEE8BE9E3E923D29DC8A0", + "on_off": 1, + "on_time": 2257, + "original_device_id": "8022F9F21DB6889D90BF8E7AAB04CD47242AAAF9", + "overcurrent_status": "normal", + "position": 4, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + "get_device_usage": { + "power_usage": { + "past30": 0, + "past7": 0, + "today": 0 + }, + "saved_power": { + "past30": 36, + "past7": 36, + "today": 36 + }, + "time_usage": { + "past30": 36, + "past7": 36, + "today": 36 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 85, + "energy_wh": 0, + "power_mw": 1999, + "voltage_mv": 119801 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:45", + "month_energy": 0, + "month_runtime": 36, + "today_energy": 0, + "today_runtime": 36 + }, + "get_max_power": { + "max_power": 1638 + }, + "get_next_event": {}, + "get_protection_power": { + "protection_enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + } + }, + "SCRUBBED_CHILD_DEVICE_ID_5": { + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 0 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_5", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "2379878FD20427DA56CDE7809167A79E", + "hw_ver": "1.6", + "is_usb": false, + "latitude": -1879048193, + "longitude": -1879048193, + "mac": "A829481CEB5D", + "model": "P316M", + "nickname": "U21hcnQgUGx1ZyA1", + "oem_id": "B956FCA0B4CAEE8BE9E3E923D29DC8A0", + "on_off": 1, + "on_time": 2257, + "original_device_id": "8022F9F21DB6889D90BF8E7AAB04CD47242AAAF9", + "overcurrent_status": "normal", + "position": 5, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + "get_device_usage": { + "power_usage": { + "past30": 0, + "past7": 0, + "today": 0 + }, + "saved_power": { + "past30": 36, + "past7": 36, + "today": 36 + }, + "time_usage": { + "past30": 36, + "past7": 36, + "today": 36 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 0, + "energy_wh": 0, + "power_mw": 0, + "voltage_mv": 120047 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:45", + "month_energy": 0, + "month_runtime": 36, + "today_energy": 0, + "today_runtime": 36 + }, + "get_max_power": { + "max_power": 1642 + }, + "get_next_event": {}, + "get_protection_power": { + "protection_enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + } + }, + "SCRUBBED_CHILD_DEVICE_ID_6": { + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "get_antitheft_rules": { + "antitheft_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_auto_off_config": { + "delay_min": 120, + "enable": false + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_countdown_rules": { + "countdown_rule_max_count": 1, + "enable": false, + "rule_list": [] + }, + "get_current_power": { + "current_power": 0 + }, + "get_device_info": { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_6", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "2379878FD20427DA56CDE7809167A79E", + "hw_ver": "1.6", + "is_usb": false, + "latitude": -1879048193, + "longitude": -1879048193, + "mac": "A829481CEB5D", + "model": "P316M", + "nickname": "U21hcnQgUGx1ZyA2", + "oem_id": "B956FCA0B4CAEE8BE9E3E923D29DC8A0", + "on_off": 1, + "on_time": 2257, + "original_device_id": "8022F9F21DB6889D90BF8E7AAB04CD47242AAAF9", + "overcurrent_status": "normal", + "position": 6, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + "get_device_usage": { + "power_usage": { + "past30": 0, + "past7": 0, + "today": 0 + }, + "saved_power": { + "past30": 36, + "past7": 36, + "today": 36 + }, + "time_usage": { + "past30": 36, + "past7": 36, + "today": 36 + } + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 0, + "energy_wh": 0, + "power_mw": 0, + "voltage_mv": 119868 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:45", + "month_energy": 0, + "month_runtime": 36, + "today_energy": 0, + "today_runtime": 36 + }, + "get_max_power": { + "max_power": 1639 + }, + "get_next_event": {}, + "get_protection_power": { + "protection_enabled": false, + "protection_power": 0 + }, + "get_schedule_rules": { + "enable": false, + "rule_list": [], + "schedule_rule_max_count": 32, + "start_index": 0, + "sum": 0 + } + } + }, + "component_nego": { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "wireless", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "led", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "control_child", + "ver_code": 2 + }, + { + "id": "child_device", + "ver_code": 2 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "matter", + "ver_code": 3 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ] + }, + "discovery_result": { + "error_code": 0, + "result": { + "device_id": "00000000000000000000000000000000", + "device_model": "P316M(US)", + "device_type": "SMART.TAPOPLUG", + "factory_default": false, + "ip": "127.0.0.123", + "is_support_iot_cloud": true, + "mac": "A8-29-48-00-00-00", + "mgt_encrypt_schm": { + "encrypt_type": "KLAP", + "http_port": 80, + "is_support_https": false, + "lv": 2 + }, + "obd_src": "tplink", + "owner": "00000000000000000000000000000000", + "protocol_version": 1 + } + }, + "get_auto_update_info": { + "enable": true, + "random_range": 120, + "time": 180 + }, + "get_child_device_component_list": { + "child_component_list": [ + { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ], + "device_id": "SCRUBBED_CHILD_DEVICE_ID_1" + }, + { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ], + "device_id": "SCRUBBED_CHILD_DEVICE_ID_2" + }, + { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ], + "device_id": "SCRUBBED_CHILD_DEVICE_ID_3" + }, + { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ], + "device_id": "SCRUBBED_CHILD_DEVICE_ID_4" + }, + { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ], + "device_id": "SCRUBBED_CHILD_DEVICE_ID_5" + }, + { + "component_list": [ + { + "id": "device", + "ver_code": 2 + }, + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "time", + "ver_code": 1 + }, + { + "id": "device_local_time", + "ver_code": 1 + }, + { + "id": "schedule", + "ver_code": 2 + }, + { + "id": "countdown", + "ver_code": 2 + }, + { + "id": "antitheft", + "ver_code": 1 + }, + { + "id": "account", + "ver_code": 1 + }, + { + "id": "synchronize", + "ver_code": 1 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "cloud_connect", + "ver_code": 1 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "default_states", + "ver_code": 1 + }, + { + "id": "localSmart", + "ver_code": 1 + }, + { + "id": "auto_off", + "ver_code": 2 + }, + { + "id": "energy_monitoring", + "ver_code": 2 + }, + { + "id": "current_protection", + "ver_code": 1 + }, + { + "id": "power_protection", + "ver_code": 1 + }, + { + "id": "charging_protection", + "ver_code": 2 + } + ], + "device_id": "SCRUBBED_CHILD_DEVICE_ID_6" + } + ], + "start_index": 0, + "sum": 6 + }, + "get_child_device_list": { + "child_device_list": [ + { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_1", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "is_usb": false, + "latitude": 0, + "longitude": 0, + "mac": "A82948000000", + "model": "P316M", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_off": 1, + "on_time": 2253, + "original_device_id": "0000000000000000000000000000000000000000", + "overcurrent_status": "normal", + "position": 1, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_2", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "is_usb": false, + "latitude": 0, + "longitude": 0, + "mac": "A82948000000", + "model": "P316M", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_off": 1, + "on_time": 2253, + "original_device_id": "0000000000000000000000000000000000000000", + "overcurrent_status": "normal", + "position": 2, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_3", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "is_usb": false, + "latitude": 0, + "longitude": 0, + "mac": "A82948000000", + "model": "P316M", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_off": 1, + "on_time": 2253, + "original_device_id": "0000000000000000000000000000000000000000", + "overcurrent_status": "normal", + "position": 3, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_4", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "is_usb": false, + "latitude": 0, + "longitude": 0, + "mac": "A82948000000", + "model": "P316M", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_off": 1, + "on_time": 2253, + "original_device_id": "0000000000000000000000000000000000000000", + "overcurrent_status": "normal", + "position": 4, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_5", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "is_usb": false, + "latitude": 0, + "longitude": 0, + "mac": "A82948000000", + "model": "P316M", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_off": 1, + "on_time": 2253, + "original_device_id": "0000000000000000000000000000000000000000", + "overcurrent_status": "normal", + "position": 5, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + }, + { + "auto_off_remain_time": 0, + "auto_off_status": "off", + "avatar": "plug", + "bind_count": 1, + "category": "plug.powerstrip.sub-plug", + "charging_status": "normal", + "default_states": { + "type": "last_states" + }, + "device_id": "SCRUBBED_CHILD_DEVICE_ID_6", + "device_on": true, + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "is_usb": false, + "latitude": 0, + "longitude": 0, + "mac": "A82948000000", + "model": "P316M", + "nickname": "I01BU0tFRF9OQU1FIw==", + "oem_id": "00000000000000000000000000000000", + "on_off": 1, + "on_time": 2253, + "original_device_id": "0000000000000000000000000000000000000000", + "overcurrent_status": "normal", + "position": 6, + "power_protection_status": "normal", + "region": "America/New_York", + "slot_number": 6, + "status_follow_edge": true, + "type": "SMART.TAPOPLUG" + } + ], + "start_index": 0, + "sum": 6 + }, + "get_connect_cloud_state": { + "status": 0 + }, + "get_current_power": { + "current_power": 0 + }, + "get_device_info": { + "avatar": "", + "device_id": "0000000000000000000000000000000000000000", + "fw_id": "00000000000000000000000000000000", + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "has_set_location_info": false, + "hw_id": "00000000000000000000000000000000", + "hw_ver": "1.6", + "ip": "127.0.0.123", + "lang": "", + "latitude": 0, + "longitude": 0, + "mac": "A8-29-48-00-00-00", + "model": "P316M", + "nickname": "", + "oem_id": "00000000000000000000000000000000", + "region": "America/New_York", + "rssi": -47, + "signal_level": 3, + "specs": "US", + "ssid": "I01BU0tFRF9TU0lEIw==", + "time_diff": -300, + "type": "SMART.TAPOPLUG" + }, + "get_device_time": { + "region": "America/New_York", + "time_diff": -300, + "timestamp": 1753309182 + }, + "get_electricity_price_config": { + "constant_price": 0, + "time_of_use_config": { + "summer": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + }, + "winter": { + "midpeak": 0, + "offpeak": 0, + "onpeak": 0, + "period": [ + 0, + 0, + 0, + 0 + ], + "weekday_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + "weekend_config": [ + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ] + } + }, + "type": "constant" + }, + "get_emeter_data": { + "current_ma": 0, + "energy_wh": 0, + "power_mw": 0, + "voltage_mv": 120209 + }, + "get_emeter_vgain_igain": { + "data": [ + { + "igain": 3821, + "slot_id": 0, + "vgain": 30247 + }, + { + "igain": 3821, + "slot_id": 1, + "vgain": 30224 + }, + { + "igain": 3821, + "slot_id": 2, + "vgain": 29991 + }, + { + "igain": 3803, + "slot_id": 3, + "vgain": 30096 + }, + { + "igain": 3779, + "slot_id": 4, + "vgain": 30203 + }, + { + "igain": 3852, + "slot_id": 5, + "vgain": 30158 + } + ] + }, + "get_energy_usage": { + "current_power": 0, + "electricity_charge": [ + 0, + 0, + 0 + ], + "local_time": "2025-07-23 18:19:43", + "month_energy": 0, + "month_runtime": 36, + "today_energy": 0, + "today_runtime": 36 + }, + "get_fw_download_state": { + "auto_upgrade": false, + "download_progress": 0, + "reboot_time": 5, + "status": 0, + "upgrade_time": 5 + }, + "get_latest_fw": { + "fw_size": 0, + "fw_ver": "1.0.5 Build 250306 Rel.151943", + "hw_id": "", + "need_to_upgrade": false, + "oem_id": "", + "release_date": "", + "release_note": "", + "type": 0 + }, + "get_led_info": { + "led_rule": "always", + "led_status": true, + "night_mode": { + "end_time": 420, + "night_mode_type": "custom", + "start_time": 1320 + } + }, + "get_matter_setup_info": { + "setup_code": "00000000000", + "setup_payload": "00:0000000000000000000" + }, + "get_max_power": { + "max_power": 1644 + }, + "get_protection_power": { + "enabled": false, + "protection_power": 0 + }, + "get_wireless_scan_info": { + "ap_list": [ + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 3, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 3, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 3, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 3, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 2, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + { + "bssid": "000000000000", + "channel": 0, + "cipher_type": 2, + "key_type": "wpa2_psk", + "signal_level": 1, + "ssid": "I01BU0tFRF9TU0lEIw==" + } + ], + "start_index": 0, + "sum": 21, + "wep_supported": false + }, + "qs_component_nego": { + "component_list": [ + { + "id": "quick_setup", + "ver_code": 3 + }, + { + "id": "sunrise_sunset", + "ver_code": 1 + }, + { + "id": "ble_whole_setup", + "ver_code": 1 + }, + { + "id": "matter", + "ver_code": 3 + }, + { + "id": "iot_cloud", + "ver_code": 1 + }, + { + "id": "inherit", + "ver_code": 1 + }, + { + "id": "firmware", + "ver_code": 2 + }, + { + "id": "control_child", + "ver_code": 2 + }, + { + "id": "child_device", + "ver_code": 2 + } + ], + "extra_info": { + "device_model": "P316M", + "device_type": "SMART.TAPOPLUG", + "is_klap": true + } + } +} diff --git a/tests/smart/modules/test_powerprotection.py b/tests/smart/modules/test_powerprotection.py index 7f03c0e9..b536ee1d 100644 --- a/tests/smart/modules/test_powerprotection.py +++ b/tests/smart/modules/test_powerprotection.py @@ -48,33 +48,40 @@ async def test_set_enable(dev: SmartDevice, mocker: MockerFixture): # Simple enable with an existing threshold call_spy = mocker.spy(powerprot, "call") await powerprot.set_enabled(True) - params = { - "enabled": True, - "protection_power": mocker.ANY, - } - call_spy.assert_called_with("set_protection_power", params) + + args, kwargs = call_spy.call_args + method, params = args + assert method == "set_protection_power" + + enabled_key = next( + k for k in powerprot.data["get_protection_power"] if "enabled" in k + ) + assert params[enabled_key] is True + assert params["protection_power"] is not None # Enable with no threshold param when 0 call_spy.reset_mock() await powerprot.set_protection_threshold(0) await device.update() await powerprot.set_enabled(True) - params = { - "enabled": True, - "protection_power": int(powerprot._max_power / 2), - } - call_spy.assert_called_with("set_protection_power", params) + + args, kwargs = call_spy.call_args + method, params = args + assert method == "set_protection_power" + assert "enabled" in params or "protection_enabled" in params + assert params["protection_power"] == int(powerprot._max_power / 2) # Enable false should not update the threshold call_spy.reset_mock() await powerprot.set_protection_threshold(0) await device.update() await powerprot.set_enabled(False) - params = { - "enabled": False, - "protection_power": 0, - } - call_spy.assert_called_with("set_protection_power", params) + + args, kwargs = call_spy.call_args + method, params = args + assert method == "set_protection_power" + assert "enabled" in params or "protection_enabled" in params + assert params["protection_power"] == 0 finally: await powerprot.set_enabled(original_enabled, threshold=original_threshold) @@ -88,11 +95,12 @@ async def test_set_threshold(dev: SmartDevice, mocker: MockerFixture): call_spy = mocker.spy(powerprot, "call") await powerprot.set_protection_threshold(123) - params = { - "enabled": mocker.ANY, - "protection_power": 123, - } - call_spy.assert_called_with("set_protection_power", params) + + args, kwargs = call_spy.call_args + method, params = args + assert method == "set_protection_power" + assert "enabled" in params or "protection_enabled" in params + assert params["protection_power"] == 123 with pytest.raises(ValueError, match="Threshold out of range"): await powerprot.set_protection_threshold(-10)