8000 Sort and update template documentation. by Petro31 · Pull Request #39548 · home-assistant/home-assistant.io · GitHub
[go: up one dir, main page]

Skip to content

Sort and update template documentation. #39548

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

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

Petro31
Copy link
Contributor
@Petro31 Petro31 commented Jun 14, 2025

Proposed change

Correct mistakes in the variable documentation.

  1. All modern template formats are now supported for state-based templates. No reason to list them individually anymore.
  2. Update variables description to let users know when variables are resolved.
  3. Sort overall platforms alphabetically
  4. Sort platform fields alphabetically

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • Adjusted missing or incorrect information in the current documentation (current branch).
  • Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • Removed stale or deprecated documentation.

Additional information

  • Link to parent pull request in the codebase:
  • Link to parent pull request in the Brands repository:
  • This PR fixes or closes issue: fixes #

Checklist

  • This PR uses the correct branch, based on one of the following:
    • I made a change to the existing documentation and used the current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • Documentation
    • Reorganized and clarified the configuration reference for template entities across all supported platforms.
    • Improved grouping, ordering, and completeness of configuration keys and descriptions.
    • Updated and expanded explanations for key fields, defaults, and schema structures.
    • Standardized and simplified section titles for easier navigation.

@Petro31 Petro31 requested a review from a team as a code owner June 14, 2025 11:37
@home-assistant home-assistant bot added the current This PR goes into the current branch label Jun 14, 2025
Copy link
netlify bot commented Jun 14, 2025

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit e94490a
🔍 Latest deploy log https://app.netlify.com/projects/home-assistant-docs/deploys/684d5ef80e4f850008a8cd70
😎 Deploy Preview https://deploy-preview-39548--home-assistant-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor
coderabbitai bot commented Jun 14, 2025
📝 Walkthrough

Walkthrough

The documentation for the template integration was reorganized and clarified, with extensive restructuring of configuration references for state-based and trigger-based template entities across all supported platforms. Schema keys were reordered, grouped, and consolidated, and descriptions were updated to improve clarity and standardization without altering any code-level entities.

Changes

File(s) Change Summary
source/_integrations/template.markdown Reorganized and clarified documentation for template integration; reordered and grouped configuration keys; consolidated and updated schema sections for all supported platforms; enhanced field descriptions and defaults.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Documentation
    User->>Documentation: Consults template integration reference
    Documentation-->>User: Presents reorganized, clarified schema for all template entity platforms
    User->>Documentation: Reviews configuration keys, descriptions, and defaults
    Documentation-->>User: Provides consolidated, logically grouped, and updated information
Loading

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. Fo 8000 r the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (4)
source/_integrations/template.markdown (4)

167-170: Consolidate common fields into one map
Introducing [all sensor, binary sensor, button, image, light, number, select, switch, weather entities] reduces duplication. Fields inside should remain alphabetically sorted for consistency.

Consider adding a brief note explaining this map covers all listed domains at once.


172-173: Tweak comma usage in availability description
Grammar nit: add a comma after “fails to render” to improve readability.

- If the template either fails to render or returns `True`
+ If the template either fails to render, or returns `True`
🧰 Tools
🪛 LanguageTool

[misspelling] ~173-~173: This word is normally spelled with a hyphen.
Context: ... Note that the string comparison is not case sensitive; "TrUe" and "yEs" are allowed. ...

(EN_COMPOUNDS_CASE_SENSITIVE)


277-277: Refine state description punctuation
Add final period to meet markdown-lint rules.

- ...depends on the sensor's device_class value
+ ...depends on the sensor's device_class value.
🧰 Tools
🪛 LanguageTool

[style] ~277-~277: In American English, abbreviations like “etc.” require a period.
Context: ...nd (Open/Closed, Detected/Clear etc) depends on the sensor's device_class v...

(ETC_PERIOD)


417-421: Add effect for lights
Default optimistic may surprise users; link to optimistic mode docs.

Add reference to “Optimistic mode” section.

📜 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 b8687fa and e94490a.

📒 Files selected for processing (1)
  • source/_integrations/template.markdown (16 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/template.markdown

[uncategorized] ~151-~151: Possible missing comma found.
Context: ...rs to update the entities. Optional. If omitted will update based on referenced entitie...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~159-~159: This expression is usually spelled with a hyphen.
Context: ...e configuration is loaded or reloaded. Trigger based template entities resolve variables bet...

(BASED_HYPHEN)


[misspelling] ~173-~173: This word is normally spelled with a hyphen.
Context: ... Note that the string comparison is not case sensitive; "TrUe" and "yEs" are allowed. ...

(EN_COMPOUNDS_CASE_SENSITIVE)


[uncategorized] ~190-~190: Possible missing comma found.
Context: ...with the unique ID of the configuration block if available. This allows changing the ...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~277-~277: In American English, abbreviations like “etc.” require a period.
Context: ...nd (Open/Closed, Detected/Clear etc) depends on the sensor's device_class v...

(ETC_PERIOD)


[uncategorized] ~311-~311: Possible missing comma found.
Context: ...pen). If the template produces a None value the current position will be set to `un...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~323-~323: Possible missing comma found.
Context: ...late. If the template produces a None value the state will be set to unknown. ...

(AI_HYDRA_LEO_MISSING_COMMA)


[grammar] ~609-~609: Is an article like ‘a’ or ‘an’ missing?
Context: ... describes when the state of the sensor was last reset. Must render to a valid `dat...

(BE_NN)

🪛 markdownlint-cli2 (0.17.2)
source/_integrations/template.markdown

264-264: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


264-264: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


268-268: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


268-268: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - home-assistant-docs
  • GitHub Check: Header rules - home-assistant-docs
  • GitHub Check: Pages changed - home-assistant-docs
🔇 Additional comments (77)
source/_integrations/template.markdown (77)

84-84: Simplify section title for clarity
The new header “State-based template (all platforms / domains)” concisely communicates that the configuration applies across all platforms, eliminating the need to enumerate them.


142-143: Move actions above other keys
Reordering to list actions first improves discoverability for trigger-based entities. Ensure this ordering is mirrored in UI schema docs.


150-151: Reorder triggers under configuration
Listing triggers immediately after conditions aligns with logical flow: define when then what.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~151-~151: Possible missing comma found.
Context: ...rs to update the entities. Optional. If omitted will update based on referenced entitie...

(AI_HYDRA_LEO_MISSING_COMMA)


159-159: Clarify variables resolution timing
The updated description clearly differentiates load-time resolution for state-based entities from runtime resolution for trigger-based ones.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~159-~159: This expression is usually spelled with a hyphen.
Context: ...e configuration is loaded or reloaded. Trigger based template entities resolve variables bet...

(BASED_HYPHEN)


176-176: Set default availability to true
Defaulting availability to true is consistent with other integrations.


177-179: Reorder icon field
Alphabetical ordering places icon before picture.


181-182: Add picture field
Correctly follows icon, enhancing entity customization.


184-185: Add name field
Alphabetical placement is accurate.


186-188: Specify type: template for name
Ensures template rendering is explicit.


189-190: Add unique_id field
Properly placed last in the common-fields map.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~190-~190: Possible missing comma found.
Context: ...with the unique ID of the configuration block if available. This allows changing the ...

(AI_HYDRA_LEO_MISSING_COMMA)


192-193: Define type: string for unique_id
Matches established schema conventions.


194-194: Consolidate attribute templates
Introducing [all binary_sensor, sensor, vacuum entities] map is DRY and logical.


199-199: Add attributes map
Allows multi-attribute templating in one block.


242-245: Add disarm action
Explicit disarm improves schema completeness.


246-249: Reposition state template
Moving state definition adjacent to actions enhances readability.


250-253: Add trigger action
Including a trigger callback is consistent with other template entities.


254-259: Switch binary_sensor schema to list
Changing to list syntax matches other multi-entity configs. Update examples accordingly.


259-262: Add auto_off key for binary sensors
Clarifies time-based auto-off behavior.


263-266: Introduce delay_off
Templated off-delay is a valuable addition.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

264-264: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


264-264: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


267-270: Introduce delay_on
Complements delay_off for symmetric behavior.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

268-268: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


268-268: Emphasis style
Expected: underscore; Actual: asterisk

(MD049, emphasis-style)


271-275: Add device_class with default
Default None is appropriate for optional device typing.


293-296: Reorder close_cover
Alpha ordering is correct; double–check inclusive requirement semantics.

Verify inclusive usage in core schema docs.


305-309: Add optimistic flag for covers
Optimistic mode consistency aids interactivity.


310-313: Introduce position template
Defines cover position. Ensure examples illustrate its use.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~311-~311: Possible missing comma found.
Context: ...pen). If the template produces a None value the current position will be set to `un...

(AI_HYDRA_LEO_MISSING_COMMA)


322-325: Reorder state template
Grouping state with position and tilt improves schema clarity.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~323-~323: Possible missing comma found.
Context: ...late. If the template produces a None value the state will be set to unknown. ...

(AI_HYDRA_LEO_MISSING_COMMA)


326-329: Add stop_cover action
Completes cover control actions set.


334-338: Add tilt_optimistic
Aligns cover tilt with optimistic interactivity.


344-347: Add oscillating template
Supports new fan oscillation state.


348-350: Add direction template
Allows forward/reverse fan control.


360-364: Convert preset_modes to list
Default empty list is clearer than a single string or list union.


386-397: Reorder fan state, turn_on, turn_off
Mandatory fields first, followed by optional presets, is logical.


422-426: Add effect_list for lights
Templates for supported effects is a useful extension.


437-441: Add min_mireds template
Defines min color temperature; ordering is alphabetical.


442-446: Add max_mireds template
Complements min_mireds.


462-465: Add set_effect action
Marks set_effect as inclusive with effect; ensure example YAML reflects inclusion.

Check sample configs for proper inclusive usage.


490-494: Reintroduce state with default
Default optimistic state fits interactive entity patterns.


495-499: Add supports_transition
Clarifies transition capability; default false is safe.


500-504: Add temperature template
Default optimistic may conflict with other defaults; verify its intent.

Confirm default for temperature is intended to be optimistic.


505-508: Reorder turn_on for lights
Placing mandatory actions next improves readability.


527-530: Add open action to locks
Extends lock control; verify core supports this verb.

Search for async_open in template lock implementation.


531-535: Introduce optimistic for locks
Optimistic mode is consistent.


536-539: Add state template for locks
Required state template aligns with other entities.


549-553: Reorder max for numbers
Alphabetical and logical; default 100.0 is reasonable.


554-558: Add min for numbers
Defines lower bound; default 0.0 is sensible.


559-563: Add optimistic for numbers
Matches pattern for interactive helpers.


564-567: Introduce set_value action
Essential for number controls; marked required correctly.


568-571: Add state template for numbers
Required state definition; description is clear.


572-576: Add unit_of_measurement default
Default None matches optional units.


577-581: Add step template
Defines increment step; required is appropriate.


586-590: Add optimistic for selects
Consistent with select interactivity.


591-594: Add options template
Defining choices is core to select; required flag is correct.


595-598: Add select_option action
Completes selection workflow.


599-602: Add state template for selects
Required for reflecting current selection.


608-612: Add last_reset template
Useful for sensors with state_class=total; default None is fine.

🧰 Tools
🪛 LanguageTool

[grammar] ~609-~609: Is an article like ‘a’ or ‘an’ missing?
Context: ... describes when the state of the sensor was last reset. Must render to a valid `dat...

(BE_NN)


613-616: Add state template for sensors
Enforces numeric output for templated sensors; description covers edge cases.


617-621: Introduce state_class
Optional key supports long-term statistics; default None is standard.


622-626: Add unit_of_measurement default
Aligns with sensor conventions.


641-644: Reorder turn_on for switches
Ensures mandatory actions are clearly listed.


654-657: Add clean_spot action
Complements vacuum feature set.


662-665: Introduce fan_speeds list
Allowing multiple speeds is logical.


666-669: Add locate action
Useful for vacuum finding routines.


682-685: Mark start action as required
Good to mandate initial cleaning command.


686-689: Add state template for vacuums
Describes all valid vacuum states.


690-693: Add stop action
Completes vacuum control API.


699-702: Add apparent_temperature_template
Increases weather data fidelity.


703-706: Add cloud_coverage_template
Enhances cloud reporting.


715-718: Add forecast_daily_template
Logical daily forecast granularity.


719-722: Add forecast_hourly_template
Supports hourly forecasts.


723-726: Add forecast_twice_daily_template
Adds twice-daily forecast slots.


731-734: Add ozone_template
Completes pollution metrics.


735-738: Add precipitation_unit
Specifies unit expectations.


763-766: Add wind_gust_speed_template
Captures gust data.


767-770: Add wind_speed_template
Core wind metric.


771-774: Add wind_speed_unit
Specifies wind speed units.


775-778: Add wind_bearing_template
Provides directional wind info.


154-157:

❓ Verification inconclusive

Reposition unique_id
Moving unique_id after triggers groups all identification and update settings together. Verify no tooling expects a different key order.

Run:

to confirm no ordering assumptions.


🏁 Script executed:

rg -n 'unique_id:' -n source/_integrations/template.markdown

Length of output: 319


Verify relocation of unique_id
Relocating the top-level unique_id (currently at line 154) to immediately follow triggers will group all identification and update settings—but make sure no tooling or docs generator depends on the existing key order.

Occurrences of unique_id: in this file: lines 154, 189, 907, 1221, 1273, 1292, 1344, 1427.

Run:

rg -n 'triggers:' source/_integrations/template.markdown
rg -n 'unique_id:' source/_integrations/template.markdown

216-220:

❓ Verification inconclusive

Insert arm_custom_bypass action
Adding this action aligns ordering alphabetically. Confirm the core integration implements this bypass mode.

Search implementation:


🏁 Script executed:

rg 'arm_custom_bypass' -n homeassistant/components/template

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Search the entire repository for any reference to arm_custom_bypass
rg -n 'arm_custom_bypass'

Length of output: 1427


🏁 Script executed:

#!/bin/bash
# Verify Template Alarm Control Panel implementation for arm_custom_bypass
rg -n 'arm_custom_bypass' -n homeassistant/components/alarm_control_panel
rg -n 'custom_bypass' -n homeassistant/components/alarm_control_panel

Length of output: 313


Confirm arm_custom_bypass support in core Template Alarm Control Panel
I couldn’t find any implementation of arm_custom_bypass in the Home Assistant core (e.g. under homeassistant/components/template or alarm_control_panel/template.py). Please verify that the Template Alarm Control Panel integration in core actually implements this action before merging.

Copy link
Contributor
@c0ffeeca7 c0ffeeca7 left a comment

Choose a reason for hiding this comment

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

Thank you, @Petro31 👍

@c0ffeeca7 c0ffeeca7 merged commit 262c73d into home-assistant:current Jun 16, 2025
7 checks passed
lmaertin pushed a commit to lmaertin/home-assistant.io that referenced this pull request Jun 16, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
current This PR goes into the current branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0