Skip to content

Add OpenRGB profile select entity#154732

Merged
joostlek merged 21 commits intohome-assistant:devfrom
felipecrs:openrgb-profiles
Dec 29, 2025
Merged

Add OpenRGB profile select entity#154732
joostlek merged 21 commits intohome-assistant:devfrom
felipecrs:openrgb-profiles

Conversation

@felipecrs
Copy link
Copy Markdown
Contributor

@felipecrs felipecrs commented Oct 18, 2025

Proposed change

This adds a select entity for selecting/applying a profile in OpenRGB. Here's how it works:

  • The profiles you create in the OpenRGB application will be shown in the select entity.
  • There is currently no way to retrieve the active profile (maybe in the future). For now, when a profile is selected, Home Assistant will assume it to be the active one and will revert the select entity state to Unknown as soon as any state change occurs (such as a change in LED color or mode) after the profile is applied.

A little demo:

chrome_vy7QEc28QP.mp4

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 link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

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 adds a select entity to the OpenRGB integration that allows users to select and apply OpenRGB profiles. The select entity dynamically updates its options based on available profiles and becomes unavailable when no profiles exist.

  • Adds a new select platform with profile selection functionality
  • Includes comprehensive test coverage for various scenarios including error handling
  • Updates the main integration to include the select platform

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/components/openrgb/test_select.py Comprehensive test suite covering entity setup, profile selection, error handling, and dynamic updates
tests/components/openrgb/snapshots/test_select.ambr Snapshot test data for entity state validation
tests/components/openrgb/conftest.py Adds profiles list and load_profile method to mock OpenRGB client
homeassistant/components/openrgb/strings.json Translation strings for the profile select entity and error messages
homeassistant/components/openrgb/select.py Implementation of the OpenRGB profile select entity
homeassistant/components/openrgb/init.py Adds SELECT platform to the list of supported platforms

frenck
frenck previously requested changes Oct 18, 2025
Comment thread homeassistant/components/openrgb/select.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft October 18, 2025 07:22
@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Comment thread homeassistant/components/openrgb/select.py Outdated
@felipecrs felipecrs marked this pull request as ready for review October 18, 2025 16:19
@home-assistant home-assistant Bot requested a review from frenck October 18, 2025 16:19
@felipecrs felipecrs requested a review from tr4nt0r October 18, 2025 16:19
Comment thread homeassistant/components/openrgb/select.py Outdated
@felipecrs felipecrs requested a review from tr4nt0r October 18, 2025 17:15
@tr4nt0r
Copy link
Copy Markdown
Contributor

tr4nt0r commented Oct 24, 2025

Usually the is no need to constantly merge the dev branch, unless there is a conflict due to changes from another PR

@felipecrs
Copy link
Copy Markdown
Contributor Author

felipecrs commented Oct 24, 2025

The last one was because of #155095.

But you're right. I should do it less often.

The contributor guide suggests rebasing after a week of inactivity.

Comment on lines +75 to +82
self._state_hash = self._compute_state_hash()
# Only check for state changes if we have a current option to potentially clear
elif self._attr_current_option is not None:
current_hash = self._compute_state_hash()
# If state changed, we can no longer assume current profile
if current_hash != self._state_hash:
self._attr_current_option = None
self._state_hash = None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need the hash? Can't we check based on name?

Copy link
Copy Markdown
Contributor Author

@felipecrs felipecrs Oct 26, 2025

Choose a reason for hiding this comment

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

Which name?

OpenRGB SDK does not expose data of the current profile. I crafted this method so that I can at least determine whether the applied profile is still active.

Please read this discussion for a better context.

Copy link
Copy Markdown
Contributor Author

@felipecrs felipecrs Nov 7, 2025

Choose a reason for hiding this comment

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

I improved the hash function a little bit by reusing @jath03's idea.

Also, this will be simplified in future. The author of OpenRGB accepted the suggestion of tracking this within OpenRGB itself.

@felipecrs felipecrs requested a review from joostlek October 29, 2025 18:41
@felipecrs felipecrs marked this pull request as draft November 11, 2025 15:56
@felipecrs felipecrs marked this pull request as ready for review November 12, 2025 00:09
@felipecrs
Copy link
Copy Markdown
Contributor Author

Can someone please help me understand what's wrong with the coverage?

image image

Comment thread homeassistant/components/openrgb/__init__.py
@home-assistant home-assistant Bot marked this pull request as draft December 2, 2025 18:34
@felipecrs felipecrs marked this pull request as ready for review December 3, 2025 23:39
@home-assistant home-assistant Bot requested a review from joostlek December 3, 2025 23:39
@joostlek joostlek dismissed frenck’s stale review December 29, 2025 16:42

Different approach taken

@joostlek joostlek merged commit 585c2dc into home-assistant:dev Dec 29, 2025
36 checks passed
@felipecrs felipecrs deleted the openrgb-profiles branch December 29, 2025 18:08
@felipecrs
Copy link
Copy Markdown
Contributor Author

Thanks a lot, @joostlek!

@github-actions github-actions Bot locked and limited conversation to collaborators Dec 30, 2025
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