Skip to content

Add documentation on triggers yaml#2884

Merged
abmantis merged 7 commits into
home-assistant:masterfrom
joostlek:trigger
Jun 30, 2026
Merged

Add documentation on triggers yaml#2884
abmantis merged 7 commits into
home-assistant:masterfrom
joostlek:trigger

Conversation

@joostlek

@joostlek joostlek commented Dec 2, 2025

Copy link
Copy Markdown
Member

Proposed change

Add documentation on triggers yaml

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features for which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Remove stale or deprecated documentation

Checklist

  • I have read and followed the documentation guidelines.
  • I have verified that my changes render correctly in the documentation.

Additional information

  • This PR fixes or closes issue: fixes #
  • Link to relevant existing code or pull request:

Summary by CodeRabbit

  • Documentation
    • Reworked the Trigger class example to replace the prior generic EventTrigger with a concrete OccupancyClearedTrigger.
    • Updated the trigger attachment example to show registering an occupancy-cleared callback and emitting a behavior-specific action payload (including entity_id and an occupancy-cleared description).
    • Refreshed the “Trigger description” section with updated trigger registrations and YAML showing an occupancy_cleared trigger targeting a presence binary sensor, including the relevant selector configuration.

Comment thread docs/automations.md Outdated
Comment thread docs/automations.md Outdated
Comment thread docs/automations.md Outdated
@joostlek joostlek marked this pull request as ready for review June 23, 2026 17:15
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updates docs/automations.md to replace the event-based trigger example with an occupancy-cleared trigger example, including the trigger class, runner callback, trigger registration, and YAML description.

Changes

Automation trigger documentation

Layer / File(s) Summary
Trigger class and schema
docs/automations.md
EventTrigger is replaced by OccupancyClearedTrigger, and the example config schema now requires CONF_TARGET instead of the previous event-options shape.
Runner callback
docs/automations.md
The attached runner example replaces the generic event callback with an occupancy-cleared callback that builds a payload from entity_id and registers it with the occupancy-cleared listener placeholder.
Trigger registration and description
docs/automations.md
async_get_triggers returns occupancy_cleared for OccupancyClearedTrigger, and the YAML snippet documents an occupancy-cleared trigger targeting a binary sensor with device_class: presence.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested reviewers

  • frenck
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding trigger YAML documentation.
Description check ✅ Passed The description follows the template and covers the main change, though the checklist and additional information fields are left incomplete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot 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.

♻️ Duplicate comments (1)
docs/automations.md (1)

99-100: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Broaden the usage note.

triggers.yaml descriptions are also consumed by the core get_triggers_for_target websocket API, so this sentence is too narrow. Update it to mention both frontend and backend consumers. As per path instructions, keep Markdown guidance direct and authoritative.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/automations.md` around lines 99 - 100, The current description of
triggers.yaml only mentions frontend usage as an example, but the core
get_triggers_for_target websocket API also consumes these descriptions from the
backend. Expand the usage note to mention both frontend and backend consumers of
the triggers.yaml file, specifically including reference to the
get_triggers_for_target websocket API. Keep the language direct and
authoritative as per Markdown documentation standards.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docs/automations.md`:
- Around line 99-100: The current description of triggers.yaml only mentions
frontend usage as an example, but the core get_triggers_for_target websocket API
also consumes these descriptions from the backend. Expand the usage note to
mention both frontend and backend consumers of the triggers.yaml file,
specifically including reference to the get_triggers_for_target websocket API.
Keep the language direct and authoritative as per Markdown documentation
standards.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2573572d-fca1-4ae2-a170-77a822cf1bfb

📥 Commits

Reviewing files that changed from the base of the PR and between 2d91792 and 0a04d7c.

📒 Files selected for processing (1)
  • docs/automations.md

@abmantis abmantis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As you pointed out in #2884 (comment) we should make the python code and the yaml description match, otherwise it becomes confusing for a new contributor to follow.

Comment thread docs/automations.md Outdated
Comment thread docs/automations.md Outdated
Comment thread docs/automations.md Outdated
@home-assistant home-assistant Bot marked this pull request as draft June 23, 2026 21:44
@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@joostlek joostlek marked this pull request as ready for review June 23, 2026 21:56
@home-assistant home-assistant Bot requested a review from abmantis June 23, 2026 21:57

@abmantis abmantis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we should add docs in the future for the new trigger helpers (that handle target + behavior), maybe keep behavior out of this one? Currently it has behavior but not using the standard selector.
You can check the todo integration for an example of a trigger that extends the base Trigger class directly and does not have behavior (but has target).

Comment thread docs/automations.md Outdated
Comment thread docs/automations.md Outdated
Comment thread docs/automations.md Outdated
@home-assistant home-assistant Bot marked this pull request as draft June 24, 2026 16:43
@joostlek joostlek marked this pull request as ready for review June 29, 2026 13:55
@home-assistant home-assistant Bot requested a review from abmantis June 29, 2026 13:55

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/automations.md`:
- Line 96: The `triggers.yaml` usage description under the automations docs is
too narrow and only mentions the frontend; update the wording to reflect that
trigger descriptions are also consumed by core APIs. Edit the sentence in the
automations documentation so it explicitly references both the frontend and core
API usage, and include `get_triggers_for_target` as the example symbol to make
the scope clear.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26220623-5c41-4f1c-bafb-19b30f4ba558

📥 Commits

Reviewing files that changed from the base of the PR and between 6e71e65 and 4ac785d.

📒 Files selected for processing (1)
  • docs/automations.md

Comment thread docs/automations.md

### Trigger description

Triggers should have their description in a `triggers.yaml` file. The description specifies the structure of the triggers and is used by the frontend, for example.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update triggers.yaml usage description to include core API, not just frontend.

Past review feedback noted that triggers.yaml descriptions are also used in core via the get_triggers_for_target websocket API, not only the frontend. The current text "and is used by the frontend, for example" understates the usage. Consider: "The description specifies the structure of the triggers and is used by the frontend and core APIs, such as get_triggers_for_target."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/automations.md` at line 96, The `triggers.yaml` usage description under
the automations docs is too narrow and only mentions the frontend; update the
wording to reflect that trigger descriptions are also consumed by core APIs.
Edit the sentence in the automations documentation so it explicitly references
both the frontend and core API usage, and include `get_triggers_for_target` as
the example symbol to make the scope clear.

@abmantis abmantis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@abmantis abmantis merged commit d486f71 into home-assistant:master Jun 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants