Skip to content

Remove legacy fallback in light color_mode property#162276

Merged
epenet merged 5 commits into
devfrom
epenet/20260205-1044
Feb 9, 2026
Merged

Remove legacy fallback in light color_mode property#162276
epenet merged 5 commits into
devfrom
epenet/20260205-1044

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Feb 5, 2026

Breaking change

Not user-facing

Proposed change

Reporting color_mode as None would 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

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings February 5, 2026 09:51
@epenet epenet requested a review from a team as a code owner February 5, 2026 09:51
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented Feb 5, 2026

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (light) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of light can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign light Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

@epenet epenet force-pushed the epenet/20260205-1044 branch 2 times, most recently from c71de77 to b950b69 Compare February 5, 2026 10:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_mode property that implemented the legacy fallback logic with automatic color mode detection
  • Simplified state_attributes to directly set color_mode to ColorMode.UNKNOWN when the light is on and color_mode returns None
  • 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),

@jbouwh
Copy link
Copy Markdown
Contributor

jbouwh commented Feb 5, 2026

Perhaps we shoud add tests to ensure this is covered?

@epenet epenet force-pushed the epenet/20260205-1044 branch from d760070 to af4aa44 Compare February 5, 2026 20:05
@epenet epenet marked this pull request as ready for review February 7, 2026 12:18
Copy link
Copy Markdown
Contributor

@davet2001 davet2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@epenet
Copy link
Copy Markdown
Contributor Author

epenet commented Feb 8, 2026

With a forced failure (see #162580) we don't have any test failure
I think this is safe to merge

Copy link
Copy Markdown
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @epenet 👍

@epenet epenet merged commit 5c5f5d0 into dev Feb 9, 2026
46 checks passed
@epenet epenet deleted the epenet/20260205-1044 branch February 9, 2026 06:54
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants