-
-
Notifications
You must be signed in to change notification settings - Fork 223
Add module support & query their information during update cycle #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
|
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. |
* 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
…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
* 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
* 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
* 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
* 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
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 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
modularize
branch which is the target branch of this PR.