Add module support & query their information during update cycle#243
Merged
rytilahti merged 9 commits intopython-kasa:modularizefrom Nov 7, 2021
Merged
Add module support & query their information during update cycle#243rytilahti merged 9 commits intopython-kasa:modularizefrom
rytilahti merged 9 commits intopython-kasa:modularizefrom
Conversation
This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice)
Codecov Report
@@ Coverage Diff @@
## master #243 +/- ##
==========================================
+ Coverage 81.63% 81.83% +0.19%
==========================================
Files 12 22 +10
Lines 1307 1525 +218
Branches 176 187 +11
==========================================
+ Hits 1067 1248 +181
- Misses 209 243 +34
- Partials 31 34 +3
Continue to review full report at Codecov.
|
Member
Author
|
I want to get this merged before continuing on improving the modules so I created a new development branch on which this PR is to be merged. The further improvement PRs can then be done separately on top of the modularize branch, which can be merged back when it's ready. |
rytilahti
added a commit
that referenced
this pull request
Jan 29, 2022
* Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
rytilahti
added a commit
to rytilahti/python-kasa
that referenced
this pull request
Jan 29, 2022
…hon-kasa#243) * Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
rytilahti
added a commit
that referenced
this pull request
Mar 24, 2022
* Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
rytilahti
added a commit
that referenced
this pull request
Apr 5, 2022
* Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
rytilahti
added a commit
that referenced
this pull request
Apr 5, 2022
* Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
rytilahti
added a commit
that referenced
this pull request
Apr 5, 2022
* Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
rytilahti
pushed a commit
that referenced
this pull request
Apr 25, 2024
This fixes the current broken tests in #844 caused by the fixtures for `HS107(US)_1.0_1.0.8.json` and `KP400(US)_1.0_1.0.10.json` having the `emeter` value in the fixture but no `get_realtime` value. Other strips do not fail because they do not have the `emeter` value in the fixture and the `FakeIotProtocol` creates one for them. It seems that #299 introduced the adding of Emeter in the smart strip constructor (in commit c8ad99a) and this was added after #243 which adds the Emeter in the IoDevice `update()` method so perhaps there is an implication to this change that I'm missing, although it seems `_create_emeter_request` is no longer called anywhere so maybe that was a historical reason. N.B. The tests all pass with this PR. Link to [CI run on branch](https://github.com/sdb9696/python-kasa/actions/runs/8831324308)
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 PR creates a modularized foundation to expose more features on the supported devices, with the goal of making it more straightforward to implement new features in the future. This PR should not break the API.
At the moment, the most visible change is that each update cycle queries the information from all modules in a single query:
As some devices are known to be picky on multimodule queries, I'm marking this a draft in hopes of getting feedback if this works on the majority of devices as it is or not.
Further updates and improvements are to be done on
modularizebranch which is the target branch of this PR.