From 2b35ee1e5e8959a1315384536792f036b2ce6b2c Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Sun, 30 Jul 2023 11:49:40 -0700 Subject: [PATCH] Mark as manually controlled when using flash, effect, or RGBW(W) (#684) * Mark as manually controlled when using flash or effect * Add comment * Add RGBW and RGBWW --- .../adaptive_lighting/adaptation_utils.py | 5 +++++ custom_components/adaptive_lighting/switch.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/custom_components/adaptive_lighting/adaptation_utils.py b/custom_components/adaptive_lighting/adaptation_utils.py index 99d1eea5..e0ab6c47 100644 --- a/custom_components/adaptive_lighting/adaptation_utils.py +++ b/custom_components/adaptive_lighting/adaptation_utils.py @@ -13,6 +13,8 @@ from homeassistant.components.light import ( ATTR_COLOR_TEMP_KELVIN, ATTR_HS_COLOR, ATTR_RGB_COLOR, + ATTR_RGBW_COLOR, + ATTR_RGBWW_COLOR, ATTR_TRANSITION, ATTR_XY_COLOR, ) @@ -27,8 +29,11 @@ COLOR_ATTRS = { # Should ATTR_PROFILE be in here? ATTR_HS_COLOR, ATTR_RGB_COLOR, ATTR_XY_COLOR, + ATTR_RGBW_COLOR, + ATTR_RGBWW_COLOR, } + BRIGHTNESS_ATTRS = { ATTR_BRIGHTNESS, ATTR_BRIGHTNESS_PCT, diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 9f2c11e3..181bd20d 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -21,6 +21,8 @@ import voluptuous as vol from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP_KELVIN, + ATTR_EFFECT, + ATTR_FLASH, ATTR_RGB_COLOR, ATTR_SUPPORTED_COLOR_MODES, ATTR_TRANSITION, @@ -1450,6 +1452,7 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): context.id, ) else: + # Need to fire manual control event because of significant_change _fire_manual_control_event(self, light, context) else: _LOGGER.debug( @@ -2371,8 +2374,11 @@ class AdaptiveLightingManager: and not force ): keys = turn_on_event.data[ATTR_SERVICE_DATA].keys() - if (adapt_color and COLOR_ATTRS.intersection(keys)) or ( - adapt_brightness and BRIGHTNESS_ATTRS.intersection(keys) + if ( + (adapt_color and COLOR_ATTRS.intersection(keys)) + or (adapt_brightness and BRIGHTNESS_ATTRS.intersection(keys)) + or (ATTR_FLASH in keys) + or (ATTR_EFFECT in keys) ): # Light was already on and 'light.turn_on' was not called by # the adaptive_lighting integration.