-
-
Notifications
You must be signed in to change notification settings - Fork 567
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
Add model autodetection #1038
Merged
Merged
Add model autodetection #1038
Conversation
This file contains 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
Different device models (even when supported by a single integration) can have different features or even different properties/API. Previously, some integrations have used a model argument to define the exact device type to be able to adapt to these differences, but there has been no generalized solution for this issue. This PR will introduce automatic model detection based on the miIO.info query. The first invokation of any command-decorated method will do the query to find the model of the device. The response of this query is cached, so this will only happen once. * info() has now a new keyword-only argument 'skip_cache' which can be used to bypass the cache * Device constructor has a new keyword-only argument to specifying the model (which skips the info query) * This PR converts Vacuum class to use these new facilities for fanspeed controls
rytilahti
force-pushed
the
feat/model_autodetect
branch
from
June 16, 2021 16:01
fe65426
to
5c941ad
Compare
Codecov Report
@@ Coverage Diff @@
## master #1038 +/- ##
==========================================
+ Coverage 75.40% 76.19% +0.78%
==========================================
Files 73 74 +1
Lines 8367 8337 -30
Branches 745 722 -23
==========================================
+ Hits 6309 6352 +43
+ Misses 1874 1805 -69
+ Partials 184 180 -4
Continue to review full report at Codecov.
|
This was referenced Jun 24, 2021
rytilahti
added a commit
that referenced
this pull request
Sep 17, 2021
* Add model autodetection Different device models (even when supported by a single integration) can have different features or even different properties/API. Previously, some integrations have used a model argument to define the exact device type to be able to adapt to these differences, but there has been no generalized solution for this issue. This PR will introduce automatic model detection based on the miIO.info query. The first invokation of any command-decorated method will do the query to find the model of the device. The response of this query is cached, so this will only happen once. * info() has now a new keyword-only argument 'skip_cache' which can be used to bypass the cache * Device constructor has a new keyword-only argument to specifying the model (which skips the info query) * This PR converts Vacuum class to use these new facilities for fanspeed controls * tests: self.model -> self._model * WIP add some missing models, fix infinite loop, experiment with supported_models * convert all devices to use the parent ctor's model kwarg, fix mypy errors * Fix tests * Add test for unsupported model logging * revert mistakenly changed test call for test_forced_model * powerstrip: add known models to supported models
15 tasks
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.
Different device models (even when supported by a single integration) can have different features or even different properties/API.
Previously, some integrations have used a model argument to define the exact device type to be able to adapt to these differences,
but there has been no generalized solution for this issue.
This PR will introduce automatic model detection based on the miIO.info query.
The first invocation of any command-decorated method will do the query to find the model of the device.
The response of this query is cached, so this will only happen once.
In the future, there should be no need to use different classes for devices/models that are using only a slightly different feature sets / commands / properties.
This would simplify the usage at least for users of the following classes (based on discovery.py):
Fan
,FanMiot
,ChuangmiPlug
,PowerStrip
,AirDog*
,AirHumidifer
,AirhumidifierJsq
,AirConditioningCompanion
,AirFresh
,AirQualityMonitor
, andHeater
.@syssi your feedback would be greatly appreciated, as you have more insight on the classes using
model
! :-)TBD: