mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
Add some device fixtures (#948)
Adds some device fixtures by courtesy of @jimboca, thanks! This is a slightly patched and rebased version of #441. --------- Co-authored-by: JimBo <jimboca3@gmail.com> Co-authored-by: sdb9696 <steven.beth@gmail.com>
This commit is contained in:
parent
f890fcedc7
commit
40f2263770
@ -29,6 +29,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
|
|||||||
- **HS110**
|
- **HS110**
|
||||||
- Hardware: 1.0 (EU) / Firmware: 1.2.5
|
- Hardware: 1.0 (EU) / Firmware: 1.2.5
|
||||||
- Hardware: 4.0 (EU) / Firmware: 1.0.4
|
- Hardware: 4.0 (EU) / Firmware: 1.0.4
|
||||||
|
- Hardware: 1.0 (US) / Firmware: 1.2.6
|
||||||
- **KP100**
|
- **KP100**
|
||||||
- Hardware: 3.0 (US) / Firmware: 1.0.1
|
- Hardware: 3.0 (US) / Firmware: 1.0.1
|
||||||
- **KP105**
|
- **KP105**
|
||||||
@ -53,6 +54,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
|
|||||||
- Hardware: 1.0 (US) / Firmware: 1.0.8
|
- Hardware: 1.0 (US) / Firmware: 1.0.8
|
||||||
- **HS300**
|
- **HS300**
|
||||||
- Hardware: 1.0 (US) / Firmware: 1.0.10
|
- Hardware: 1.0 (US) / Firmware: 1.0.10
|
||||||
|
- Hardware: 1.0 (US) / Firmware: 1.0.21
|
||||||
- Hardware: 2.0 (US) / Firmware: 1.0.12
|
- Hardware: 2.0 (US) / Firmware: 1.0.12
|
||||||
- Hardware: 2.0 (US) / Firmware: 1.0.3
|
- Hardware: 2.0 (US) / Firmware: 1.0.3
|
||||||
- **KP200**
|
- **KP200**
|
||||||
@ -97,6 +99,7 @@ Some newer Kasa devices require authentication. These are marked with <sup>*</su
|
|||||||
- **KL110**
|
- **KL110**
|
||||||
- Hardware: 1.0 (US) / Firmware: 1.8.11
|
- Hardware: 1.0 (US) / Firmware: 1.8.11
|
||||||
- **KL120**
|
- **KL120**
|
||||||
|
- Hardware: 1.0 (US) / Firmware: 1.8.11
|
||||||
- Hardware: 1.0 (US) / Firmware: 1.8.6
|
- Hardware: 1.0 (US) / Firmware: 1.8.6
|
||||||
- **KL125**
|
- **KL125**
|
||||||
- Hardware: 1.20 (US) / Firmware: 1.0.5
|
- Hardware: 1.20 (US) / Firmware: 1.0.5
|
||||||
|
@ -33,7 +33,8 @@ class IotLightStrip(IotBulb):
|
|||||||
Currently active effect:
|
Currently active effect:
|
||||||
|
|
||||||
>>> strip.effect
|
>>> strip.effect
|
||||||
{'brightness': 50, 'custom': 0, 'enable': 0, 'id': '', 'name': ''}
|
{'brightness': 100, 'custom': 0, 'enable': 0,
|
||||||
|
'id': 'bCTItKETDFfrKANolgldxfgOakaarARs', 'name': 'Flicker'}
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
The device supports some features that are not currently implemented,
|
The device supports some features that are not currently implemented,
|
||||||
|
@ -45,6 +45,9 @@ class LightPreset(IotModule, LightPresetInterface):
|
|||||||
self._presets = {
|
self._presets = {
|
||||||
f"Light preset {index+1}": IotLightPreset(**vals)
|
f"Light preset {index+1}": IotLightPreset(**vals)
|
||||||
for index, vals in enumerate(self.data["preferred_state"])
|
for index, vals in enumerate(self.data["preferred_state"])
|
||||||
|
# Devices may list some light effects along with normal presets but these
|
||||||
|
# are handled by the LightEffect module so exclude preferred states with id
|
||||||
|
if "id" not in vals
|
||||||
}
|
}
|
||||||
self._preset_list = [self.PRESET_NOT_SET]
|
self._preset_list = [self.PRESET_NOT_SET]
|
||||||
self._preset_list.extend(self._presets.keys())
|
self._preset_list.extend(self._presets.keys())
|
||||||
@ -133,7 +136,9 @@ class LightPreset(IotModule, LightPresetInterface):
|
|||||||
def _deprecated_presets(self) -> list[IotLightPreset]:
|
def _deprecated_presets(self) -> list[IotLightPreset]:
|
||||||
"""Return a list of available bulb setting presets."""
|
"""Return a list of available bulb setting presets."""
|
||||||
return [
|
return [
|
||||||
IotLightPreset(**vals) for vals in self._device.sys_info["preferred_state"]
|
IotLightPreset(**vals)
|
||||||
|
for vals in self._device.sys_info["preferred_state"]
|
||||||
|
if "id" not in vals
|
||||||
]
|
]
|
||||||
|
|
||||||
async def _deprecated_save_preset(self, preset: IotLightPreset):
|
async def _deprecated_save_preset(self, preset: IotLightPreset):
|
||||||
|
37
kasa/tests/fixtures/HS110(US)_1.0_1.2.6.json
vendored
Normal file
37
kasa/tests/fixtures/HS110(US)_1.0_1.2.6.json
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"emeter": {
|
||||||
|
"get_realtime": {
|
||||||
|
"current": 0.128037,
|
||||||
|
"err_code": 0,
|
||||||
|
"power": 7.677094,
|
||||||
|
"total": 30.404,
|
||||||
|
"voltage": 118.917389
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"get_sysinfo": {
|
||||||
|
"active_mode": "schedule",
|
||||||
|
"alias": "Home Google WiFi HS110",
|
||||||
|
"dev_name": "Wi-Fi Smart Plug With Energy Monitoring",
|
||||||
|
"deviceId": "0000000000000000000000000000000000000000",
|
||||||
|
"err_code": 0,
|
||||||
|
"feature": "TIM:ENE",
|
||||||
|
"fwId": "00000000000000000000000000000000",
|
||||||
|
"hwId": "00000000000000000000000000000000",
|
||||||
|
"hw_ver": "1.0",
|
||||||
|
"icon_hash": "",
|
||||||
|
"latitude": 0,
|
||||||
|
"led_off": 0,
|
||||||
|
"longitude": 0,
|
||||||
|
"mac": "00:00:00:00:00:00",
|
||||||
|
"model": "HS110(US)",
|
||||||
|
"oemId": "00000000000000000000000000000000",
|
||||||
|
"on_time": 14048150,
|
||||||
|
"relay_state": 1,
|
||||||
|
"rssi": -38,
|
||||||
|
"sw_ver": "1.2.6 Build 200727 Rel.121701",
|
||||||
|
"type": "IOT.SMARTPLUGSWITCH",
|
||||||
|
"updating": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
89
kasa/tests/fixtures/HS300(US)_1.0_1.0.21.json
vendored
Normal file
89
kasa/tests/fixtures/HS300(US)_1.0_1.0.21.json
vendored
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"emeter": {
|
||||||
|
"get_realtime": {
|
||||||
|
"current_ma": 544,
|
||||||
|
"err_code": 0,
|
||||||
|
"power_mw": 62430,
|
||||||
|
"total_wh": 26889,
|
||||||
|
"voltage_mv": 118389
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"get_sysinfo": {
|
||||||
|
"alias": "TP-LINK_Power Strip_2CA9",
|
||||||
|
"child_num": 6,
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"alias": "Home CameraPC",
|
||||||
|
"id": "800623145DFF1AA096363EFD161C2E661A9D8DED00",
|
||||||
|
"next_action": {
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"on_time": 1449897,
|
||||||
|
"state": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "Home Firewalla",
|
||||||
|
"id": "800623145DFF1AA096363EFD161C2E661A9D8DED01",
|
||||||
|
"next_action": {
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"on_time": 1449897,
|
||||||
|
"state": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "Home Cox modem",
|
||||||
|
"id": "800623145DFF1AA096363EFD161C2E661A9D8DED02",
|
||||||
|
"next_action": {
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"on_time": 1449897,
|
||||||
|
"state": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "Home rpi3-2",
|
||||||
|
"id": "800623145DFF1AA096363EFD161C2E661A9D8DED03",
|
||||||
|
"next_action": {
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"on_time": 1449897,
|
||||||
|
"state": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "Home Camera Switch",
|
||||||
|
"id": "800623145DFF1AA096363EFD161C2E661A9D8DED05",
|
||||||
|
"next_action": {
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"on_time": 1449897,
|
||||||
|
"state": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"alias": "Home Network Switch",
|
||||||
|
"id": "800623145DFF1AA096363EFD161C2E661A9D8DED04",
|
||||||
|
"next_action": {
|
||||||
|
"type": -1
|
||||||
|
},
|
||||||
|
"on_time": 1449897,
|
||||||
|
"state": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deviceId": "0000000000000000000000000000000000000000",
|
||||||
|
"err_code": 0,
|
||||||
|
"feature": "TIM:ENE",
|
||||||
|
"hwId": "00000000000000000000000000000000",
|
||||||
|
"hw_ver": "1.0",
|
||||||
|
"latitude_i": 0,
|
||||||
|
"led_off": 0,
|
||||||
|
"longitude_i": 0,
|
||||||
|
"mac": "00:00:00:00:00:00",
|
||||||
|
"mic_type": "IOT.SMARTPLUGSWITCH",
|
||||||
|
"model": "HS300(US)",
|
||||||
|
"oemId": "00000000000000000000000000000000",
|
||||||
|
"rssi": -39,
|
||||||
|
"status": "new",
|
||||||
|
"sw_ver": "1.0.21 Build 210524 Rel.161309",
|
||||||
|
"updating": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
85
kasa/tests/fixtures/KL120(US)_1.0_1.8.11.json
vendored
Normal file
85
kasa/tests/fixtures/KL120(US)_1.0_1.8.11.json
vendored
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"smartlife.iot.common.emeter": {
|
||||||
|
"get_realtime": {
|
||||||
|
"err_code": 0,
|
||||||
|
"power_mw": 7800
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"smartlife.iot.smartbulb.lightingservice": {
|
||||||
|
"get_light_state": {
|
||||||
|
"brightness": 70,
|
||||||
|
"color_temp": 3001,
|
||||||
|
"err_code": 0,
|
||||||
|
"hue": 0,
|
||||||
|
"mode": "normal",
|
||||||
|
"on_off": 1,
|
||||||
|
"saturation": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"system": {
|
||||||
|
"get_sysinfo": {
|
||||||
|
"active_mode": "none",
|
||||||
|
"alias": "Home Family Room Table",
|
||||||
|
"ctrl_protocols": {
|
||||||
|
"name": "Linkie",
|
||||||
|
"version": "1.0"
|
||||||
|
},
|
||||||
|
"description": "Smart Wi-Fi LED Bulb with Tunable White Light",
|
||||||
|
"dev_state": "normal",
|
||||||
|
"deviceId": "0000000000000000000000000000000000000000",
|
||||||
|
"disco_ver": "1.0",
|
||||||
|
"err_code": 0,
|
||||||
|
"heapsize": 292140,
|
||||||
|
"hwId": "00000000000000000000000000000000",
|
||||||
|
"hw_ver": "1.0",
|
||||||
|
"is_color": 0,
|
||||||
|
"is_dimmable": 1,
|
||||||
|
"is_factory": false,
|
||||||
|
"is_variable_color_temp": 1,
|
||||||
|
"light_state": {
|
||||||
|
"brightness": 70,
|
||||||
|
"color_temp": 3001,
|
||||||
|
"hue": 0,
|
||||||
|
"mode": "normal",
|
||||||
|
"on_off": 1,
|
||||||
|
"saturation": 0
|
||||||
|
},
|
||||||
|
"mic_mac": "000000000000",
|
||||||
|
"mic_type": "IOT.SMARTBULB",
|
||||||
|
"model": "KL120(US)",
|
||||||
|
"oemId": "00000000000000000000000000000000",
|
||||||
|
"preferred_state": [
|
||||||
|
{
|
||||||
|
"brightness": 100,
|
||||||
|
"color_temp": 3500,
|
||||||
|
"hue": 0,
|
||||||
|
"index": 0,
|
||||||
|
"saturation": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 50,
|
||||||
|
"color_temp": 5000,
|
||||||
|
"hue": 0,
|
||||||
|
"index": 1,
|
||||||
|
"saturation": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 50,
|
||||||
|
"color_temp": 2700,
|
||||||
|
"hue": 0,
|
||||||
|
"index": 2,
|
||||||
|
"saturation": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 1,
|
||||||
|
"color_temp": 2700,
|
||||||
|
"hue": 0,
|
||||||
|
"index": 3,
|
||||||
|
"saturation": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rssi": -45,
|
||||||
|
"sw_ver": "1.8.11 Build 191113 Rel.105336"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
kasa/tests/fixtures/KL430(US)_1.0_1.0.10.json
vendored
61
kasa/tests/fixtures/KL430(US)_1.0_1.0.10.json
vendored
@ -7,8 +7,8 @@
|
|||||||
"get_realtime": {
|
"get_realtime": {
|
||||||
"current_ma": 0,
|
"current_ma": 0,
|
||||||
"err_code": 0,
|
"err_code": 0,
|
||||||
"power_mw": 8729,
|
"power_mw": 2725,
|
||||||
"total_wh": 21,
|
"total_wh": 1193,
|
||||||
"voltage_mv": 0
|
"voltage_mv": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
"system": {
|
"system": {
|
||||||
"get_sysinfo": {
|
"get_sysinfo": {
|
||||||
"active_mode": "none",
|
"active_mode": "schedule",
|
||||||
"alias": "Bedroom Lightstrip",
|
"alias": "Bedroom Lightstrip",
|
||||||
"ctrl_protocols": {
|
"ctrl_protocols": {
|
||||||
"name": "Linkie",
|
"name": "Linkie",
|
||||||
@ -42,27 +42,66 @@
|
|||||||
"latitude_i": 0,
|
"latitude_i": 0,
|
||||||
"length": 16,
|
"length": 16,
|
||||||
"light_state": {
|
"light_state": {
|
||||||
"brightness": 50,
|
"brightness": 15,
|
||||||
"color_temp": 3630,
|
"color_temp": 2500,
|
||||||
"hue": 0,
|
"hue": 0,
|
||||||
"mode": "normal",
|
"mode": "normal",
|
||||||
"on_off": 1,
|
"on_off": 1,
|
||||||
"saturation": 0
|
"saturation": 0
|
||||||
},
|
},
|
||||||
"lighting_effect_state": {
|
"lighting_effect_state": {
|
||||||
"brightness": 50,
|
"brightness": 100,
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
"enable": 0,
|
"enable": 0,
|
||||||
"id": "",
|
"id": "bCTItKETDFfrKANolgldxfgOakaarARs",
|
||||||
"name": ""
|
"name": "Flicker"
|
||||||
},
|
},
|
||||||
"longitude_i": 0,
|
"longitude_i": 0,
|
||||||
"mic_mac": "CC32E5230F55",
|
"mic_mac": "CC32E5000000",
|
||||||
"mic_type": "IOT.SMARTBULB",
|
"mic_type": "IOT.SMARTBULB",
|
||||||
"model": "KL430(US)",
|
"model": "KL430(US)",
|
||||||
"oemId": "00000000000000000000000000000000",
|
"oemId": "00000000000000000000000000000000",
|
||||||
"preferred_state": [],
|
"preferred_state": [
|
||||||
"rssi": -56,
|
{
|
||||||
|
"brightness": 100,
|
||||||
|
"custom": 0,
|
||||||
|
"id": "QglBhMShPHUAuxLqzNEefFrGiJwahOmz",
|
||||||
|
"index": 0,
|
||||||
|
"mode": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 100,
|
||||||
|
"custom": 0,
|
||||||
|
"id": "bCTItKETDFfrKANolgldxfgOakaarARs",
|
||||||
|
"index": 1,
|
||||||
|
"mode": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 34,
|
||||||
|
"color_temp": 0,
|
||||||
|
"hue": 7,
|
||||||
|
"index": 2,
|
||||||
|
"mode": 1,
|
||||||
|
"saturation": 49
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 25,
|
||||||
|
"color_temp": 0,
|
||||||
|
"hue": 4,
|
||||||
|
"index": 3,
|
||||||
|
"mode": 1,
|
||||||
|
"saturation": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"brightness": 15,
|
||||||
|
"color_temp": 2500,
|
||||||
|
"hue": 0,
|
||||||
|
"index": 4,
|
||||||
|
"mode": 1,
|
||||||
|
"saturation": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rssi": -44,
|
||||||
"status": "new",
|
"status": "new",
|
||||||
"sw_ver": "1.0.10 Build 200522 Rel.104340"
|
"sw_ver": "1.0.10 Build 200522 Rel.104340"
|
||||||
}
|
}
|
||||||
|
@ -283,12 +283,17 @@ async def test_ignore_default_not_set_without_color_mode_change_turn_on(
|
|||||||
@bulb_iot
|
@bulb_iot
|
||||||
async def test_list_presets(dev: IotBulb):
|
async def test_list_presets(dev: IotBulb):
|
||||||
presets = dev.presets
|
presets = dev.presets
|
||||||
assert len(presets) == len(dev.sys_info["preferred_state"])
|
# Light strip devices may list some light effects along with normal presets but these
|
||||||
|
# are handled by the LightEffect module so exclude preferred states with id
|
||||||
|
raw_presets = [
|
||||||
|
pstate for pstate in dev.sys_info["preferred_state"] if "id" not in pstate
|
||||||
|
]
|
||||||
|
assert len(presets) == len(raw_presets)
|
||||||
|
|
||||||
for preset, raw in zip(presets, dev.sys_info["preferred_state"]):
|
for preset, raw in zip(presets, raw_presets):
|
||||||
assert preset.index == raw["index"]
|
assert preset.index == raw["index"]
|
||||||
assert preset.hue == raw["hue"]
|
|
||||||
assert preset.brightness == raw["brightness"]
|
assert preset.brightness == raw["brightness"]
|
||||||
|
assert preset.hue == raw["hue"]
|
||||||
assert preset.saturation == raw["saturation"]
|
assert preset.saturation == raw["saturation"]
|
||||||
assert preset.color_temp == raw["color_temp"]
|
assert preset.color_temp == raw["color_temp"]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user