From 84452aa1eaa39fe605fa9129f9d95f56dedda873 Mon Sep 17 00:00:00 2001 From: Milo You Date: Tue, 13 Oct 2020 14:29:54 +0800 Subject: [PATCH] Revert "Check color mode values for emptiness (#829)" This reverts commit fc6740494318dc0693433b0d4d9ab393cf3474c0. --- miio/yeelight.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/miio/yeelight.py b/miio/yeelight.py index 8f7305e1b..3d23bf9c7 100644 --- a/miio/yeelight.py +++ b/miio/yeelight.py @@ -39,9 +39,8 @@ def brightness(self) -> int: @property def rgb(self) -> Optional[Tuple[int, int, int]]: """Return color in RGB if RGB mode is active.""" - rgb = self.data["rgb"] - if self.color_mode == YeelightMode.RGB and rgb: - return int_to_rgb(int(rgb)) + if self.color_mode == YeelightMode.RGB: + return int_to_rgb(int(self.data["rgb"])) return None @property @@ -52,19 +51,15 @@ def color_mode(self) -> YeelightMode: @property def hsv(self) -> Optional[Tuple[int, int, int]]: """Return current color in HSV if HSV mode is active.""" - hue = self.data["hue"] - sat = self.data["sat"] - brightness = self.data["bright"] - if self.color_mode == YeelightMode.HSV and (hue or sat or brightness): - return hue, sat, brightness + if self.color_mode == YeelightMode.HSV: + return self.data["hue"], self.data["sat"], self.data["bright"] return None @property def color_temp(self) -> Optional[int]: """Return current color temperature, if applicable.""" - ct = self.data["ct"] - if self.color_mode == YeelightMode.ColorTemperature and ct: - return int(ct) + if self.color_mode == YeelightMode.ColorTemperature: + return int(self.data["ct"]) return None @property