diff --git a/miio/airhumidifier.py b/miio/airhumidifier.py index 031d30c04..a143d1171 100644 --- a/miio/airhumidifier.py +++ b/miio/airhumidifier.py @@ -337,6 +337,20 @@ def set_led_brightness(self, brightness: LedBrightness): """Set led brightness.""" return self.send("set_led_b", [brightness.value]) + @command( + click.argument("led", type=bool), + default_output=format_output( + lambda led: "Turning on LED" + if led else "Turning off LED" + ) + ) + def set_led(self, led: bool): + """Turn led on/off.""" + if led: + return self.set_led_brightness(LedBrightness.Bright) + else: + return self.set_led_brightness(LedBrightness.Off) + @command( click.argument("buzzer", type=bool), default_output=format_output( diff --git a/miio/tests/test_airhumidifier.py b/miio/tests/test_airhumidifier.py index a9bcfb973..af933d05f 100644 --- a/miio/tests/test_airhumidifier.py +++ b/miio/tests/test_airhumidifier.py @@ -147,6 +147,16 @@ def led_brightness(): self.device.set_led_brightness(LedBrightness.Off) assert led_brightness() == LedBrightness.Off + def test_set_led(self): + def led_brightness(): + return self.device.status().led_brightness + + self.device.set_led(True) + assert led_brightness() == LedBrightness.Bright + + self.device.set_led(False) + assert led_brightness() == LedBrightness.Off + def test_set_buzzer(self): def buzzer(): return self.device.status().buzzer @@ -343,6 +353,16 @@ def led_brightness(): self.device.set_led_brightness(LedBrightness.Off) assert led_brightness() == LedBrightness.Off + def test_set_led(self): + def led_brightness(): + return self.device.status().led_brightness + + self.device.set_led(True) + assert led_brightness() == LedBrightness.Bright + + self.device.set_led(False) + assert led_brightness() == LedBrightness.Off + def test_set_buzzer(self): def buzzer(): return self.device.status().buzzer