From 7c9d21af7a596bc8542e356e182a2ac320d61226 Mon Sep 17 00:00:00 2001 From: Ivan Prodanov Date: Mon, 16 Aug 2021 21:16:29 +0300 Subject: [PATCH] Add real kasa KL430(UN) device dump (#192) * Add real kasa KL430(UN) device dump * Adjust hue&sat max values * light strips, as bulbs, have only power for emeter Co-authored-by: Teemu Rytilahti --- kasa/tests/fixtures/KL430(UN)_2.0_1.0.8.json | 90 ++++++++++++++++++++ kasa/tests/newfakes.py | 4 +- kasa/tests/test_emeter.py | 2 +- 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 kasa/tests/fixtures/KL430(UN)_2.0_1.0.8.json diff --git a/kasa/tests/fixtures/KL430(UN)_2.0_1.0.8.json b/kasa/tests/fixtures/KL430(UN)_2.0_1.0.8.json new file mode 100644 index 00000000..a956575b --- /dev/null +++ b/kasa/tests/fixtures/KL430(UN)_2.0_1.0.8.json @@ -0,0 +1,90 @@ +{ + "smartlife.iot.common.emeter": { + "get_realtime": { + "err_code": 0, + "power_mw": 16760, + "total_wh": 120 + } + }, + "system": { + "get_sysinfo": { + "LEF": 1, + "active_mode": "none", + "alias": "Bedroom light strip", + "ctrl_protocols": { + "name": "Linkie", + "version": "1.0" + }, + "description": "Kasa Smart Light Strip, Multicolor", + "dev_state": "normal", + "deviceId": "0000000000000000000000000000000000000000", + "disco_ver": "1.0", + "err_code": 0, + "hwId": "00000000000000000000000000000000", + "hw_ver": "2.0", + "is_color": 1, + "is_dimmable": 1, + "is_factory": false, + "is_variable_color_temp": 1, + "latitude_i": 0, + "length": 16, + "light_state": { + "brightness": 100, + "color_temp": 9000, + "hue": 0, + "mode": "normal", + "on_off": 1, + "saturation": 0 + }, + "lighting_effect_state": { + "brightness": 100, + "custom": 1, + "enable": 1, + "id": "yMwcNpLxijmoKamskHCvvravpbnIqAIN", + "name": "Aurora 1" + }, + "longitude_i": 0, + "mic_mac": "00:00:00:00:00:00", + "mic_type": "IOT.SMARTBULB", + "model": "KL430(UN)", + "oemId": "00000000000000000000000000000000", + "preferred_state": [ + { + "brightness": 100, + "color_temp": 9000, + "hue": 0, + "index": 0, + "mode": 1, + "saturation": 0 + }, + { + "brightness": 100, + "color_temp": 0, + "hue": 217, + "index": 1, + "mode": 1, + "saturation": 99 + }, + { + "brightness": 100, + "color_temp": 0, + "hue": 194, + "index": 2, + "mode": 1, + "saturation": 50 + }, + { + "brightness": 100, + "color_temp": 0, + "hue": 277, + "index": 3, + "mode": 1, + "saturation": 86 + } + ], + "rssi": -43, + "status": "new", + "sw_ver": "1.0.8 Build 210121 Rel.084339" + } + } +} diff --git a/kasa/tests/newfakes.py b/kasa/tests/newfakes.py index 73eed0f3..1e053621 100644 --- a/kasa/tests/newfakes.py +++ b/kasa/tests/newfakes.py @@ -150,9 +150,9 @@ BULB_SCHEMA = PLUG_SCHEMA.extend( { "brightness": All(int, Range(min=0, max=100)), "color_temp": int, - "hue": All(int, Range(min=0, max=255)), + "hue": All(int, Range(min=0, max=360)), "index": int, - "saturation": All(int, Range(min=0, max=255)), + "saturation": All(int, Range(min=0, max=100)), } ], } diff --git a/kasa/tests/test_emeter.py b/kasa/tests/test_emeter.py index 907f2478..75afe7dd 100644 --- a/kasa/tests/test_emeter.py +++ b/kasa/tests/test_emeter.py @@ -89,7 +89,7 @@ async def test_emeter_status(dev): assert d["power_mw"] == d["power"] * 1000 # bulbs have only power according to tplink simulator. - if not dev.is_bulb: + if not dev.is_bulb and not dev.is_light_strip: assert d["voltage_mv"] == d["voltage"] * 1000 assert d["current_ma"] == d["current"] * 1000