-
-
Notifications
You must be signed in to change notification settings - Fork 595
Permit setting aqi_realtime_update_duration and do not override the value of aqi_realtime_update_duration if it is set for the Mi Air Purifier 3/3H (zhimi.airpurifier.mb3). #2040
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
Open
d1b
wants to merge
1
commit into
rytilahti:master
Choose a base branch
from
d1b:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,10 @@ | |
| "filter_rfid_product_id": "0:0:41:30", | ||
| "filter_rfid_tag": "10:20:30:40:50:60:7", | ||
| "button_pressed": "power", | ||
| "aqi_realtime_update_duration": 0, | ||
| } | ||
|
|
||
|
|
||
| _INITIAL_STATE_MB4 = { | ||
| "power": True, | ||
| "aqi": 10, | ||
|
|
@@ -91,6 +93,9 @@ def __init__(self, *args, **kwargs): | |
| ), | ||
| "set_act_det": lambda x: self._set_state("act_det", x), | ||
| "set_app_extra": lambda x: self._set_state("app_extra", x), | ||
| "set_aqi_realtime_update_duration": lambda x: self._set_state( | ||
| "aqi_realtime_update_duration", x | ||
| ), | ||
| } | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
|
|
@@ -236,6 +241,44 @@ def test_set_anion(self): | |
| self.device.set_anion(True) | ||
|
|
||
|
|
||
| class DummyAirPurifierMiotMB3(DummyAirPurifierMiot): | ||
| def __init__(self, *args, **kwargs): | ||
| self._model = "zhimi.airpurifier.mb3" | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def airpurifierMB3(request): | ||
| request.cls.device = DummyAirPurifierMiotMB3() | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures("airpurifierMB3") | ||
| class TestAirPurifierMB3(TestCase): | ||
| def test_status(self): | ||
| default_adjusted_value = 5 | ||
| specific_value = 10 | ||
| status = self.device.status() | ||
| assert _INITIAL_STATE["aqi_realtime_update_duration"] == 0 | ||
| assert status.aqi_realtime_update_duration == default_adjusted_value | ||
|
|
||
| # Set a specific value | ||
|
|
||
| self.device.set_aqi_realtime_update_duration(specific_value) | ||
|
|
||
| # Check that we do not override a specific set value | ||
| status = self.device.status() | ||
|
|
||
| assert status.aqi_realtime_update_duration == specific_value | ||
|
|
||
| def test_set_aqi_realtime_update_duration_negative_value(self): | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what other models have or do not have the ability to set and or provide information on |
||
| with pytest.raises(ValueError): | ||
| self.device.set_aqi_realtime_update_duration(-1) | ||
|
|
||
| def test_set_aqi_realtime_update_duration(self): | ||
| self.device.set_aqi_realtime_update_duration(12) | ||
| assert self.device.status().aqi_realtime_update_duration == 12 | ||
|
|
||
|
|
||
| class DummyAirPurifierMiotMB4(DummyAirPurifierMiot): | ||
| def __init__(self, *args, **kwargs): | ||
| self._model = "zhimi.airpurifier.mb4" | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for my 3H for this setting is 0. I can move this change to device specific init state if that is desired.