From 8965e6becf02cf18c9483f49aa420164cdb99bef Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 31 Aug 2022 22:53:27 -0700 Subject: [PATCH] Ugly first implementation --- custom_components/adaptive_lighting/switch.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 1108dd80..0e166abe 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -816,6 +816,18 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): color_temp_mired = self._settings["color_temp_mired"] color_temp_mired = max(min(color_temp_mired, max_mireds), min_mireds) service_data[ATTR_COLOR_TEMP] = color_temp_mired + if ( + self.sleep_mode_switch.is_on + and self._sun_light_settings.sleep_rgb_or_color_temp == "rgb_color" + ): + # Special case: if we're in sleep mode and the user has chosen to use RGB color + # in sleep mode, we use this + if "color" not in features: + raise ValueError( + "sleep_rgb_or_color_temp is set to 'rgb_color' however it is " + "not supported by the light." + ) + service_data[ATTR_RGB_COLOR] = self._settings["rgb_color"] elif "color" in features and adapt_color: service_data[ATTR_RGB_COLOR] = self._settings["rgb_color"]