-
Notifications
You must be signed in to change notification settings - Fork 67
Fix light polling trusting unsupported color_mode
#707
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
Changes from all commits
dc9ac69
0ad05d5
acc3160
d21c886
8374715
fe5194b
afc7e52
43a1a51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,7 +258,8 @@ def restore_external_state_attributes( | |
| self._color_temp = color_temp | ||
| if xy_color is not None: | ||
| self._xy_color = xy_color | ||
| if color_mode is not None: | ||
| # Older persisted states may contain a color_mode not in supported modes | ||
| if color_mode is not None and color_mode in self._supported_color_modes: | ||
| self._color_mode = color_mode | ||
| if effect is not None: | ||
| self._effect = effect | ||
|
|
@@ -1085,14 +1086,22 @@ async def async_update(self) -> None: | |
| return # type: ignore[unreachable] | ||
|
|
||
| if (color_mode := results.get("color_mode")) is not None: | ||
| if color_mode == Color.ColorMode.Color_temperature: | ||
| self._color_mode = ColorMode.COLOR_TEMP | ||
| # Determine the effective color mode: if only one mode is | ||
| # supported, use it regardless of what the device reports | ||
| if len(self._supported_color_modes) == 1: | ||
| effective_mode = next(iter(self._supported_color_modes)) | ||
|
Comment on lines
1088
to
+1092
|
||
| elif color_mode == Color.ColorMode.Color_temperature: | ||
| effective_mode = ColorMode.COLOR_TEMP | ||
| else: | ||
| effective_mode = ColorMode.XY | ||
| self._color_mode = effective_mode | ||
|
|
||
| if effective_mode == ColorMode.COLOR_TEMP: | ||
| color_temp = results.get("color_temperature") | ||
| if color_temp is not None and color_mode: | ||
| if color_temp is not None: | ||
| self._color_temp = color_temp | ||
| self._xy_color = None | ||
| else: | ||
| self._color_mode = ColorMode.XY | ||
| elif effective_mode == ColorMode.XY: | ||
| color_x = results.get("current_x") | ||
| color_y = results.get("current_y") | ||
| if color_x is not None and color_y is not None: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.