-
-
Notifications
You must be signed in to change notification settings - Fork 36.5k
Add raw_value to HomeConnect select #157332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Add raw_value to HomeConnect select #157332
Conversation
|
Hey there @DavidMStraub, @Diegorro98, @MartinHjelmare, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this 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 raw_value attribute to the HomeConnect program select entity that exposes the raw API program value. This enables users to detect programs that aren't user-selectable (like rinsing, self-clean, or favorites) for automation purposes, while maintaining backward compatibility with existing functionality.
Key Changes
- Modified
update_native_value()to store the raw API program value inextra_state_attributes - Added error handling for invalid program keys using try-except around
ProgramKeyconversion - Updated test to verify
raw_valueattribute is present in entity state
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| homeassistant/components/home_connect/select.py | Added raw_value to extra state attributes and wrapped ProgramKey conversion in try-except to handle non-selectable programs |
| tests/components/home_connect/test_select.py | Enhanced test to verify raw_value attribute is correctly set in entity state |
|
We already explored exactly the same feature a while ago at #131874, but after some discussion we decided to discard it. The programs can be easily added to aiohomeconnect, then they will appear in the entities state so the user can check the value in the automations. See for example #157174 The drawback (or the advantage) of this way to work is that the users need to report the program keys or even contribute them directly. |
|
@Diegorro98 Yes, I get this. But when the programs are added to the programs in aiohomeconnect they would appear in the select, and the user could select them. In case of programs like "rinse on startup" (coffee maker) this does not make any sense, because this cannot be set by the user. There are also a bunch of programs that are not available by the API (e.g. maximum efficiency on my dishwasher), so even they would make sense to include, the API would return an error when someone tries to set it using the API. |
|
Marking as draft until the discussion is settled. |
|
Maybe the solution is not about adding an attribute, maybe we should allow those programs to be present on the entity and improve the error handling to ensure that the user understands that the error is not related to Home Assistant, is because the API doesn't allow using that program. Also we could add the information to the documentation to be clear that some programs are not selectable so that unnecessary issues aren't created, |
|
In my opinion the select has the intention to present the user options to select from. And adding options there (and there will be a bunch of them), that will knowingly cause an error when they are selected, does not sound right to me. But in any case, another reason to keep the raw value in there: Due to the fully qualified dot notation, that the API is using (e.g. |
|
Apart from my opinion, I don't know if either adding programs that might not work which can be selected or adding an extra attribute with the original key, which maybe for basic users that would like to do an automation based on their favorite program selection is difficult or not very intuitive, meet the Home Assistant quality standards. |
|
So this means, in result: We are hiding some information that is delivered by the API, but as it could be not intuitive for some users, we do not allow anybody to receive this info at all? |
|
I think you are misunderstanding me, I was just exposing the options that we have. Now that I have more time than yesterday, let me do a bullet-point list about this:
Based on these points, I wouldn't add this extra attribute. But I invite anyone (and specially to @boergegrunicke) to contribute to this bullet-point list in order to have it as complete as possible to make a decision. Also, @MartinHjelmare, what's your opinion about this topic? |
|
I don't think adding an attribute would be acceptable. We don't need to know the main state of the select entity to understand the attribute value. A separate sensor that is disabled by default could be acceptable. |
Proposed change
This adds the
raw_valueto the program select, which is basically the raw value that was received from the API. This is relevant, because the API reports back some programs that are not selectable from the user (rinsing, self-clean, favorites). But these programs might be still relevant for automations. (The user might want to trigger something when a favorite program starts, but posibly not while the device is self-cleaning itself).Having this as an attribute in the select, does not break anything for existing users, does not bother "normal" users, but enables users that are interested in it, to read the data and enhance automations.
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: