Skip to content

Conversation

@joostlek
Copy link
Member

@joostlek joostlek commented Dec 2, 2025

Proposed change

Add documentation on conditions

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
    • Added a comprehensive Conditions section with implementation guidance, practical examples, registration patterns, schema validation, and frontend integration instructions.
    • Refined trigger documentation wording for improved clarity.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

📝 Walkthrough

Walkthrough

Documentation-only update to docs/automations.md that revises trigger wording and adds a new "Conditions" section with examples and guidance for implementing, validating, registering, and integrating condition classes and schemas.

Changes

Cohort / File(s) Change Summary
Documentation
docs/automations.md
Added a new "Conditions" section including: example Condition class with async_validate_config and async_get_checker, async_get_conditions registration example, a Voluptuous-based condition schema, DoorStateConditionBase illustrating state checks, and frontend conditions.yaml-style integration snippet. Also updated trigger wording from "the example above" to "the following example."

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Documentation-only changes; no runtime code modified
  • Review focus: clarity and accuracy of examples and YAML snippets
  • Files to spot-check:
    • docs/automations.md (examples, code blocks, schema correctness)

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description follows the required template structure and includes the 'Proposed change' and 'Type of change' sections with appropriate selection, but the checklist items are unchecked and the 'Additional information' section lacks the required linked pull request. Complete the checklist items by confirming documentation guidelines were followed and changes render correctly. Link the related pull request in the 'Additional information' section to provide full context.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add documentation on conditions' clearly and specifically describes the main change—adding documentation for a conditions feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
docs/automations.md (2)

168-172: Strengthen instructional phrasing by fronting the goal.

Line 170 uses passive voice and defers the goal. Restructure to front the action for clarity and directness, consistent with documentation guidelines.

Apply this diff to improve the instructional phrasing:

-To register the conditions `async_get_conditions` should be implemented in the `condition` platform for that integration.
+Implement `async_get_conditions` in the `condition` platform to register conditions.

181-187: Optional: Make schema explanation more direct.

While clear, line 183 could be more authoritative by fronting the goal rather than describing frontend behavior.

Apply this diff for a more direct tone:

-The frontend uses the `conditions.yaml` file to know the structure of the conditions.
-This file is similar to `triggers.yaml` and `services.yaml`.
+Define the condition structure in `conditions.yaml` for the frontend, similar to `triggers.yaml` and `services.yaml`.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 40fdc6a and 6e41ad9.

📒 Files selected for processing (1)
  • docs/automations.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)

⚙️ CodeRabbit configuration file

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.

  • Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • Use sentence-style capitalization also in headings.

do not comment on HTML used for icons

Avoid flagging inline HTML for embedding videos in future reviews for this repository.

Files:

  • docs/automations.md
🔇 Additional comments (3)
docs/automations.md (3)

88-88: Good phrasing adjustment.

The change from "example above" to "the following example" correctly describes the position of the code that immediately follows.


99-107: Clear and well-structured introduction to conditions.

The section frontloads the implementation goal and correctly references the trigger class pattern for consistency.


188-198: YAML example is well-structured and accurate.

The schema correctly represents the Python condition implementation and follows the expected structure for condition definitions.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

127-131: Voluptuous schema syntax is correct.

The vol.In() validator now correctly accepts a single iterable argument. This resolves the prior critical issue flagged in previous reviews.

🧹 Nitpick comments (1)
docs/automations.md (1)

168-171: Align condition registration wording with trigger registration for consistency.

The conditions section should use the same direct imperative style as the parallel triggers section. Currently, line 170 uses passive construction ("should be implemented") while the triggers section uses active voice ("Implement").

Apply this diff to match the triggers section pattern:

-To register the conditions `async_get_conditions` should be implemented in the `condition` platform for that integration.
+Implement `async_get_conditions` in the `condition` platform to register all the integration's conditions.

As per coding guidelines, documentation should use a direct and authoritative tone with frontloaded goals.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 6e41ad9 and 04a8901.

📒 Files selected for processing (1)
  • docs/automations.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)

⚙️ CodeRabbit configuration file

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.

  • Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • Use sentence-style capitalization also in headings.

do not comment on HTML used for icons

Avoid flagging inline HTML for embedding videos in future reviews for this repository.

Files:

  • docs/automations.md
🔇 Additional comments (2)
docs/automations.md (2)

111-166: Condition class example is well-structured.

The code implementation properly demonstrates the required methods (async_validate_config and async_get_checker), includes appropriate type hints, and provides clear comments explaining the logic. The schema definition is correct.


181-198: Condition schema documentation and example are clear.

The explanation of conditions.yaml and its relationship to related files provides helpful context. The YAML example correctly demonstrates the door_state condition schema structure with appropriate field definitions and selectors.


## Conditions

Conditions are checks that must be met in order for an automation to trigger. Implement them in the `condition` platform (`condition.py`) of your integration by creating and registering condition classes.
Copy link
Member

Choose a reason for hiding this comment

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

I would be more specific with the language here. The automation triggers when its trigger is triggered, then the automation checks any conditions, and if they are met or if there are no conditions, the automation action will be done.

@MartinHjelmare MartinHjelmare marked this pull request as draft December 7, 2025 10:38
self, hass: HomeAssistant, config: ConditionConfig
) -> None:
"""Initialize condition."""
self._hass = hass
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self._hass = hass
super().__init__(hass, config)

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.

3 participants