Bulbs: allow specifying transition for state changes#70
Merged
rytilahti merged 1 commit intopython-kasa:masterfrom Jun 14, 2020
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #70 +/- ##
==========================================
- Coverage 61.33% 61.22% -0.11%
==========================================
Files 9 9
Lines 1169 1171 +2
Branches 177 178 +1
==========================================
Hits 717 717
+ Misses 413 412 -1
- Partials 39 42 +3
Continue to review full report at Codecov.
|
basnijholt
reviewed
Jun 14, 2020
| return await self._query_helper(self.LIGHT_SERVICE, "get_light_state") | ||
|
|
||
| async def set_light_state(self, state: Dict) -> Dict: | ||
| async def set_light_state(self, state: Dict, *, transition: int = None) -> Dict: |
Contributor
There was a problem hiding this comment.
Not really part of this PR, but shouldn't we further specify what is in the output Dict?
Member
Author
There was a problem hiding this comment.
That could be added, it'd be Dict[str, Union[str,Dict]] or Dict[str, Union[str,Dict[str,Union[str,int]]] (which is not very beautiful :-)
Here's an example what it returns:
{'on_off': 0, 'dft_on_state': {'mode': 'normal', 'hue': 0, 'saturation': 0, 'color_temp': 2000, 'brightness': 23}}
Contributor
There was a problem hiding this comment.
Right, that wouldn't be easy to read 😅
All state changing functions now allow defining transition time in milliseconds
c5a67ea to
1cfbc47
Compare
Merged
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.
This adds
transitionkwarg for all state changing methods.The values are in milliseconds, and limits of what values are accepted differ likely between devices, so there is no checks for that for now. This has only been tested using the brightness & turn on/off transitions on a KL60.
This is a WIP, as mypy does not like that the signature of
turn_onandturn_offdiffer, so this does not currently pass the tests and that needs to be investigated.This PR also changes the setters to return the response from the device, which can potentially be useful for downstream developers:
I wanted to push this up to give an example how to test the transitions, this is related to #69