-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Check aliases in get_by_name functions for areas/floors #118995
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
return area | ||
|
||
# Check aliases | ||
normalized_name = normalize_name(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.
This is not using an index and will be very inefficient. Shouldn't we add a secondary alias index so we can call areas.get_by_alias(name)
?
@@ -197,8 +197,19 @@ def async_get_area(self, area_id: str) -> AreaEntry | None: | |||
|
|||
@callback | |||
def async_get_area_by_name(self, name: str) -> AreaEntry | None: |
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.
This should be added as a a new function so we don't have unintended side effects.
We should then update template method to call it. Probably also update suggested_area processing in device registry to use it.
I've marked this PR, as changes are requested that need to be processed. Thanks! 👍 ../Frenck |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Proposed change
The
async_get_area_by_name
andasync_get_floor_by_name
functions on their respective registries do not currently check for aliases. Because of this, working with area/floor aliases in templates is not possible (thearea_id
andfloor_id
template functions useget_*_by_name
).This PR extends the two
get_*_by_name
functions to also check aliases. Thenormalize_name
function fromnormalized_name_base_registry
is reused.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
..coveragerc
.To help with the load of incoming pull requests: