adaptive-lighting: AL fails to detect native HA turning on of Hue lights (eg light.turn_on service call) and marks them all as manually controlled. Workaround is to enable "detect_non_ha_changes" but that's unreliable
Home Assistant Adaptive Lighting Issue Template
Bug Reports
EDIT: this seems like a worse regression than I thought originally. AL somehow doesn’t detect turning ON of a hue lights entity which represents a hue group through HA. E.g. if I turn on the lights using the Light Turn On HA service I see this in the logs.
2024-07-05 16:02:46.689 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom: Ignoring 'off' → 'on' event for 'light.nbr_window_1' with context.id='01J227VY8KS079NXXH8BCWZ3WJ' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False
I will try to enable detect_non_ha_changes for now but I dislike having that setting on. This might have been caused by the most recent change of HA changing details of how it advertises turning lights on that is incompatible with LA’s detection logic.
This seems to only be the case for light entities which are a hue group (using the official built-in Hue integration of Home Assistant).
Given this configuration
configuration (take from the attribute of the switch as I don't use YAML for AL):
lights: - light.north_bedroom
interval: 45
transition: 20
initial_transition: 8
min_brightness: 1
max_brightness: 100
min_color_temp: 1675
max_color_temp: 7000
prefer_rgb_color: false
sleep_brightness: 1
sleep_rgb_or_color_temp: rgb_color
sleep_color_temp: 1000
sleep_rgb_color: - 92 - 54 - 0
sleep_transition: 900
transition_until_sleep: false
take_over_control: true
detect_non_ha_changes: false
autoreset_control_seconds: 0
only_once: false
adapt_only_on_bare_turn_on: true
separate_turn_on_commands: false
send_split_delay: 0
adapt_delay: 0
skip_redundant_commands: false
intercept: true
multi_light_intercept: true
include_config_in_attributes: true
And assuming light.north_bedroom is a hue light group that controls N number of other lights.
If you turn on light.north_bedroom without requesting manual control (i.e. a simple light turn on)
BEFORE is empty as such:
manual_control:
NOW
manual_control: light.1, light.2, light.3, light.4
where those lights 1, 2, 3 are the actual lights in the light.north_bedroom light group.
Was this change by design or unintentional? This looks like a really bad bug.
Thank you.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 35 (6 by maintainers)
I experienced the same… In order to get it in working order, I had to re-enable all the low level lights exposed by Hue. This is not desired as it overwhelmed hue hub when you have a large amount of lights.
I experienced the same issue on a recent Core update, and had to revert back to the June release to restore functionality.
Based on the timing and nature of this issue, it is most likely the result of this commit: https://github.com/home-assistant/core/pull/113053
This commit adds the
entity_idattribute to Hue Group lights, which makes the Hue Groups functionally similar to other groups in HA. Its seems like a benign attribute change, and definitely has benefits at the HA core level.However…it now triggers this boolean method in Adaptive Lighting, which it would not have previously: https://github.com/basnijholt/adaptive-lighting/blob/8e8c520dad81fdcf4359b1c2b6ce7665b99286a6/custom_components/adaptive_lighting/switch.py#L640
There seems to be a bunch of AL logic based on this check, which I have yet to digest. But the net of all this is: AL treats individual lights and light groups differently. As the result of an HA core change, Hue groups are being treated as a light group, rather than an individual bulb.
How to fix? I hope an AL developer can chime in.
@basnijholt I posted my logs in the above linked issue. Two logs, one with only groups and one with a mixed group/individual configuration.
I think you might be describing a different issue or perhaps I’m missing something. For us the issue is the opposite. The lights are always marked as manual because the AL integration no longer detects light entities that represent hue light groups when they are turned on or off as originating from HA. So I’m a bit confused by your comment but I might be missing something.
Below are my logs after calling light.turn_on on ‘light.dans_bedroom’, with ‘light.dans_bedroom’ being the Hue group and the numbered lights being the individual lights within the group. I have my adaptive lighting setup for these lights on the ‘light.dans_bedroom’ Hue group, with none of the individual bulbs included in the configuration. I also did some digging into the Hue component’s code and found this change in which the entity IDs were added to Hue group bulbs, and figured that could possibly be contributing.
2024-07-31 23:31:12.173 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (0) _service_interceptor_turn_on_handler: call.context.id='01J45ZVQ5AVX809Q9DZGK3BDCS', is_skipped_hash='False' 2024-07-31 23:31:12.173 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (1) _service_interceptor_turn_on_handler: call='<ServiceCall light.turn_on (c:01J45ZVQ5AVX809Q9DZGK3BDCS): entity_id=['light.dans_bedroom_color_lights'], params=>', service_data='{'entity_id': ['light.dans_bedroom_color_lights'], 'params': {}}' 2024-07-31 23:31:12.174 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] No switch found for entity_id='light.dans_bedroom_color_lights', skipped='['light.dans_bedroom_color_lights']' 2024-07-31 23:31:12.175 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] (2) _service_interceptor_turn_on_handler: switch_to_eids='{}', skipped='['light.dans_bedroom_color_lights']' 2024-07-31 23:31:12.410 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.dans_bedroom_3' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['None', 'candle', 'fire', 'prism', 'sparkle', 'opal', 'glisten', 'sunrise', 'unknown'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'effect': 'None', 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 83, 'color_temp_kelvin': 2000, 'color_temp': 500, 'hs_color': (30.601, 94.547), 'rgb_color': (255, 136, 13), 'xy_color': (0.599, 0.382), 'mode': 'normal', 'dynamics': 'none', 'icon': 'hue:bulb-sultan', 'friendly_name': 'Dan’s Bedroom 3', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01J45ZVQCS9KN68X61XEDTAAKJ' 2024-07-31 23:31:12.410 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.dans_bedroom_3' with context.id='01J45ZVQCS9KN68X61XEDTAAKJ' 2024-07-31 23:31:12.411 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J45ZVQCS9KN68X61XEDTAAKJ' 2024-07-31 23:31:12.411 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: delta_time='68.820095' > delay='5' 2024-07-31 23:31:12.411 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J45ZVQCS9KN68X61XEDTAAKJ' 2024-07-31 23:31:12.412 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom: Ignoring 'off' → 'on' event for 'light.dans_bedroom_3' with context.id='01J45ZVQCS9KN68X61XEDTAAKJ' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False 2024-07-31 23:31:12.412 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.dans_bedroom_3' as manually controlled. 2024-07-31 23:31:12.418 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.dans_bedroom_2' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['None', 'candle', 'fire', 'prism', 'sparkle', 'opal', 'glisten', 'sunrise', 'unknown'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'effect': 'None', 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 83, 'color_temp_kelvin': 2000, 'color_temp': 500, 'hs_color': (30.601, 94.547), 'rgb_color': (255, 136, 13), 'xy_color': (0.599, 0.382), 'mode': 'normal', 'dynamics': 'none', 'icon': 'hue:bulb-sultan', 'friendly_name': 'Dan’s Bedroom 2', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01J45ZVQCZXF4WM1AE2CBX3PM5' 2024-07-31 23:31:12.419 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.dans_bedroom_2' with context.id='01J45ZVQCZXF4WM1AE2CBX3PM5' 2024-07-31 23:31:12.419 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J45ZVQCZXF4WM1AE2CBX3PM5' 2024-07-31 23:31:12.419 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: delta_time='68.823957' > delay='5' 2024-07-31 23:31:12.420 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J45ZVQCZXF4WM1AE2CBX3PM5' 2024-07-31 23:31:12.420 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom: Ignoring 'off' → 'on' event for 'light.dans_bedroom_2' with context.id='01J45ZVQCZXF4WM1AE2CBX3PM5' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False 2024-07-31 23:31:12.420 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.dans_bedroom_2' as manually controlled. 2024-07-31 23:31:12.422 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.dans_bedroom_1' 'state_changed' event: '{'min_color_temp_kelvin': 2000, 'max_color_temp_kelvin': 6535, 'min_mireds': 153, 'max_mireds': 500, 'effect_list': ['None', 'candle', 'fire', 'prism', 'sparkle', 'opal', 'glisten', 'sunrise', 'unknown'], 'supported_color_modes': [<ColorMode.COLOR_TEMP: 'color_temp'>, <ColorMode.XY: 'xy'>], 'effect': 'None', 'color_mode': <ColorMode.COLOR_TEMP: 'color_temp'>, 'brightness': 83, 'color_temp_kelvin': 2000, 'color_temp': 500, 'hs_color': (30.601, 94.547), 'rgb_color': (255, 136, 13), 'xy_color': (0.599, 0.382), 'mode': 'normal', 'dynamics': 'none', 'icon': 'hue:bulb-sultan', 'friendly_name': 'Dan’s Bedroom 1', 'supported_features': <LightEntityFeature.EFFECT|FLASH|TRANSITION: 44>}' with context.id='01J45ZVQD69GEWGRPFDJ376EEN' 2024-07-31 23:31:12.423 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'off' → 'on' event for 'light.dans_bedroom_1' with context.id='01J45ZVQD69GEWGRPFDJ376EEN' 2024-07-31 23:31:12.423 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J45ZVQD69GEWGRPFDJ376EEN' 2024-07-31 23:31:12.423 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] just_turned_off: delta_time='68.82189' > delay='5' 2024-07-31 23:31:12.424 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] is_proactively_adapting_context='False', context_id='01J45ZVQD69GEWGRPFDJ376EEN' 2024-07-31 23:31:12.424 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Bedroom: Ignoring 'off' → 'on' event for 'light.dans_bedroom_1' with context.id='01J45ZVQD69GEWGRPFDJ376EEN' because 'light.turn_on' was not called by HA and 'detect_non_ha_changes' is False 2024-07-31 23:31:12.424 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking 'light.dans_bedroom_1' as manually controlled.I see these kind of messages in the logs when turning a group of hue lights on:
2024-07-23 22:06:15.903 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Living: Ignoring ‘off’ → ‘on’ event for ‘light.hue_color_spot_1_2’ with context.id=‘01J3GK6W4Q9PCFFQ7MPKK3W2E8’ because ‘light.turn_on’ was not called by HA and ‘detect_non_ha_changes’ is False 2024-07-23 22:06:15.903 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Marking ‘light.hue_color_spot_1_2’ as manually controlled.
I’m really surprised more people aren’t experiencing this. I don’t have anything custom in my setup and philips hue (and using light groups) is pretty standard for HA.
I’m getting the exact same thing, hue bridge and lights are being marked ‘manual control’ on turn on. Turning off/on the light is supposed to reset it but doesn’t. Seems to be something that broke during an HA core update…
My current workaround is that each time after issuing a service call lights.turn_on, i must then set manual control to FALSE to get things to work as they used to. It’s really onerous and can obviously only work if lights are turned on via some automation/service call. I’m not sure how this bug happened, perhaps it’s something to do with a recent HA core update but either way it’s making things rough to use 😦.