diff --git a/kasa/tests/conftest.py b/kasa/tests/conftest.py index 69f1f3b7..456fe3ab 100644 --- a/kasa/tests/conftest.py +++ b/kasa/tests/conftest.py @@ -25,9 +25,9 @@ SUPPORTED_DEVICES = glob.glob( LIGHT_STRIPS = {"KL430"} -BULBS = {"KL60", "LB100", "LB120", "LB130", "KL120", "KL130", *LIGHT_STRIPS} -VARIABLE_TEMP = {"LB120", "LB130", "KL120", "KL130", "KL430", *LIGHT_STRIPS} -COLOR_BULBS = {"LB130", "KL130", *LIGHT_STRIPS} +VARIABLE_TEMP = {"LB120", "LB130", "KL120", "KL125", "KL130", "KL430", *LIGHT_STRIPS} +COLOR_BULBS = {"LB130", "KL125", "KL130", *LIGHT_STRIPS} +BULBS = {"KL60", "LB100", *VARIABLE_TEMP, *COLOR_BULBS, *LIGHT_STRIPS} PLUGS = {"HS100", "HS103", "HS105", "HS110", "HS200", "HS210"} diff --git a/kasa/tests/fixtures/HS200(US)_5.0_1.0.2.json b/kasa/tests/fixtures/HS200(US)_5.0_1.0.2.json new file mode 100644 index 00000000..fc09e6f5 --- /dev/null +++ b/kasa/tests/fixtures/HS200(US)_5.0_1.0.2.json @@ -0,0 +1,31 @@ +{ + "system": { + "get_sysinfo": { + "active_mode": "none", + "alias": "House Fan", + "dev_name": "Smart Wi-Fi Light Switch", + "deviceId": "0000000000000000000000000000000000000000", + "err_code": 0, + "feature": "TIM", + "hwId": "00000000000000000000000000000000", + "hw_ver": "5.0", + "icon_hash": "", + "latitude_i": 0, + "led_off": 0, + "longitude_i": 0, + "mac": "00:00:00:00:00:00", + "mic_type": "IOT.SMARTPLUGSWITCH", + "model": "HS200(US)", + "next_action": { + "type": -1 + }, + "oemId": "00000000000000000000000000000000", + "on_time": 0, + "relay_state": 0, + "rssi": -50, + "status": "new", + "sw_ver": "1.0.2 Build 200819 Rel.105309", + "updating": 0 + } + } +} diff --git a/kasa/tests/fixtures/KL125(US)_1.20_1.0.5.json b/kasa/tests/fixtures/KL125(US)_1.20_1.0.5.json new file mode 100644 index 00000000..1fca6924 --- /dev/null +++ b/kasa/tests/fixtures/KL125(US)_1.20_1.0.5.json @@ -0,0 +1,88 @@ +{ + "smartlife.iot.common.emeter": { + "get_realtime": { + "err_code": 0, + "power_mw": 10800, + "total_wh": 40 + } + }, + "smartlife.iot.smartbulb.lightingservice": { + "get_light_state": { + "brightness": 100, + "color_temp": 4000, + "err_code": 0, + "hue": 0, + "mode": "normal", + "on_off": 1, + "saturation": 0 + } + }, + "system": { + "get_sysinfo": { + "active_mode": "none", + "alias": "kasa-bc01", + "ctrl_protocols": { + "name": "Linkie", + "version": "1.0" + }, + "description": "Smart Wi-Fi LED Bulb with Color Changing", + "dev_state": "normal", + "deviceId": "0000000000000000000000000000000000000000", + "disco_ver": "1.0", + "err_code": 0, + "hwId": "00000000000000000000000000000000", + "hw_ver": "1.20", + "is_color": 1, + "is_dimmable": 1, + "is_factory": false, + "is_variable_color_temp": 1, + "latitude_i": 0, + "light_state": { + "brightness": 100, + "color_temp": 4000, + "hue": 0, + "mode": "normal", + "on_off": 1, + "saturation": 0 + }, + "longitude_i": 0, + "mic_mac": "000000000000", + "mic_type": "IOT.SMARTBULB", + "model": "KL125(US)", + "oemId": "00000000000000000000000000000000", + "preferred_state": [ + { + "brightness": 100, + "color_temp": 4000, + "hue": 0, + "index": 0, + "saturation": 0 + }, + { + "brightness": 100, + "color_temp": 0, + "hue": 0, + "index": 1, + "saturation": 100 + }, + { + "brightness": 100, + "color_temp": 0, + "hue": 120, + "index": 2, + "saturation": 100 + }, + { + "brightness": 100, + "color_temp": 0, + "hue": 240, + "index": 3, + "saturation": 100 + } + ], + "rssi": -59, + "status": "new", + "sw_ver": "1.0.5 Build 200831 Rel.141525" + } + } +} diff --git a/kasa/tests/newfakes.py b/kasa/tests/newfakes.py index 55c3e00c..73eed0f3 100644 --- a/kasa/tests/newfakes.py +++ b/kasa/tests/newfakes.py @@ -265,7 +265,9 @@ class FakeTransportProtocol(TPLinkSmartHomeProtocol): # if we have emeter support, we need to add the missing pieces for module in ["emeter", "smartlife.iot.common.emeter"]: for etype in ["get_realtime", "get_daystat", "get_monthstat"]: - if etype in info[module]: # if the fixture has the data, use it + if ( + module in info and etype in info[module] + ): # if the fixture has the data, use it # print("got %s %s from fixture: %s" % (module, etype, info[module][etype])) proto[module][etype] = info[module][etype] else: # otherwise fall back to the static one