Skip to content

Commit

Permalink
SleepMode enum added. SleepMode isn't a subset of OperationMode. (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Jan 28, 2018
1 parent ae5f4ba commit b0c04cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class OperationMode(enum.Enum):
Idle = 'idle'


class SleepMode(enum.Enum):
Off = 'poweroff'
Silent = 'silent'
Idle = 'idle'


class LedBrightness(enum.Enum):
Bright = 0
Dim = 1
Expand Down Expand Up @@ -112,10 +118,10 @@ def mode(self) -> OperationMode:
return OperationMode(self.data["mode"])

@property
def sleep_mode(self) -> Optional[OperationMode]:
def sleep_mode(self) -> Optional[SleepMode]:
"""Operation mode of the sleep state. (Idle vs. Silent)"""
if self.data["sleep_mode"] is not None:
return OperationMode(self.data["sleep_mode"])
return SleepMode(self.data["sleep_mode"])

return None

Expand Down
4 changes: 2 additions & 2 deletions miio/tests/test_airpurifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest import TestCase
from miio import AirPurifier
from miio.airpurifier import (
OperationMode, LedBrightness, FilterType, AirPurifierException
OperationMode, LedBrightness, FilterType, SleepMode, AirPurifierException
)
from .dummies import DummyDevice
import pytest
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_status(self):
assert self.state().illuminance == self.device.start_state["bright"]
assert self.state().volume == self.device.start_state["volume"]
assert self.state().filter_rfid_product_id == self.device.start_state["rfid_product_id"]
assert self.state().sleep_mode == OperationMode(self.device.start_state["sleep_mode"])
assert self.state().sleep_mode == SleepMode(self.device.start_state["sleep_mode"])
assert self.state().sleep_time == self.device.start_state["sleep_time"]
assert self.state().sleep_mode_learn_count == self.device.start_state["sleep_data_num"]
assert self.state().extra_features == self.device.start_state["app_extra"]
Expand Down

0 comments on commit b0c04cf

Please sign in to comment.