Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yeelight status for white-only bulbs #1562

Merged
merged 1 commit into from Oct 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions miio/integrations/light/yeelight/yeelight.py
Expand Up @@ -57,9 +57,12 @@ def rgb(self) -> Optional[Tuple[int, int, int]]:
return None

@property
def color_mode(self) -> YeelightMode:
def color_mode(self) -> Optional[YeelightMode]:
"""Return current color mode."""
return YeelightMode(int(self.data[self.get_prop_name("color_mode")]))
try:
return YeelightMode(int(self.data[self.get_prop_name("color_mode")]))
except ValueError: # white only bulbs
return None

@property
def hsv(self) -> Optional[Tuple[int, int, int]]:
Expand Down Expand Up @@ -120,7 +123,7 @@ def rgb(self) -> Optional[Tuple[int, int, int]]:
return self.lights[0].rgb

@property
def color_mode(self) -> YeelightMode:
def color_mode(self) -> Optional[YeelightMode]:
"""Return current color mode."""
return self.lights[0].color_mode

Expand Down Expand Up @@ -218,7 +221,7 @@ def cli_format(self) -> str:
s += f"{light.type.name} light\n"
s += f" Power: {light.is_on}\n"
s += f" Brightness: {light.brightness}\n"
s += f" Color mode: {light.color_mode.name}\n"
s += f" Color mode: {light.color_mode}\n"
if light.color_mode == YeelightMode.RGB:
s += f" RGB: {light.rgb}\n"
elif light.color_mode == YeelightMode.HSV:
Expand Down