From 7164ef7a668e0c7b148ecff5e8a30c992a726297 Mon Sep 17 00:00:00 2001 From: Peter Arapov Date: Fri, 18 Sep 2026 08:38:08 -0500 Subject: [PATCH] Add KL420 to TPLINK_KELVIN color temperature ranges (#1757) Adds the `KL420` series to `TPLINK_KELVIN` to support wider color temperature ranges (2500-9000K as supported by the device). While older firmware (1.0.2) reported is_variable_color_temp: 0, firmware 1.0.7 enables variable color temperature support. --- SUPPORTED.md | 1 + kasa/iot/iotbulb.py | 1 + tests/device_fixtures.py | 10 +++- tests/fixtureinfo.py | 11 +--- tests/fixtures/iot/KL420L5(US)_1.0_1.0.7.json | 57 +++++++++++++++++++ 5 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 tests/fixtures/iot/KL420L5(US)_1.0_1.0.7.json diff --git a/SUPPORTED.md b/SUPPORTED.md index 3e4eb5d5..afb12809 100644 --- a/SUPPORTED.md +++ b/SUPPORTED.md @@ -169,6 +169,7 @@ Some newer Kasa devices require authentication. These are marked with [^1] in th - Hardware: 1.0 (US) / Firmware: 1.0.8 - **KL420L5** - Hardware: 1.0 (US) / Firmware: 1.0.2 + - Hardware: 1.0 (US) / Firmware: 1.0.7 - **KL430** - Hardware: 2.0 (UN) / Firmware: 1.0.8 - Hardware: 1.0 (US) / Firmware: 1.0.10 diff --git a/kasa/iot/iotbulb.py b/kasa/iot/iotbulb.py index 33c7a2be..943574de 100644 --- a/kasa/iot/iotbulb.py +++ b/kasa/iot/iotbulb.py @@ -91,6 +91,7 @@ TPLINK_KELVIN = { r"KL120\(EU\)": ColorTempRange(2700, 6500), r"KL120\(US\)": ColorTempRange(2700, 5000), r"KL400L5": ColorTempRange(2500, 9000), + r"KL420": ColorTempRange(2500, 9000), r"KL430": ColorTempRange(2500, 9000), } diff --git a/tests/device_fixtures.py b/tests/device_fixtures.py index 0edce51e..04b98177 100644 --- a/tests/device_fixtures.py +++ b/tests/device_fixtures.py @@ -55,9 +55,13 @@ BULBS_IOT_VARIABLE_TEMP = { "KL135", "KL430", } -# KL400L5 firmware 1.0.5 and 1.0.8 fixtures report no variable color temperature -# support, so match the supporting 1.0.11 fixture rather than the entire model. -BULBS_IOT_VARIABLE_TEMP_FIXTURES = {"KL400L5(US)_1.0_1.0.11"} +# KL400L5 firmware 1.0.5/1.0.8 and KL420L5 firmware 1.0.2 fixtures report no +# variable color temperature support, so match the supporting fixtures rather +# than the entire model. +BULBS_IOT_VARIABLE_TEMP_FIXTURES = { + "KL400L5(US)_1.0_1.0.11", + "KL420L5(US)_1.0_1.0.7", +} BULBS_IOT_COLOR = {"LB130", "KL125", "KL130", "KL135", *BULBS_IOT_LIGHT_STRIP} BULBS_IOT_DIMMABLE = {"KL50", "KL60", "LB100", "LB110", "KL110", "KL110B"} BULBS_IOT = ( diff --git a/tests/fixtureinfo.py b/tests/fixtureinfo.py index fbfe6ff8..9334f97f 100644 --- a/tests/fixtureinfo.py +++ b/tests/fixtureinfo.py @@ -129,14 +129,9 @@ def filter_fixtures( if isinstance(model_filter, str): model_filter = {model_filter} assert isinstance(model_filter, set), "model filter must be a set" - model_filter_list = [mf for mf in model_filter] - if ( - len(model_filter_list) == 1 - and (model := model_filter_list[0]) - and len(model.split("_")) == 3 - ): - # filter string includes hw and fw, return exact match - return fixture_data.name == f"{model}.json" + fixture_base = fixture_data.name.removesuffix(".json") + if fixture_base in model_filter or fixture_data.name in model_filter: + return True file_model_region = fixture_data.name.split("_")[0] file_model = file_model_region.split("(")[0] return file_model in model_filter diff --git a/tests/fixtures/iot/KL420L5(US)_1.0_1.0.7.json b/tests/fixtures/iot/KL420L5(US)_1.0_1.0.7.json new file mode 100644 index 00000000..4d30dbe8 --- /dev/null +++ b/tests/fixtures/iot/KL420L5(US)_1.0_1.0.7.json @@ -0,0 +1,57 @@ +{ + "smartlife.iot.common.emeter": { + "get_realtime": { + "err_code": 0, + "power_mw": 500, + "total_wh": 1192 + } + }, + "system": { + "get_sysinfo": { + "LEF": 1, + "active_mode": "none", + "alias": "#MASKED_NAME#", + "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": "1.0", + "is_color": 1, + "is_dimmable": 1, + "is_factory": false, + "is_variable_color_temp": 1, + "latitude_i": 0, + "length": 50, + "light_state": { + "brightness": 60, + "color_temp": 2700, + "hue": 0, + "mode": "normal", + "on_off": 1, + "saturation": 0 + }, + "lighting_effect_state": { + "brightness": 60, + "custom": 0, + "enable": 0, + "id": "CdLeIgiKcQrLKMINRPTMbylATulQewLD", + "name": "Aurora" + }, + "longitude_i": 0, + "mic_mac": "00:00:00:00:00:00", + "mic_type": "IOT.SMARTBULB", + "model": "KL420L5(US)", + "oemId": "00000000000000000000000000000000", + "preferred_state": [], + "rssi": -19, + "status": "new", + "sw_ver": "1.0.7 Build 240809 Rel.170227" + } + } +}