Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1745 +/- ##
==========================================
+ Coverage 93.29% 93.32% +0.02%
==========================================
Files 157 158 +1
Lines 9932 9990 +58
Branches 1022 1028 +6
==========================================
+ Hits 9266 9323 +57
- Misses 471 472 +1
Partials 195 195 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if (change_state := self.data.get("change_state")) is not None: | ||
| self._change_transition = change_state["enable"] | ||
|
|
There was a problem hiding this comment.
The above comment is for the supports_on_and_off, so this should probably be moved after it?
Any ideas if this is for specific version?
There was a problem hiding this comment.
It's v4. Of the 35 fixtures carrying on_off_gradually, change_state is in exactly one, L530EA(EU)_1.0_1.4.2, at v4; v1 reports enable, v2 and v3 report on_state/off_state. Added it to the version list and moved the read to the end of _post_update_hook so the comment sits against the code it describes. That puts it past the v1 early return, which is right for v4 but leaves the v1 skip implicit; say if you would rather it were an explicit version check.
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.
6298f32 to
a526c0e
Compare
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