Include device_on in set_brightness, set_color_temp, and set_hsv#1680
Open
fluffyspace wants to merge 3 commits intopython-kasa:masterfrom
Open
Include device_on in set_brightness, set_color_temp, and set_hsv#1680fluffyspace wants to merge 3 commits intopython-kasa:masterfrom
fluffyspace wants to merge 3 commits intopython-kasa:masterfrom
Conversation
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1680 +/- ##
=======================================
Coverage 93.22% 93.22%
=======================================
Files 157 157
Lines 9815 9815
Branches 1003 1003
=======================================
Hits 9150 9150
Misses 472 472
Partials 193 193 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
device_on: Trueto theset_device_infopayload inset_brightness(),set_color_temp(), andset_hsv()Problem
Some Tapo devices (confirmed on the L900-5 LED light strip) do not implicitly turn on when receiving brightness or color commands via
set_device_info. The device:error_code: 0)device_on: true,brightness: 100when queried)This creates a "zombie state" where the device reports it's on but the LEDs are off. The state persists until the device is power-cycled. Since every protocol response indicates success, python-kasa (and Home Assistant) have no way to detect the failure.
Root cause
Brightness.set_brightness()sends{"brightness": N}— nodevice_onColorTemperature.set_color_temp()sends{"color_temp": N}— nodevice_onColor.set_hsv()sends{"hue": N, "saturation": N}— nodevice_onMeanwhile,
Light.set_state()always includesdevice_onin the payload, and works correctly.Fix
Include
"device_on": Truein all three methods'set_device_infopayloads. This matches the behavior ofset_state()and is consistent with how the official Tapo app sends commands.Testing
Tested on a Tapo L900-5 (firmware current, KLAP v2 transport) controlled via Home Assistant's tplink integration:
light.turn_onwithbrightness_pct=100→ device reports on, LEDs stay offlight.turn_onwithbrightness_pct=100→ device reports on, LEDs turn on🤖 Generated with Claude Code