Skip to content

Add KL400L5 color temperature range#1719

Merged
rytilahti merged 6 commits into
python-kasa:masterfrom
loganrosen:fix-kl400l5-color-temp
Jul 18, 2026
Merged

Add KL400L5 color temperature range#1719
rytilahti merged 6 commits into
python-kasa:masterfrom
loganrosen:fix-kl400l5-color-temp

Conversation

@loganrosen

@loganrosen loganrosen commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the KL400L5 color temperature range used by newer firmware
  • add a KL400L5(US) 1.0.11 fixture that reports variable color temperature support
  • categorize that fixture as variable color temperature while keeping older KL400L5 fixtures non-variable

Notes

  • TP-Link's official datasheets only say the strip is tunable; they do not list a Kelvin range.
  • The local protocol accepts and reports a wide set of values, including out-of-spec values, so it does not provide a trustworthy hardware max.
  • The Tapo app exposes 2500K-9000K for these KL400L5 strips, so this PR uses that app-visible range.

Test plan

  • uv run pytest tests/test_bulb.py::test_non_variable_temp tests/test_bulb.py::test_try_set_colortemp tests/test_bulb.py::test_out_of_range_temperature
  • uv run pytest tests/test_bulb.py -k 'variable_temp or non_variable_temp'
  • uv run pytest tests/iot/test_iotbulb.py -k 'unknown_temp_range or set_color_temp_transition' tests/test_cli.py -k color_temperature
  • uv run pre-commit run --files tests/device_fixtures.py
  • uv run pre-commit run --files kasa/iot/iotbulb.py tests/iot/test_iotbulb.py kasa/cli/light.py tests/test_cli.py 'tests/fixtures/iot/KL400L5(US)_1.0_1.0.11.json' SUPPORTED.md tests/device_fixtures.py

loganrosen and others added 4 commits July 8, 2026 20:39
Add KL400L5(US) 1.0.11 fixture data with variable color temperature support and cover its supported color temperature range so the fallback warning is not emitted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the device-specific color temperature range for validation instead of Click blocking values above 9000K before the library can validate them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set the KL400L5 range to 2500-9000K based on the app-visible range and drop the model-specific warning test in favor of existing generic color temperature coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The KL400L5 model has older fixtures without variable color temperature and a newer firmware fixture with variable color temperature. Categorize the newer fixture by exact fixture name so generic variable and non-variable temperature tests cover the right cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.29%. Comparing base (88e1c27) to head (a60ec5d).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1719      +/-   ##
==========================================
+ Coverage   93.21%   93.29%   +0.07%     
==========================================
  Files         157      157              
  Lines        9819     9932     +113     
  Branches     1005     1022      +17     
==========================================
+ Hits         9153     9266     +113     
+ Misses        472      471       -1     
- Partials      194      195       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rytilahti rytilahti added the enhancement New feature or request label Jul 10, 2026

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @loganrosen! Just a quick question (inline) before merging it, would it be enough to add the new model to the already existing list of iot devices with color temperature controls?

Comment thread tests/device_fixtures.py
"KL135",
"KL430",
}
BULBS_IOT_VARIABLE_TEMP_FIXTURES = {"KL400L5(US)_1.0_1.0.11"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason this would not work if simply added to the BULBS_IOT_VARIABLE_TEMP?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding KL400L5 to BULBS_IOT_VARIABLE_TEMP would select every KL400L5 fixture by model. The 1.0.5 and 1.0.8 fixtures report is_variable_color_temp: 0, while only 1.0.11 reports 1. The exact fixture filter keeps the older firmware fixtures in non_variable_temp and includes only 1.0.11 in the variable-temperature tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification, makes sense! Could you add a quick comment on this in the file, so it's clear also for future readers?

@loganrosen loganrosen Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment explaining that the KL400L5 firmware 1.0.5 and 1.0.8 fixtures report no variable color-temperature support, while the 1.0.11 fixture does, so the supporting fixture is matched exactly rather than categorizing the entire model.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a0ca7c6a-6019-45c6-b839-bc1e4d6171c8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a0ca7c6a-6019-45c6-b839-bc1e4d6171c8
@rytilahti
rytilahti merged commit a29d061 into python-kasa:master Jul 18, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants