GeezerVison is showing github.com — Add some device fixtures (#948) · pillarsdotnet/python-kasa@13b34f9
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: SUPPORTED.md +3Lines changed: 3 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su | 29 | 29 | - **HS110** | 30 | 30 | - Hardware: 1.0 (EU) / Firmware: 1.2.5 | 31 | 31 | - Hardware: 4.0 (EU) / Firmware: 1.0.4 | | 32 | + - Hardware: 1.0 (US) / Firmware: 1.2.6 | 32 | 33 | - **KP100** | 33 | 34 | - Hardware: 3.0 (US) / Firmware: 1.0.1 | 34 | 35 | - **KP105** | @@ -53,6 +54,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su | 53 | 54 | - Hardware: 1.0 (US) / Firmware: 1.0.8 | 54 | 55 | - **HS300** | 55 | 56 | - Hardware: 1.0 (US) / Firmware: 1.0.10 | | 57 | + - Hardware: 1.0 (US) / Firmware: 1.0.21 | 56 | 58 | - Hardware: 2.0 (US) / Firmware: 1.0.12 | 57 | 59 | - Hardware: 2.0 (US) / Firmware: 1.0.3 | 58 | 60 | - **KP200** | @@ -97,6 +99,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su | 97 | 99 | - **KL110** | 98 | 100 | - Hardware: 1.0 (US) / Firmware: 1.8.11 | 99 | 101 | - **KL120** | | 102 | + - Hardware: 1.0 (US) / Firmware: 1.8.11 | 100 | 103 | - Hardware: 1.0 (US) / Firmware: 1.8.6 | 101 | 104 | - **KL125** | 102 | 105 | - Hardware: 1.20 (US) / Firmware: 1.0.5 | |
Collapse file Copy file name to clipboardExpand all lines: kasa/iot/iotlightstrip.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,7 +33,8 @@ class IotLightStrip(IotBulb): | 33 | 33 | Currently active effect: | 34 | 34 |
| 35 | 35 | >>> strip.effect | 36 | | - {'brightness': 50, 'custom': 0, 'enable': 0, 'id': '', 'name': ''} | | 36 | + {'brightness': 100, 'custom': 0, 'enable': 0, | | 37 | + 'id': 'bCTItKETDFfrKANolgldxfgOakaarARs', 'name': 'Flicker'} | 37 | 38 |
| 38 | 39 | .. note:: | 39 | 40 | The device supports some features that are not currently implemented, | |
Collapse file Copy file name to clipboardExpand all lines: kasa/iot/modules/lightpreset.py +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,9 @@ def _post_update_hook(self): | 45 | 45 | self._presets = { | 46 | 46 | f"Light preset {index+1}": IotLightPreset(**vals) | 47 | 47 | for index, vals in enumerate(self.data["preferred_state"]) | | 48 | + # Devices may list some light effects along with normal presets but these | | 49 | + # are handled by the LightEffect module so exclude preferred states with id | | 50 | + if "id" not in vals | 48 | 51 | } | 49 | 52 | self._preset_list = [self.PRESET_NOT_SET] | 50 | 53 | self._preset_list.extend(self._presets.keys()) | @@ -133,7 +136,9 @@ def query(self): | 133 | 136 | def _deprecated_presets(self) -> list[IotLightPreset]: | 134 | 137 | """Return a list of available bulb setting presets.""" | 135 | 138 | return [ | 136 | | - IotLightPreset(**vals) for vals in self._device.sys_info["preferred_state"] | | 139 | + IotLightPreset(**vals) | | 140 | + for vals in self._device.sys_info["preferred_state"] | | 141 | + if "id" not in vals | 137 | 142 | ] | 138 | 143 |
| 139 | 144 | async def _deprecated_save_preset(self, preset: IotLightPreset): | |
Collapse file Copy file name to clipboard +37Lines changed: 37 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "emeter": { | | 3 | + "get_realtime": { | | 4 | + "current": 0.128037, | | 5 | + "err_code": 0, | | 6 | + "power": 7.677094, | | 7 | + "total": 30.404, | | 8 | + "voltage": 118.917389 | | 9 | + } | | 10 | + }, | | 11 | + "system": { | | 12 | + "get_sysinfo": { | | 13 | + "active_mode": "schedule", | | 14 | + "alias": "Home Google WiFi HS110", | | 15 | + "dev_name": "Wi-Fi Smart Plug With Energy Monitoring", | | 16 | + "deviceId": "0000000000000000000000000000000000000000", | | 17 | + "err_code": 0, | | 18 | + "feature": "TIM:ENE", | | 19 | + "fwId": "00000000000000000000000000000000", | | 20 | + "hwId": "00000000000000000000000000000000", | | 21 | + "hw_ver": "1.0", | | 22 | + "icon_hash": "", | | 23 | + "latitude": 0, | | 24 | + "led_off": 0, | | 25 | + "longitude": 0, | | 26 | + "mac": "00:00:00:00:00:00", | | 27 | + "model": "HS110(US)", | | 28 | + "oemId": "00000000000000000000000000000000", | | 29 | + "on_time": 14048150, | | 30 | + "relay_state": 1, | | 31 | + "rssi": -38, | | 32 | + "sw_ver": "1.2.6 Build 200727 Rel.121701", | | 33 | + "type": "IOT.SMARTPLUGSWITCH", | | 34 | + "updating": 0 | | 35 | + } | | 36 | + } | | 37 | +} |
Collapse file Copy file name to clipboard +89Lines changed: 89 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "emeter": { | | 3 | + "get_realtime": { | | 4 | + "current_ma": 544, | | 5 | + "err_code": 0, | | 6 | + "power_mw": 62430, | | 7 | + "total_wh": 26889, | | 8 | + "voltage_mv": 118389 | | 9 | + } | | 10 | + }, | | 11 | + "system": { | | 12 | + "get_sysinfo": { | | 13 | + "alias": "TP-LINK_Power Strip_2CA9", | | 14 | + "child_num": 6, | | 15 | + "children": [ | | 16 | + { | | 17 | + "alias": "Home CameraPC", | | 18 | + "id": "800623145DFF1AA096363EFD161C2E661A9D8DED00", | | 19 | + "next_action": { | | 20 | + "type": -1 | | 21 | + }, | | 22 | + "on_time": 1449897, | | 23 | + "state": 1 | | 24 | + }, | | 25 | + { | | 26 | + "alias": "Home Firewalla", | | 27 | + "id": "800623145DFF1AA096363EFD161C2E661A9D8DED01", | | 28 | + "next_action": { | | 29 | + "type": -1 | | 30 | + }, | | 31 | + "on_time": 1449897, | | 32 | + "state": 1 | | 33 | + }, | | 34 | + { | | 35 | + "alias": "Home Cox modem", | | 36 | + "id": "800623145DFF1AA096363EFD161C2E661A9D8DED02", | | 37 | + "next_action": { | | 38 | + "type": -1 | | 39 | + }, | | 40 | + "on_time": 1449897, | | 41 | + "state": 1 | | 42 | + }, | | 43 | + { | | 44 | + "alias": "Home rpi3-2", | | 45 | + "id": "800623145DFF1AA096363EFD161C2E661A9D8DED03", | | 46 | + "next_action": { | | 47 | + "type": -1 | | 48 | + }, | | 49 | + "on_time": 1449897, | | 50 | + "state": 1 | | 51 | + }, | | 52 | + { | | 53 | + "alias": "Home Camera Switch", | | 54 | + "id": "800623145DFF1AA096363EFD161C2E661A9D8DED05", | | 55 | + "next_action": { | | 56 | + "type": -1 | | 57 | + }, | | 58 | + "on_time": 1449897, | | 59 | + "state": 1 | | 60 | + }, | | 61 | + { | | 62 | + "alias": "Home Network Switch", | | 63 | + "id": "800623145DFF1AA096363EFD161C2E661A9D8DED04", | | 64 | + "next_action": { | | 65 | + "type": -1 | | 66 | + }, | | 67 | + "on_time": 1449897, | | 68 | + "state": 1 | | 69 | + } | | 70 | + ], | | 71 | + "deviceId": "0000000000000000000000000000000000000000", | | 72 | + "err_code": 0, | | 73 | + "feature": "TIM:ENE", | | 74 | + "hwId": "00000000000000000000000000000000", | | 75 | + "hw_ver": "1.0", | | 76 | + "latitude_i": 0, | | 77 | + "led_off": 0, | | 78 | + "longitude_i": 0, | | 79 | + "mac": "00:00:00:00:00:00", | | 80 | + "mic_type": "IOT.SMARTPLUGSWITCH", | | 81 | + "model": "HS300(US)", | | 82 | + "oemId": "00000000000000000000000000000000", | | 83 | + "rssi": -39, | | 84 | + "status": "new", | | 85 | + "sw_ver": "1.0.21 Build 210524 Rel.161309", | | 86 | + "updating": 0 | | 87 | + } | | 88 | + } | | 89 | +} |
Collapse file Copy file name to clipboard +85Lines changed: 85 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "smartlife.iot.common.emeter": { | | 3 | + "get_realtime": { | | 4 | + "err_code": 0, | | 5 | + "power_mw": 7800 | | 6 | + } | | 7 | + }, | | 8 | + "smartlife.iot.smartbulb.lightingservice": { | | 9 | + "get_light_state": { | | 10 | + "brightness": 70, | | 11 | + "color_temp": 3001, | | 12 | + "err_code": 0, | | 13 | + "hue": 0, | | 14 | + "mode": "normal", | | 15 | + "on_off": 1, | | 16 | + "saturation": 0 | | 17 | + } | | 18 | + }, | | 19 | + "system": { | | 20 | + "get_sysinfo": { | | 21 | + "active_mode": "none", | | 22 | + "alias": "Home Family Room Table", | | 23 | + "ctrl_protocols": { | | 24 | + "name": "Linkie", | | 25 | + "version": "1.0" | | 26 | + }, | | 27 | + "description": "Smart Wi-Fi LED Bulb with Tunable White Light", | | 28 | + "dev_state": "normal", | | 29 | + "deviceId": "0000000000000000000000000000000000000000", | | 30 | + "disco_ver": "1.0", | | 31 | + "err_code": 0, | | 32 | + "heapsize": 292140, | | 33 | + "hwId": "00000000000000000000000000000000", | | 34 | + "hw_ver": "1.0", | | 35 | + "is_color": 0, | | 36 | + "is_dimmable": 1, | | 37 | + "is_factory": false, | | 38 | + "is_variable_color_temp": 1, | | 39 | + "light_state": { | | 40 | + "brightness": 70, | | 41 | + "color_temp": 3001, | | 42 | + "hue": 0, | | 43 | + "mode": "normal", | | 44 | + "on_off": 1, | | 45 | + "saturation": 0 | | 46 | + }, | | 47 | + "mic_mac": "000000000000", | | 48 | + "mic_type": "IOT.SMARTBULB", | | 49 | + "model": "KL120(US)", | | 50 | + "oemId": "00000000000000000000000000000000", | | 51 | + "preferred_state": [ | | 52 | + { | | 53 | + "brightness": 100, | | 54 | + "color_temp": 3500, | | 55 | + "hue": 0, | | 56 | + "index": 0, | | 57 | + "saturation": 0 | | 58 | + }, | | 59 | + { | | 60 | + "brightness": 50, | | 61 | + "color_temp": 5000, | | 62 | + "hue": 0, | | 63 | + "index": 1, | | 64 | + "saturation": 0 | | 65 | + }, | | 66 | + { | | 67 | + "brightness": 50, | | 68 | + "color_temp": 2700, | | 69 | + "hue": 0, | | 70 | + "index": 2, | | 71 | + "saturation": 0 | | 72 | + }, | | 73 | + { | | 74 | + "brightness": 1, | | 75 | + "color_temp": 2700, | | 76 | + "hue": 0, | | 77 | + "index": 3, | | 78 | + "saturation": 0 | | 79 | + } | | 80 | + ], | | 81 | + "rssi": -45, | | 82 | + "sw_ver": "1.8.11 Build 191113 Rel.105336" | | 83 | + } | | 84 | + } | | 85 | +} |
Collapse file Copy file name to clipboardExpand all lines: kasa/tests/fixtures/KL430(US)_1.0_1.0.10.json +50-11Lines changed: 50 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | "get_realtime": { | 8 | 8 | "current_ma": 0, | 9 | 9 | "err_code": 0, | 10 | | - "power_mw": 8729, | 11 | | - "total_wh": 21, | | 10 | + "power_mw": 2725, | | 11 | + "total_wh": 1193, | 12 | 12 | "voltage_mv": 0 | 13 | 13 | } | 14 | 14 | }, | | 22 | 22 | }, | 23 | 23 | "system": { | 24 | 24 | "get_sysinfo": { | 25 | | - "active_mode": "none", | | 25 | + "active_mode": "schedule", | 26 | 26 | "alias": "Bedroom Lightstrip", | 27 | 27 | "ctrl_protocols": { | 28 | 28 | "name": "Linkie", | | 42 | 42 | "latitude_i": 0, | 43 | 43 | "length": 16, | 44 | 44 | "light_state": { | 45 | | - "brightness": 50, | 46 | | - "color_temp": 3630, | | 45 | + "brightness": 15, | | 46 | + "color_temp": 2500, | 47 | 47 | "hue": 0, | 48 | 48 | "mode": "normal", | 49 | 49 | "on_off": 1, | 50 | 50 | "saturation": 0 | 51 | 51 | }, | 52 | 52 | "lighting_effect_state": { | 53 | | - "brightness": 50, | | 53 | + "brightness": 100, | 54 | 54 | "custom": 0, | 55 | 55 | "enable": 0, | 56 | | - "id": "", | 57 | | - "name": "" | | 56 | + "id": "bCTItKETDFfrKANolgldxfgOakaarARs", | | 57 | + "name": "Flicker" | 58 | 58 | }, | 59 | 59 | "longitude_i": 0, | 60 | | - "mic_mac": "CC32E5230F55", | | 60 | + "mic_mac": "CC32E5000000", | 61 | 61 | "mic_type": "IOT.SMARTBULB", | 62 | 62 | "model": "KL430(US)", | 63 | 63 | "oemId": "00000000000000000000000000000000", | 64 | | - "preferred_state": [], | 65 | | - "rssi": -56, | | 64 | + "preferred_state": [ | | 65 | + { | | 66 | + "brightness": 100, | | 67 | + "custom": 0, | | 68 | + "id": "QglBhMShPHUAuxLqzNEefFrGiJwahOmz", | | 69 | + "index": 0, | | 70 | + "mode": 2 | | 71 | + }, | | 72 | + { | | 73 | + "brightness": 100, | | 74 | + "custom": 0, | | 75 | + "id": "bCTItKETDFfrKANolgldxfgOakaarARs", | | 76 | + "index": 1, | | 77 | + "mode": 2 | | 78 | + }, | | 79 | + { | | 80 | + "brightness": 34, | | 81 | + "color_temp": 0, | | 82 | + "hue": 7, | | 83 | + "index": 2, | | 84 | + "mode": 1, | | 85 | + "saturation": 49 | | 86 | + }, | | 87 | + { | | 88 | + "brightness": 25, | | 89 | + "color_temp": 0, | | 90 | + "hue": 4, | | 91 | + "index": 3, | | 92 | + "mode": 1, | | 93 | + "saturation": 100 | | 94 | + }, | | 95 | + { | | 96 | + "brightness": 15, | | 97 | + "color_temp": 2500, | | 98 | + "hue": 0, | | 99 | + "index": 4, | | 100 | + "mode": 1, | | 101 | + "saturation": 0 | | 102 | + } | | 103 | + ], | | 104 | + "rssi": -44, | 66 | 105 | "status": "new", | 67 | 106 | "sw_ver": "1.0.10 Build 200522 Rel.104340" | 68 | 107 | } | |
Collapse file Copy file name to clipboardExpand all lines: kasa/tests/test_bulb.py +9-4Lines changed: 9 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -283,12 +283,17 @@ async def test_ignore_default_not_set_without_color_mode_change_turn_on( | 283 | 283 | @bulb_iot | 284 | 284 | async def test_list_presets(dev: IotBulb): | 285 | 285 | presets = dev.presets | 286 | | - assert len(presets) == len(dev.sys_info["preferred_state"]) | 287 | | - | 288 | | - for preset, raw in zip(presets, dev.sys_info["preferred_state"]): | | 286 | + # Light strip devices may list some light effects along with normal presets but these | | 287 | + # are handled by the LightEffect module so exclude preferred states with id | | 288 | + raw_presets = [ | | 289 | + pstate for pstate in dev.sys_info["preferred_state"] if "id" not in pstate | | 290 | + ] | | 291 | + assert len(presets) == len(raw_presets) | | 292 | + | | 293 | + for preset, raw in zip(presets, raw_presets): | 289 | 294 | assert preset.index == raw["index"] | 290 | | - assert preset.hue == raw["hue"] | 291 | 295 | assert preset.brightness == raw["brightness"] | | 296 | + assert preset.hue == raw["hue"] | 292 | 297 | assert preset.saturation == raw["saturation"] | 293 | 298 | assert preset.color_temp == raw["color_temp"] | 294 | 299 |
| |
|