Skip to content
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

Air Purifier Pro second motor speed #176

Merged
merged 6 commits into from
Jan 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ def motor_speed(self) -> int:
"""Speed of the motor."""
return self.data["motor1_speed"]

@property
def motor2_speed(self) -> Optional[int]:
"""Speed of the 2nd motor."""
return self.data["motor2_speed"]

@property
def volume(self) -> Optional[int]:
"""Volume of sound notifications [0-100]."""
Expand All @@ -175,6 +180,7 @@ def __repr__(self) -> str:
"use_time=%s, " \
"purify_volume=%s, " \
"motor_speed=%s, " \
"motor2_speed=%s, " \
"volume=%s>" % \
(self.power,
self.aqi,
Expand All @@ -193,6 +199,7 @@ def __repr__(self) -> str:
self.use_time,
self.purify_volume,
self.motor_speed,
self.motor2_speed,
self.volume)
return s

Expand All @@ -205,10 +212,11 @@ def status(self) -> AirPurifierStatus:

properties = ['power', 'aqi', 'average_aqi', 'humidity', 'temp_dec',
'mode', 'favorite_level', 'filter1_life', 'f1_hour_used',
'use_time', 'motor1_speed', 'purify_volume', 'f1_hour',
'use_time', 'motor1_speed', 'motor2_speed',
'purify_volume',
# Second request
'led', 'led_b', 'bright', 'buzzer', 'child_lock',
'volume', ]
'f1_hour', 'led', 'led_b', 'bright', 'buzzer',
'child_lock', 'volume', ]

# A single request is limited to 16 properties. Therefore the
# properties are divided in two groups here. The second group contains
Expand Down
2 changes: 2 additions & 0 deletions miio/tests/test_airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, *args, **kwargs):
'f1_hour_used': 682,
'use_time': 2457000,
'motor1_speed': 354,
'motor2_speed': 800,
'purify_volume': 25262,
'f1_hour': 3500,
'led': 'off',
Expand Down Expand Up @@ -87,6 +88,7 @@ def test_status(self):
assert self.state().filter_hours_used == self.device.start_state["f1_hour_used"]
assert self.state().use_time == self.device.start_state["use_time"]
assert self.state().motor_speed == self.device.start_state["motor1_speed"]
assert self.state().motor2_speed == self.device.start_state["motor2_speed"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (83 > 79 characters)

assert self.state().purify_volume == self.device.start_state["purify_volume"]

assert self.state().led == (self.device.start_state["led"] == 'on')
Expand Down