From afd7b935d7ad399c8b0a19dcb1ff6d2e07a31ddf Mon Sep 17 00:00:00 2001 From: DataGhost <3911340+DataGhost@users.noreply.github.com> Date: Thu, 27 Nov 2025 18:54:14 +0100 Subject: [PATCH] Check for external light mode (temperature vs rgb) switch (#1282) --- custom_components/adaptive_lighting/switch.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 19e99d78..b423fc3c 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -766,6 +766,31 @@ def _attributes_have_changed( context.id, ) return True + + if adapt_color and ( + ( + old_attributes.get(ATTR_COLOR_TEMP_KELVIN) + and not new_attributes.get(ATTR_COLOR_TEMP_KELVIN) + ) + or ( + old_attributes.get(ATTR_RGB_COLOR) + and not new_attributes.get(ATTR_RGB_COLOR) + ) + ): + last_mode = ( + "color_temp" if old_attributes.get(ATTR_COLOR_TEMP_KELVIN) else "rgb" + ) + current_mode = ( + "color_temp" if new_attributes.get(ATTR_COLOR_TEMP_KELVIN) else "rgb" + ) + _LOGGER.debug( + "Light mode of %s changed from %s to %s with context.id='%s'", + light, + last_mode, + current_mode, + context.id, + ) + return True return False