Extract triggers/conditions/services for non-primary entities#169319
Closed
abmantis wants to merge 387 commits intonon_primary_entity_conditions2from
Closed
Extract triggers/conditions/services for non-primary entities#169319abmantis wants to merge 387 commits intonon_primary_entity_conditions2from
abmantis wants to merge 387 commits intonon_primary_entity_conditions2from
Conversation
…68756) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…#168209) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
…IMAP connection was lost (#168662) Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: RaHehl <rahehl@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Franck Nijhof <git@frenck.dev>
…NS (#169240) Co-authored-by: Claude Code <claude@anthropic.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
…169326) Co-authored-by: Andrej Walilko <awalilko@liquidweb.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Comment on lines
+133
to
+136
| if check_entity_category and self.primary_entities_only: | ||
| entry = er.async_get(hass).async_get(entity_id) | ||
| if entry is None or entry.entity_category is not None: | ||
| return False |
There was a problem hiding this comment.
Cache entity registry lookups per entity (or precompute a set of non-primary entity_ids) before iterating components to avoid doing an entity registry lookup for every component filter check, which can become expensive for large targets and many component descriptions.
Comment on lines
250
to
279
| @@ -253,7 +271,11 @@ def _async_get_automation_components_for_target( | |||
| if component_data.component in matched_components: | |||
| continue | |||
| if component_data.matches( | |||
| hass, entity_id, entity_domain, entity_integration | |||
| hass, | |||
| entity_id, | |||
| entity_domain, | |||
| entity_integration, | |||
| check_entity_category, | |||
| ): | |||
There was a problem hiding this comment.
Apply the entity_category filter only to indirectly expanded entities (e.g., when entity_id is in extracted.indirectly_referenced) instead of enabling it globally whenever any indirect entity exists, to avoid changing behavior for explicitly targeted entities in mixed targets (and to avoid excluding non-registry entities when combined with area/device/label targets).
…components_diag_entities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Make get_triggers_for_target/get_conditions_for_target/get_services_for_target expose triggers/conditions/services with
primary_entities_only=Falsewhen there are matching non-primary entities.This keeps the existing behavior for when there are no indirect targets: all triggers/conditions/services are returned, regardless of the flag.
Implements #168101.
Depends on #169291.
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: