Skip to content

Inspect plural automation config sections - #1319

Merged
frenck merged 1 commit into
mainfrom
fix/automation-plural-config
Jun 23, 2026
Merged

frenck merged 1 commit into
mainfrom
fix/automation-plural-config

Conversation

@frenckatron

Copy link
Copy Markdown
Collaborator

Description

Spook now inspects both the legacy singular automation config sections and the modern plural sections when extracting entity references:

  • trigger and triggers
  • condition and conditions
  • action and actions

The event-trigger cleanup that ignores event bus topics also checks both trigger and triggers.

Motivation and Context

Fixes #1162.

Home Assistant's current automation editor can store automations with plural section keys. Spook only looked at the singular keys in the raw config fallback, so a missing entity in conditions could be missed even when the editor itself showed it as unknown.

How has this been tested?

  • uv run pytest tests/ectoplasms/automation/repairs/test_unknown_entity_references.py::test_automation_full_config_with_plural_keys tests/ectoplasms/automation/repairs/test_unknown_entity_references.py::test_plural_condition_entity_is_reported_unknown -q
  • uv run pytest tests/ectoplasms/automation/repairs/test_unknown_entity_references.py -q
  • uv run ruff format --check custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py tests/ectoplasms/automation/repairs/test_unknown_entity_references.py
  • uv run ruff check --output-format=github custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py tests/ectoplasms/automation/repairs/test_unknown_entity_references.py
  • uv run --with pre-commit pre-commit run pylint --files custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py tests/ectoplasms/automation/repairs/test_unknown_entity_references.py

Screenshots (if appropriate):

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@frenckatron frenckatron added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 472b833c-b0d7-4a0f-b8a6-8218bdcf3d02

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba83e7 and d9d37e5.

📒 Files selected for processing (2)
  • custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py
  • tests/ectoplasms/automation/repairs/test_unknown_entity_references.py

📝 Walkthrough

Walkthrough

The automation entity extractor is updated to iterate over both singular and plural configuration keys (trigger/triggers, condition/conditions, action/actions). The unknown-reference computation is similarly extended to strip event types from both trigger and triggers. Two new tests cover these plural-key paths.

Changes

Plural automation section key support

Layer / File(s) Summary
Plural key handling in extraction and unknown-reference computation
custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py
extract_entities_from_automation_config now loops over ("trigger", "triggers"), ("condition", "conditions"), ("action", "actions") tuples instead of checking only singular keys. _async_compute_unknown_references removes event types for both trigger and triggers keys from entity.raw_config.
Tests for plural-key extraction and unknown-reference reporting
tests/ectoplasms/automation/repairs/test_unknown_entity_references.py
Adds a golden-path test asserting entities are extracted from all three plural-key sections, and a targeted test asserting _async_compute_unknown_references returns the unknown entity from a plural conditions section.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • frenck/spook#977: Introduced the enhanced automation entity-extraction flow that parses trigger/condition/action configuration, which this PR extends to handle plural keys.
  • frenck/spook#1275: Added golden-path tests for extract_entities_from_automation_config, which this PR extends with plural-key test cases.
  • frenck/spook#1312: Modified the same unknown_entity_references.py file to strip event types from trigger configuration, directly related to the triggers plural extension here.

Suggested reviewers

  • frenck

Poem

🐇 Hop, hop, singular or plural,
Triggers, conditions, actions too —
Whether one key or a mural,
Spook will find each entity clue!
No missing input_boolean escapes,
The ghost repairs all plural shapes. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Inspect plural automation config sections' accurately describes the main change: adding support for plural configuration keys alongside singular ones.
Description check ✅ Passed The description clearly explains the changes, motivation, testing approach, and links to the relevant issue #1162, providing context for why plural sections needed support.
Linked Issues check ✅ Passed The PR directly addresses issue #1162 by implementing detection of missing entities in plural automation config sections, which the Home Assistant editor displays as unknown.
Out of Scope Changes check ✅ Passed All changes are directly related to supporting both singular and plural automation configuration keys as required by issue #1162, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/automation-plural-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates Spook’s automation unknown-entity detection to correctly inspect Home Assistant’s modern plural automation config sections (e.g., triggers, conditions, actions) in addition to the legacy singular keys, ensuring missing entities aren’t silently missed when raw config uses the new structure (Fixes #1162).

Changes:

  • Extend entity extraction to scan both singular and plural automation section keys: trigger/triggers, condition/conditions, action/actions.
  • Extend the event-trigger cleanup (that excludes event bus topics) to consider both trigger and triggers.
  • Add tests covering plural-key configs and verifying unknown entities in conditions are reported.

Reviewed changes

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

File Description
custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py Scan both singular/plural automation sections for entity extraction; apply event-type cleanup for both trigger and triggers.
tests/ectoplasms/automation/repairs/test_unknown_entity_references.py Add regression tests for plural-key automation configs and unknown-entity reporting from plural conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@frenck
frenck merged commit b63cb1e into main Jun 23, 2026
21 checks passed
@frenck
frenck deleted the fix/automation-plural-config branch June 23, 2026 08:33
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

input_boolean not reported as missing 2026.1

3 participants