Expose the light transition state change flag - #1745
Open
nopoz wants to merge 1 commit into
Open
Conversation
on_off_gradually reports three flags: on_state and off_state, which cover fading when the light is turned on and off and are already exposed as number features, and change_state, which was neither read nor written. change_state controls fading between states while the light is already on, and is what the Tapo app presents as "Smooth Transition". Verified on an L920 running firmware 1.4.4: with the flag cleared a brightness jump snaps instantly, and with it set the same jump ramps. Only newer firmware reports it, so the feature is registered only when the device returns the flag. The check uses the parsed value rather than the raw data because _initialize_features must not raise for devices whose get_on_off_gradually_info query failed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1745 +/- ##
=======================================
Coverage 93.29% 93.30%
=======================================
Files 157 157
Lines 9932 9945 +13
Branches 1022 1025 +3
=======================================
+ Hits 9266 9279 +13
Misses 471 471
Partials 195 195 ☔ View full report in Codecov by Harness. 🚀 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
Bulbs and light strips can fade smoothly when their brightness or colour changes, instead of snapping straight to the new value. The Tapo app exposes this as "Smooth Transition". python-kasa cannot read or change it today, so the setting is missing from Home Assistant even though the device supports it. This PR adds it as a switch.
Under the hood,
on_off_graduallyreports three flags.on_stateandoff_statecover fading when the light is turned on and off, and are already exposed as thesmooth_transition_on/smooth_transition_offnumber features. The third,change_state, appears nowhere inlighttransition.py: it is never read and never written, andset_enabled()only touches the other two.change_statein_post_update_hookchange_transitionproperty andset_change_transition()smooth_transition_changeswitch feature when the device reports the flagVerification
Confirmed on a physical L920 running firmware 1.4.4,
on_off_graduallyv4, by toggling the flag and watching the strip. Withchange_statecleared, a brightness jump from 10 to 100 snaps instantly. With it set, the same jump ramps. Turn-on and turn-off fades were unaffected in both cases, which is the expected split withon_state/off_state.The flag persists across a full disconnect, so it is stored device state rather than a per-session toggle.
Notes
change_state. Exactly one fixture in the repo has it,L530EA(EU)_1.0_1.4.2, and 26 otheron_off_graduallyfixtures do not, so the feature is registered conditionally and the test asserts both paths.self.data._initialize_featuresruns after_post_update_hookand must not raise for devices whoseget_on_off_gradually_infoquery failed. Readingself.datathere breaks fixture generation for several plugs, including P135 and KS225.tests/fakeprotocol_smart.pyneeded a matching branch in_set_on_off_gradually_info, which previously appliedon_stateandoff_statebut silently droppedchange_state.enablefor this flag, with no duration alongside it.Test plan
uv run pytest tests/smart/modules/test_lighttransition.py- 66 tests, covering both the supported and unsupported pathsuv run pytest- full suite passesuv run pre-commit run -a- clean