Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved support of the Xiaomi Smart Fan #306

Merged
merged 8 commits into from
Apr 16, 2018

Conversation

syssi
Copy link
Collaborator

@syssi syssi commented Apr 12, 2018

Properties: temp_dec, humidity, angle, speed, ac_power, battery, angle_enable, natural_level, child_lock, buzzer, led_b

Methods:

  • set_angle
  • set_angle_enable
  • set_buzzer
  • set_child_lock
  • set_led_b
  • set_speed_level
  • set_natural_level
  • set_power
  • set_poweroff_time
  • set_move
  • set_speed

miio/fan.py Outdated

_LOGGER = logging.getLogger(__name__)

class FanException(DeviceException):

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

@coveralls
Copy link

coveralls commented Apr 12, 2018

Coverage Status

Coverage increased (+2.5%) to 73.002% when pulling f1a2398 on syssi:feature/fan-updates into 25ef8ab on rytilahti:master.

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):

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,

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:

Choose a reason for hiding this comment

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

multiple spaces after keyword

self.device.set_rotate(MoveDirection.Left)
self.device.set_rotate(MoveDirection.Right)

def test_set_direct_speed(self):

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

self.device.set_rotate(MoveDirection.Left)
self.device.set_rotate(MoveDirection.Right)

def test_set_direct_speed(self):

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

Copy link
Owner

@rytilahti rytilahti left a 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',
],
}
Copy link
Owner

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."""
Copy link
Owner

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?

@syssi syssi merged commit 476aadc into rytilahti:master Apr 16, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants