Remove legacy fallback in light color_mode property#162276
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
c71de77 to
b950b69
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the legacy fallback behavior in the light component's color_mode property. Previously, when color_mode was None, the code would log a warning and attempt to guess the appropriate color mode based on supported color modes and available state attributes. Now, the system simply reports ColorMode.UNKNOWN when a light is on but doesn't report a color mode.
Changes:
- Removed the
_light_internal_color_modeproperty that implemented the legacy fallback logic with automatic color mode detection - Simplified
state_attributesto directly setcolor_modetoColorMode.UNKNOWNwhen the light is on andcolor_modereturnsNone - Removed the test for the deprecated warning behavior that is no longer applicable
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| homeassistant/components/light/init.py | Removed _light_internal_color_mode property and replaced its usage with a simple conditional that sets color_mode to ColorMode.UNKNOWN when light is on and color_mode is None |
| tests/components/light/test_init.py | Removed test test_report_no_color_mode that was testing the deprecated warning and fallback behavior |
Comments suppressed due to low confidence (1)
tests/components/light/test_init.py:2386
- The removed test tested the legacy fallback behavior when color_mode is None. With the new implementation, when a light is on and color_mode returns None, the state_attributes property should set color_mode to ColorMode.UNKNOWN. Consider adding a test to verify this new behavior works correctly. The test should create a MockLightEntity with _attr_color_mode = None and _attr_is_on = True, then verify that the resulting state attributes include color_mode set to ColorMode.UNKNOWN.
(light.ColorMode.ONOFF, {light.ColorMode.ONOFF}, False),
|
Perhaps we shoud add tests to ensure this is covered? |
d760070 to
af4aa44
Compare
|
With a forced failure (see #162580) we don't have any test failure |
Breaking change
Not user-facing
Proposed change
Reporting
color_modeasNonewould previously log a warning and attempt to guess the color mode from the supported colors modes.This is no longer supported.
Needs:
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: