Skip to content

Improved support of the Xiaomi Smart Fan#306

Merged
syssi merged 8 commits intorytilahti:masterfrom
syssi:feature/fan-updates
Apr 16, 2018
Merged

Improved support of the Xiaomi Smart Fan#306
syssi merged 8 commits intorytilahti:masterfrom
syssi:feature/fan-updates

Conversation

@syssi
Copy link
Copy Markdown
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


_LOGGER = logging.getLogger(__name__)

class FanException(DeviceException):
Copy link
Copy Markdown

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
Copy Markdown

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):
Copy link
Copy Markdown

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,
Copy link
Copy Markdown

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:
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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):
Copy link
Copy Markdown

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

'bat_charge',
'button_pressed',
],
}
Copy link
Copy Markdown
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
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants