GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — Include device_on in set_brightness, set_color_temp, and set_hsv by fluffyspace · Pull Request #1680 · python-kasa/python-kasa Conversation
|
| Scenario | is_on |
device_on sent? |
Result |
|---|---|---|---|
| L900-5 zombie state (reports on, LEDs off) | True |
yes | LEDs come on |
| Normal "device on, change brightness" | True |
yes | Same as Tapo app |
| Pre-set brightness while off (#1532) | False |
no | Device stays off |
This matches the spirit of set_state() (which sends device_on explicitly) without contradicting the "set brightness without turning on" use case from #1532 / #1066.
Tested on a Tapo L900-5 (firmware current, KLAP v2 transport) controlled via Home Assistant's tplink integration:
light.turn_on with brightness_pct=100 → device reports on, LEDs stay offlight.turn_on with brightness_pct=100 → device reports on, LEDs turn onNew tests/smart/modules/test_light_device_on_payload.py parametrizes set_brightness, set_color_temp, and set_hsv over is_on=[True, False] and locks in:
is_on=True → payload includes device_on: Trueis_on=False → payload omits device_on (no regression for Regression? Latest kasa cli turns light on when setting brightness. #1532)Updated existing test_light_effect_brightness cases to force dev._info["device_on"] = True so the asserted payload is deterministic across fixtures (some have device_on: false baked in).
Closes the regression risk for #1532 / #1066.
🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## master #1680 +/- ## ========================================== + Coverage 93.31% 93.33% +0.02% ========================================== Files 158 158 Lines 9977 9984 +7 Branches 1025 1028 +3 ========================================== + Hits 9310 9319 +9 Misses 472 472 + Partials 195 193 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Updated in 85d8d38 to address the regression risk against #1532 / #1066. Original approach forced New approach: PR description updated with the full matrix; new parametrized tests in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Some Tapo devices (confirmed on L900-5 LED strip) treat power state and brightness/color as independent parameters. When set_device_info is called with only brightness or color parameters (without device_on), the device accepts the command, updates its internal state, and reports success — but the LEDs do not physically turn on. This causes a particularly bad failure mode: the device enters a "zombie state" where it reports on/brightness=100 to all queries while the LEDs remain off. The device stays in this state until power cycled, and python-kasa has no way to detect the discrepancy since every protocol response indicates success. Adding device_on: True to set_brightness(), set_color_temp(), and set_hsv() ensures the device always receives an explicit power state with light property changes. This matches the behavior of set_state() which already includes device_on, and is consistent with how the official Tapo app sends commands. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Update test_light_effect_brightness assertions in both test_light_effect.py and test_light_strip_effect.py to match the new set_brightness payload that includes device_on: True. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Forcing device_on: True unconditionally in set_brightness, set_color_temp, and set_hsv fixed the L900-5 zombie state but reintroduced the python-kasa#1532 regression: users who want to change brightness on an off device without turning it on as a side-effect. Now device_on: True is injected only when self._device.is_on is already true. That still re-asserts the power state for devices in the zombie state (they report on, so the flag is still sent and the LEDs physically come up), while leaving a deliberately-off device alone. Tests parametrize all three setters over is_on=[True, False] to lock in both branches.
Fixes mypy: `dev` is typed as `Device` (the abstract base) which has no `_info` attribute. Patching the public `is_on` property has the same effect on the brightness module's logic and is type-clean.
f04f085 to
b341310
Compare
|
Hi! Just a gentle ping on this one — I've rebased the branch onto the latest master and CI is green again (Codecov reports coverage at 93.24%). I'd love to get this merged if there's anything I can do to help it along. Quick recap for context: this fixes a Happy to adjust the approach, add fixtures, or split the changes if that makes it easier to review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.