Skip to content

Raise on missing color mode#162715

Merged
epenet merged 7 commits into
devfrom
epenet/20260210-1256
Feb 11, 2026
Merged

Raise on missing color mode#162715
epenet merged 7 commits into
devfrom
epenet/20260210-1256

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Feb 10, 2026

Proposed change

Partial reversal of #162276

As spotted in #162650, changing the default for _attr_color_mode is an unintended breaking change for "did I already initialise the color mode"

Instead of defaulting to UNKNOWN we raise an exception if the color_mode is not set

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @felipecrs, mind taking a look at this pull request as it has been labeled with an integration (openrgb) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of openrgb 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 openrgb 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.

@home-assistant
Copy link
Copy Markdown
Contributor

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.

@felipecrs
Copy link
Copy Markdown
Contributor

@epenet is the OpenRGB integration your only concern?

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 rolls back part of #162276 by restoring the ability for LightEntity.color_mode / _attr_color_mode to be None, to avoid an unintended breaking change in default light behavior (as discussed in #162650).

Changes:

  • Make LightEntity._attr_color_mode optional again and update LightEntity.color_mode return type accordingly.
  • Adjust OpenRGB light attribute update logic to use None as the “unknown/unset” sentinel instead of ColorMode.UNKNOWN.
  • Update the pylint type-hint enforcement plugin to allow LightEntity.color_mode to return None.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pylint/plugins/hass_enforce_type_hints.py Updates type-hint enforcement rules to allow LightEntity.color_mode to be optional.
homeassistant/components/openrgb/light.py Aligns OpenRGB’s internal color mode calculation with the restored None default/semantics.
homeassistant/components/light/__init__.py Restores None as the default/allowed value for _attr_color_mode and color_mode.

Comment thread homeassistant/components/light/__init__.py
@epenet
Copy link
Copy Markdown
Contributor Author

epenet commented Feb 10, 2026

@epenet is the OpenRGB integration your only concern?

I am not sure.

As I have been cleaning up the deprecate features of the light platform, all other failing tests were "intended" (they raised warnings before, and now they fail).

However the openrgb was affected in a way that was not intended (working without warning => not working).
It was an easy fix, but we don't know how many custom integrations could be affected in a similar way.

@emontnemery
Copy link
Copy Markdown
Contributor

As discussed yesterday, I think all light.py need to be reviewed to see if there are more cases than openrgb

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.

I don't think this is a good change, before #162276 the light's color mode would be deduced by its attributes (brightness, color, and so on) and thus not be None. Now, the color mode will be None as I understand it?

Also, tests should be updated.

@emontnemery emontnemery marked this pull request as draft February 10, 2026 12:37
@epenet epenet changed the title Restore light default color_mode Raise on missing color mode Feb 10, 2026
@epenet epenet marked this pull request as ready for review February 10, 2026 13:58
@epenet epenet requested review from bdraco and jbouwh as code owners February 10, 2026 13:58
@epenet
Copy link
Copy Markdown
Contributor Author

epenet commented Feb 10, 2026

I don't think this is a good change, before #162276 the light's color mode would be deduced by its attributes (brightness, color, and so on) and thus not be None. Now, the color mode will be None as I understand it?

Also, tests should be updated.

As discussed on Discord, I have adjusted this to raise an error if the color_mode is still None, and added some tests accordingly.

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.

LGTM, thanks @epenet 👍

@epenet epenet merged commit eab80f7 into dev Feb 11, 2026
46 checks passed
@epenet epenet deleted the epenet/20260210-1256 branch February 11, 2026 10:12
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 12, 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.

4 participants