From 4c186bc3b708b3b750a303fa5b778b054df63300 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 22 Jan 2018 10:27:02 +0100 Subject: [PATCH] Xiaomi Air Humidifier: Unavailable property "led" removed. (#170) * Unavailable property "led" removed. * Property "led" removed from tests. * Example payload updated. --- miio/airhumidifier.py | 25 ++++++++++--------------- miio/tests/test_airhumidifier.py | 13 ------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/miio/airhumidifier.py b/miio/airhumidifier.py index d72888ea8..cc45645e7 100644 --- a/miio/airhumidifier.py +++ b/miio/airhumidifier.py @@ -23,6 +23,13 @@ class AirHumidifierStatus: """Container for status reports from the air humidifier.""" def __init__(self, data: Dict[str, Any]) -> None: + """ + Response of a Air Humidifier (zhimi.humidifier.v1): + + {'power': 'off', 'mode': 'high', 'temp_dec': 294, + 'humidity': 33, 'buzzer': 'on', 'led_b': 0} + """ + self.data = data @property @@ -57,11 +64,6 @@ def buzzer(self) -> bool: """True if buzzer is turned on.""" return self.data["buzzer"] == "on" - @property - def led(self) -> bool: - """True if LED is turned on.""" - return self.data["led"] == "on" - @property def led_brightness(self) -> Optional[LedBrightness]: """LED brightness if available.""" @@ -71,9 +73,9 @@ def led_brightness(self) -> Optional[LedBrightness]: def __str__(self) -> str: s = "" % \ + "humidity=%s%%, led_brightness=%s, buzzer=%s>" % \ (self.power, self.mode, self.temperature, - self.humidity, self.led, self.led_brightness, self.buzzer) + self.humidity, self.led_brightness, self.buzzer) return s @@ -84,7 +86,7 @@ def status(self) -> AirHumidifierStatus: """Retrieve properties.""" properties = ['power', 'mode', 'temp_dec', 'humidity', 'buzzer', - 'led_b', 'led', ] + 'led_b', ] values = self.send( "get_prop", @@ -118,13 +120,6 @@ def set_led_brightness(self, brightness: LedBrightness): """Set led brightness.""" return self.send("set_led_b", [brightness.value]) - def set_led(self, led: bool): - """Turn led on/off.""" - if led: - return self.send("set_led", ['on']) - else: - return self.send("set_led", ['off']) - def set_buzzer(self, buzzer: bool): """Set buzzer on/off.""" if buzzer: diff --git a/miio/tests/test_airhumidifier.py b/miio/tests/test_airhumidifier.py index 6fb3e6b48..317f4c85d 100644 --- a/miio/tests/test_airhumidifier.py +++ b/miio/tests/test_airhumidifier.py @@ -13,14 +13,12 @@ def __init__(self, *args, **kwargs): 'temp_dec': 186, 'humidity': 62, 'buzzer': 'off', - 'led': 'off', 'led_b': 2, } self.return_values = { 'get_prop': self._get_state, 'set_power': lambda x: self._set_state("power", x), 'set_mode': lambda x: self._set_state("mode", x), - 'set_led': lambda x: self._set_state("led", x), 'set_led_b': lambda x: self._set_state("led_b", x), 'set_buzzer': lambda x: self._set_state("buzzer", x), } @@ -64,7 +62,6 @@ def test_status(self): assert self.state().temperature == self.device.start_state["temp_dec"] / 10.0 assert self.state().humidity == self.device.start_state["humidity"] assert self.state().mode == OperationMode(self.device.start_state["mode"]) - assert self.state().led == (self.device.start_state["led"] == 'on') assert self.state().led_brightness == LedBrightness(self.device.start_state["led_b"]) assert self.state().buzzer == (self.device.start_state["buzzer"] == 'on') @@ -94,16 +91,6 @@ def led_brightness(): self.device.set_led_brightness(LedBrightness.Off) assert led_brightness() == LedBrightness.Off - def test_set_led(self): - def led(): - return self.device.status().led - - self.device.set_led(True) - assert led() is True - - self.device.set_led(False) - assert led() is False - def test_set_buzzer(self): def buzzer(): return self.device.status().buzzer