-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Additional properties of the Xiaomi Air Purifier 2 introduced #132
Additional properties of the Xiaomi Air Purifier 2 introduced #132
Conversation
miio/airpurifier.py
Outdated
@@ -1,5 +1,6 @@ | |||
import logging | |||
import enum | |||
import math |
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.
'math' imported but unused
1 similar comment
miio/tests/test_airpurifier.py
Outdated
|
||
assert self.is_on() is True | ||
assert self.state().temperature == \ | ||
self.device.start_state["temp_dec"] / 10.0 |
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.
continuation line over-indented for visual indent
miio/tests/test_airpurifier.py
Outdated
assert child_lock() == True | ||
|
||
self.device.set_child_lock(False) | ||
assert child_lock() == False |
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.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_airpurifier.py
Outdated
return self.device.status().child_lock | ||
|
||
self.device.set_child_lock(True) | ||
assert child_lock() == True |
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.
comparison to True should be 'if cond is True:' or 'if cond:'
miio/tests/test_airpurifier.py
Outdated
assert buzzer() == True | ||
|
||
self.device.set_buzzer(False) | ||
assert buzzer() == False |
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.
comparison to False should be 'if cond is False:' or 'if not cond:'
miio/tests/test_airpurifier.py
Outdated
return self.device.status().buzzer | ||
|
||
self.device.set_buzzer(True) | ||
assert buzzer() == True |
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.
comparison to True should be 'if cond is True:' or 'if cond:'
miio/tests/test_airpurifier.py
Outdated
assert led() == True | ||
|
||
self.device.set_led(False) | ||
assert led() == False |
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.
comparison to False should be 'if cond is False:' or 'if not cond:'
assert self.state().mode == OperationMode(self.device.start_state["mode"]) | ||
assert self.state().favorite_level == self.device.start_state["favorite_level"] | ||
assert self.state().filter_life_remaining == self.device.start_state["filter1_life"] | ||
assert self.state().filter_hours_used == self.device.start_state["f1_hour_used"] |
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.
line too long (88 > 79 characters)
assert self.state().humidity == self.device.start_state["humidity"] | ||
assert self.state().mode == OperationMode(self.device.start_state["mode"]) | ||
assert self.state().favorite_level == self.device.start_state["favorite_level"] | ||
assert self.state().filter_life_remaining == self.device.start_state["filter1_life"] |
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.
line too long (92 > 79 characters)
assert self.state().temperature == self.device.start_state["temp_dec"] / 10.0 | ||
assert self.state().humidity == self.device.start_state["humidity"] | ||
assert self.state().mode == OperationMode(self.device.start_state["mode"]) | ||
assert self.state().favorite_level == self.device.start_state["favorite_level"] |
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.
line too long (87 > 79 characters)
assert self.state().average_aqi == self.device.start_state["average_aqi"] | ||
assert self.state().temperature == self.device.start_state["temp_dec"] / 10.0 | ||
assert self.state().humidity == self.device.start_state["humidity"] | ||
assert self.state().mode == OperationMode(self.device.start_state["mode"]) |
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.
line too long (82 > 79 characters)
assert self.is_on() is True | ||
assert self.state().aqi == self.device.start_state["aqi"] | ||
assert self.state().average_aqi == self.device.start_state["average_aqi"] | ||
assert self.state().temperature == self.device.start_state["temp_dec"] / 10.0 |
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.
line too long (85 > 79 characters)
miio/tests/test_airpurifier.py
Outdated
self.device.state["bright"] = self.device.state["led_b"] | ||
del self.device.state["led_b"] | ||
|
||
assert self.state().led_brightness == LedBrightness(self.device.start_state["led_b"]) |
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.
line too long (93 > 79 characters)
miio/tests/test_airpurifier.py
Outdated
|
||
# The LED brightness of a Air Purifier Pro cannot be set so far. | ||
self.device.set_led(True) | ||
assert led() == True |
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.
comparison to True should be 'if cond is True:' or 'if cond:'
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.
Thanks for fixing docstrings and new tests! I added a couple of comments behind, feel free to merge if you consider things are fine as they are / after changing those (and fixing those hound warnings where deemed necessary, i.e. the None checks at least) :-)
miio/airpurifier.py
Outdated
|
||
values = self.send( | ||
"get_prop", | ||
properties | ||
properties[0:13] |
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.
Mind leaving a comment behind to explain why using only a slice here? Same below too.
|
||
# This is the property name of the Air Purifier Pro | ||
if self.data["bright"] is not None: | ||
return LedBrightness(self.data["bright"]) |
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.
Does this mean that when the device is not air purifier pro, the "led_b" will be empty? If yes, then it's fine.
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.
Yep. The air purifier provides a "bright" property XOR a "led_b" property.
miio/tests/test_airpurifier.py
Outdated
return self.device.status().favorite_level | ||
|
||
self.device.set_favorite_level(1) | ||
assert favorite_level() == 1 |
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.
Is it known what values are allowed for favorite level? If yes, it makes probably sense to add an exception if out-of-range values are inputed, and to add a test for that also here (https://docs.pytest.org/en/latest/assert.html#assertions-about-expected-exceptions).
miio/tests/test_airpurifier.py
Outdated
del self.device.state["led_b"] | ||
|
||
assert self.state().led_brightness == \ | ||
LedBrightness(self.device.start_state["led_b"]) |
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.
continuation line over-indented for visual indent
|
||
assert self.is_on() is True | ||
assert self.state().aqi == self.device.start_state["aqi"] | ||
assert self.state().average_aqi == self.device.start_state["average_aqi"] |
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.
line too long (81 > 79 characters)
miio/tests/test_airpurifier.py
Outdated
del self.device.state["led_b"] | ||
|
||
assert self.state().led_brightness == \ | ||
LedBrightness(self.device.start_state["led_b"]) |
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.
continuation line over-indented for visual indent
|
||
assert self.is_on() is True | ||
assert self.state().aqi == self.device.start_state["aqi"] | ||
assert self.state().average_aqi == self.device.start_state["average_aqi"] |
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.
line too long (81 > 79 characters)
miio/tests/test_airpurifier.py
Outdated
def test_status_string(self): | ||
self.device._reset_state() | ||
|
||
assert self.state().__str__ |
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 status string should be __repr__
instead of __str__
, right? https://stackoverflow.com/questions/1436703/difference-between-str-and-repr-in-python
miio/airpurifier.py
Outdated
|
||
use_time and motor1_speed is missing because a request is limitted | ||
to 16 properties. We request 15 properties at the moment. | ||
A request is limitted to 16 properties. |
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.
limited
Additional properties of the Xiaomi Air Purifier 2 introduced. Some code clean-up.
Property average_aqi fixed. Missing method "set_child_lock" added.
3911b40
to
cf5a544
Compare
This reverts commit 779bb83.
Some comments improved.
Some code clean-up.