Skip to content

Commit

Permalink
Revert "Check color mode values for emptiness (rytilahti#829)"
Browse files Browse the repository at this point in the history
This reverts commit fc67404.
  • Loading branch information
swim2sun authored Oct 13, 2020
1 parent 841abc4 commit 84452aa
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions miio/yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 84452aa

Please sign in to comment.