-
-
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
Improved support of the Xiaomi Smart Fan #306
Conversation
miio/fan.py
Outdated
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
class FanException(DeviceException): |
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.
expected 2 blank lines, found 1
miio/tests/test_fan.py
Outdated
assert self.state().battery_state == self.device.start_state["bat_state"] | ||
assert self.state().button_pressed == self.device.start_state["button_pressed"] | ||
|
||
class DummyFanV3(DummyDevice, Fan): |
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.
expected 2 blank lines, found 1
import pytest | ||
|
||
from miio import Fan | ||
from miio.fan import (MoveDirection, LedBrightness, FanStatus, FanException, |
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.
'miio.fan.MoveDirection' imported but unused
'miio.fan.FanException' imported but unused
miio/fan.py
Outdated
return self.data["led"] == "on" | ||
def led(self) -> Optional[bool]: | ||
"""True if LED is turned on, if available.""" | ||
if "led" in self.data and self.data["led"] is not None: |
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.
multiple spaces after keyword
miio/tests/test_fan.py
Outdated
self.device.set_rotate(MoveDirection.Left) | ||
self.device.set_rotate(MoveDirection.Right) | ||
|
||
def test_set_direct_speed(self): |
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.
redefinition of unused 'test_set_direct_speed' from line 369
miio/tests/test_fan.py
Outdated
self.device.set_rotate(MoveDirection.Left) | ||
self.device.set_rotate(MoveDirection.Right) | ||
|
||
def test_set_direct_speed(self): |
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.
redefinition of unused 'test_set_direct_speed' from line 141
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.
Looks great, just a couple of nitpicks :-)
miio/fan.py
Outdated
'bat_charge', | ||
'button_pressed', | ||
], | ||
} |
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.
I think it would be nice to have a GENERIC_PROPERTIES
(ugh, global variables with uppercasing.. feels so unpythonic :-)), considering quite a few are shared anyway:
>>> set(x) & set(y)
{'bat_charge', 'poweroff_time', 'ac_power', 'led_b', 'use_time', 'humidity',
'button_pressed', 'battery', 'angle_enable', 'speed_level', 'temp_dec',
'child_lock', 'buzzer', 'natural_level', 'power', 'angle', 'speed'}
miio/fan.py
Outdated
def set_direction(self, direction: MoveDirection): | ||
"""Set move direction.""" | ||
def set_rotate(self, direction: MoveDirection): | ||
"""Rotate the fan by 5 degrees left/right.""" |
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.
left for negative 5, right for positive?
Properties: temp_dec, humidity, angle, speed, ac_power, battery, angle_enable, natural_level, child_lock, buzzer, led_b
Methods: