GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add some device fixtures (#948) · pillarsdotnet/python-kasa@13b34f9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • SUPPORTED.md
  • kasa
    • iot
      • iotlightstrip.py
      • modules
        • lightpreset.py
    • tests
      • fixtures
        • HS110(US)_1.0_1.2.6.json
        • HS300(US)_1.0_1.0.21.json
        • KL120(US)_1.0_1.8.11.json
        • KL430(US)_1.0_1.0.10.json
      • test_bulb.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎SUPPORTED.md‎

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 numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
2929
- **HS110**
3030
- Hardware: 1.0 (EU) / Firmware: 1.2.5
3131
- Hardware: 4.0 (EU) / Firmware: 1.0.4
32+
- Hardware: 1.0 (US) / Firmware: 1.2.6
3233
- **KP100**
3334
- Hardware: 3.0 (US) / Firmware: 1.0.1
3435
- **KP105**
@@ -53,6 +54,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
5354
- Hardware: 1.0 (US) / Firmware: 1.0.8
5455
- **HS300**
5556
- Hardware: 1.0 (US) / Firmware: 1.0.10
57+
- Hardware: 1.0 (US) / Firmware: 1.0.21
5658
- Hardware: 2.0 (US) / Firmware: 1.0.12
5759
- Hardware: 2.0 (US) / Firmware: 1.0.3
5860
- **KP200**
@@ -97,6 +99,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
9799
- **KL110**
98100
- Hardware: 1.0 (US) / Firmware: 1.8.11
99101
- **KL120**
102+
- Hardware: 1.0 (US) / Firmware: 1.8.11
100103
- Hardware: 1.0 (US) / Firmware: 1.8.6
101104
- **KL125**
102105
- Hardware: 1.20 (US) / Firmware: 1.0.5
Collapse file

‎kasa/iot/iotlightstrip.py‎

Copy file name to clipboardExpand all lines: kasa/iot/iotlightstrip.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class IotLightStrip(IotBulb):
3333
Currently active effect:
3434
3535
>>> strip.effect
36-
{'brightness': 50, 'custom': 0, 'enable': 0, 'id': '', 'name': ''}
36+
{'brightness': 100, 'custom': 0, 'enable': 0,
37+
'id': 'bCTItKETDFfrKANolgldxfgOakaarARs', 'name': 'Flicker'}
3738
3839
.. note::
3940
The device supports some features that are not currently implemented,
Collapse file

‎kasa/iot/modules/lightpreset.py‎

Copy file name to clipboardExpand all lines: kasa/iot/modules/lightpreset.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def _post_update_hook(self):
4545
self._presets = {
4646
f"Light preset {index+1}": IotLightPreset(**vals)
4747
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
4851
}
4952
self._preset_list = [self.PRESET_NOT_SET]
5053
self._preset_list.extend(self._presets.keys())
@@ -133,7 +136,9 @@ def query(self):
133136
def _deprecated_presets(self) -> list[IotLightPreset]:
134137
"""Return a list of available bulb setting presets."""
135138
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
137142
]
138143

139144
async def _deprecated_save_preset(self, preset: IotLightPreset):
Collapse file

‎kasa/tests/fixtures/HS110(US)_1.0_1.2.6.json‎

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

‎kasa/tests/fixtures/HS300(US)_1.0_1.0.21.json‎

Copy file name to clipboard
+89Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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

‎kasa/tests/fixtures/KL120(US)_1.0_1.8.11.json‎

Copy file name to clipboard
+85Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

‎kasa/tests/fixtures/KL430(US)_1.0_1.0.10.json‎

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 numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"get_realtime": {
88
"current_ma": 0,
99
"err_code": 0,
10-
"power_mw": 8729,
11-
"total_wh": 21,
10+
"power_mw": 2725,
11+
"total_wh": 1193,
1212
"voltage_mv": 0
1313
}
1414
},
@@ -22,7 +22,7 @@
2222
},
2323
"system": {
2424
"get_sysinfo": {
25-
"active_mode": "none",
25+
"active_mode": "schedule",
2626
"alias": "Bedroom Lightstrip",
2727
"ctrl_protocols": {
2828
"name": "Linkie",
@@ -42,27 +42,66 @@
4242
"latitude_i": 0,
4343
"length": 16,
4444
"light_state": {
45-
"brightness": 50,
46-
"color_temp": 3630,
45+
"brightness": 15,
46+
"color_temp": 2500,
4747
"hue": 0,
4848
"mode": "normal",
4949
"on_off": 1,
5050
"saturation": 0
5151
},
5252
"lighting_effect_state": {
53-
"brightness": 50,
53+
"brightness": 100,
5454
"custom": 0,
5555
"enable": 0,
56-
"id": "",
57-
"name": ""
56+
"id": "bCTItKETDFfrKANolgldxfgOakaarARs",
57+
"name": "Flicker"
5858
},
5959
"longitude_i": 0,
60-
"mic_mac": "CC32E5230F55",
60+
"mic_mac": "CC32E5000000",
6161
"mic_type": "IOT.SMARTBULB",
6262
"model": "KL430(US)",
6363
"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,
66105
"status": "new",
67106
"sw_ver": "1.0.10 Build 200522 Rel.104340"
68107
}
Collapse file

‎kasa/tests/test_bulb.py‎

Copy file name to clipboardExpand all lines: kasa/tests/test_bulb.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,17 @@ async def test_ignore_default_not_set_without_color_mode_change_turn_on(
283283
@bulb_iot
284284
async def test_list_presets(dev: IotBulb):
285285
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):
289294
assert preset.index == raw["index"]
290-
assert preset.hue == raw["hue"]
291295
assert preset.brightness == raw["brightness"]
296+
assert preset.hue == raw["hue"]
292297
assert preset.saturation == raw["saturation"]
293298
assert preset.color_temp == raw["color_temp"]
294299

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.