-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Fix invalid unique id for Transmission entities #84664
Fix invalid unique id for Transmission entities #84664
Conversation
Hey there @engrbm87, @JPHutchins, 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.
Few suggestions for the migration test. Also let's add type hints for new code.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Coverage issue is now gone! Thank you @epenet |
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.
One more little tweak, to account for @engrbm87 comment regarding cases that can't happen, and then I think it's good.
I had those cases as an attempt to improve code coverage. They are not relevant now so will remove. |
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.
LGTM 👍
It would be nice to have confirmation from a code owner
@engrbm87, @JPHutchins, any thoughts on this? |
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.
The unique_id cleanup is fine as such, but we should not add deprecated composing of names.
Background in https://developers.home-assistant.io/docs/core/entity#has_entity_name-true-mandatory-for-new-integrations
self._client_name = client_name | ||
self._name = sensor_name | ||
self._sub_type = sub_type | ||
self._attr_name = f"{client_name} {sensor_name}" |
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.
Please don't add this unwanted composing of name with device name.
Instead, leave it as is and in another PR set _attr_has_entity_name = True
to have the name composing happen automatically in frontend.
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.
I'm not adding name composing, I'm keeping existing functionality just moving it from function to attribute.
I've been explicitly asked to avoid doing too many things in one PR so this one is focused on unique_id. Once it's merged I'll be happy to migrate to new entity naming.
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.
You're right, sorry about that!
A PR setting _attr_has_entity_name = True
would still be welcome 👍
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.
Thanks, @avee87 👍
Proposed change
Currently it's using host and entity name for unique id which is not acceptable. Changing to config entry id + key.
Follow up PR will enable new entity naming and use entity descriptions - I don't want to do all this in one PR because it would do too many things at once and get stuck. See #74438 which I'm splitting into smaller parts now.
Type of change
Additional information
Checklist
black --fast 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
..coveragerc
.To help with the load of incoming pull requests: