Skip to content

Add modern style configuration for template cover #38744

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

Conversation

Petro31
Copy link
Contributor

@Petro31 Petro31 commented Apr 25, 2025

Proposed change

Adds modern style template configuration to cover platform.

e.g.

template:
- cover:
  - name: ...

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

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
    • Updated documentation to include support for the "cover" entity type in the Template integration.
    • Added a detailed configuration reference for template covers, describing state, position, tilt templates, actions, and options.
    • Expanded lists and section headers to explicitly include cover entities alongside other supported types.

@Petro31 Petro31 requested a review from a team as a code owner April 25, 2025 12:51
@home-assistant home-assistant bot added has-parent This PR has a parent PR in a other repo next This PR goes into the next branch labels Apr 25, 2025
Copy link

netlify bot commented Apr 25, 2025

Deploy Preview for home-assistant-docs failed.

Name Link
🔨 Latest commit a32a745
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/680f19ab7c605200089856f7

Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

📝 Walkthrough

Walkthrough

The documentation for the Template integration in Home Assistant was updated to add support for the "cover" entity type. This involved expanding the lists of supported categories and platforms to include "cover", updating relevant section headers, and adding a detailed configuration reference for template covers. The new section describes the schema, required and optional keys, accepted value types, and behavioral flags for cover entities. Additionally, the documentation now lists "cover" among the entity types that share common configuration fields.

Changes

File(s) Change Summary
source/_integrations/template.markdown Added documentation for "cover" entity type, expanded category/platform lists, updated headers, and included a new configuration schema section for template covers. Also updated the list of entity types sharing common fields to include "cover".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomeAssistantDocs

    User ->> HomeAssistantDocs: Reads Template integration documentation
    HomeAssistantDocs -->> User: Presents updated entity types (including "cover")
    User ->> HomeAssistantDocs: Views configuration reference for "cover"
    HomeAssistantDocs -->> User: Shows cover schema, keys, and usage details
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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For 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 generate unit testing code.
    • @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.

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: 2

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

79-79: Nitpick: normalize “weathers” to “weather”.

In the heading, “weathers” is nonstandard; it’s preferable to use the uncountable form “weather”.
Suggested change:

-### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weathers
+### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weather
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa65d9f and 7dc0d60.

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

[uncategorized] ~342-~342: A comma might be missing here.
Context: ...en). If the template produces a None value the current tilt state will be set to `...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

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

300-300: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)

⏰ 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 (3)
source/_integrations/template.markdown (3)

7-7: Approve addition of Cover to ha_category.

Including Cover in the ha_category list aligns with the new template cover feature.


10-10: Approve addition of Light to ha_category.

The Light entry follows the existing pattern and ensures consistency in category listings.


14-14: Approve addition of Switch to ha_category.

Adding Switch here keeps the category list up to date with supported template entities.

@@ -391,7 +441,7 @@ weather:
description: Unit for precipitation output. Valid options are km, mi, ft, m, cm, mm, in, yd.
required: false
type: string
"[all sensor, binary sensor, button, image, number, select, weather entities]":
"[all sensor, binary sensor, button, cover, image, number, select, weather entities]":
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Correct the map description to include all listed entities.

The header includes cover, image, and weather, but the description omits them. This inconsistency can confuse readers.
Proposed fix:

-  description: Fields that can be used above for sensors, binary sensors, buttons, numbers, and selects.
+  description: Fields that can be used above for sensors, binary sensors, buttons, covers, images, numbers, selects, and weather entities.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"[all sensor, binary sensor, button, cover, image, number, select, weather entities]":
"[all sensor, binary sensor, button, cover, image, number, select, weather entities]":
description: Fields that can be used above for sensors, binary sensors, buttons, covers, images, numbers, selects, and weather entities.

Comment on lines 298 to 344
cover:
state:
description: Defines a template to get the state of the cover. Valid output values from the template are `open`, `opening`, `closing` and `closed` which are directly mapped to the corresponding states. In addition, `true` is valid as a synonym to `open` and `false` as a synonym to `closed`. If [both a `value_template` and a `position_template`](#combining-value_template-and-position_template) are specified, only `opening` and `closing` are set from the `value_template`. If the template produces a `None` value the state will be set to `unknown`.
required: false
type: template
position:
description: Defines a template to get the position of the cover. Legal values are numbers between `0` (closed) and `100` (open). If the template produces a `None` value the current position will be set to `unknown`.
required: false
type: template
device_class:
description: Sets the [class of the device](/integrations/cover/), changing the device state and icon that is displayed on the frontend.
required: false
type: string
open_cover:
description: Defines an action to open the cover. If [`open_cover`](#open_cover) is specified, [`close_cover`](#close_cover) must also be specified. At least one of [`open_cover`](#open_cover) and [`set_cover_position`](#set_cover_position) must be specified.
required: inclusive
type: action
close_cover:
description: Defines an action to close the cover.
required: inclusive
type: action
stop_cover:
description: Defines an action to stop the cover.
required: false
type: action
set_cover_position:
description: Defines an action to set to a cover position (between `0` and `100`). The variable `position` will contain the entity's set position.
required: false
type: action
set_cover_tilt_position:
description: Defines an action to set the tilt of a cover (between `0` and `100`). The variable `tilt` will contain the entity's set tilt position.
required: false
type: action
optimistic:
description: Force cover position to use [optimistic mode](#optimistic-mode).
required: false
type: boolean
default: false
tilt_optimistic:
description: Force cover tilt position to use [optimistic mode](#optimistic-mode).
required: false
type: boolean
default: false
tilt:
description: Defines a template to get the tilt state of the cover. Legal values are numbers between `0` (closed) and `100` (open). If the template produces a `None` value the current tilt state will be set to `unknown`.
required: false
type: template
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix broken link fragment and add missing comma in cover config.

  1. The link to #combining-value_template-and-position_template does not resolve—remove or replace it.
  2. Add a comma after “None value” for readability.

Proposed diff:

@@ 299,307
-    description: Defines a template to get the state of the cover. Valid output values from the template are `open`, `opening`, `closing` and `closed` which are directly mapped to the corresponding states. In addition, `true` is valid as a synonym to `open` and `false` as a synonym to `closed`. If [both a `value_template` and a `position_template`](#combining-value_template-and-position_template) are specified, only `opening` and `closing` are set from the `value_template`. If the template produces a `None` value the state will be set to `unknown`.
+    description: Defines a template to get the state of the cover. Valid output values from the template are `open`, `opening`, `closing` and `closed` which are directly mapped to the corresponding states. In addition, `true` is valid as a synonym to `open` and `false` as a synonym to `closed`. If both a `value_template` and a `position_template` are specified, only `opening` and `closing` are set from the `value_template`. If the template produces a `None` value, the state will be set to `unknown`.
@@ 340,345
-  tilt:
-    description: Defines a template to get the tilt state of the cover. Legal values are numbers between `0` (closed) and `100` (open).  If the template produces a `None` value the current tilt state will be set to `unknown`.
+  tilt:
+    description: Defines a template to get the tilt state of the cover. Legal values are numbers between `0` (closed) and `100` (open). If the template produces a `None` value, the current tilt state will be set to `unknown`.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~342-~342: A comma might be missing here.
Context: ...en). If the template produces a None value the current tilt state will be set to `...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

🪛 markdownlint-cli2 (0.17.2)

300-300: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)

@home-assistant home-assistant bot added the parent-merged The parent PR has been merged already label Apr 25, 2025
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: 2

♻️ Duplicate comments (1)
source/_integrations/template.markdown (1)

445-445: ⚠️ Potential issue

Include all entity types in common-fields description.

The description under "[all sensor, binary sensor, button, cover, image, number, select, weather entities]" omits cover, image, and weather. Update it to match the heading:

- description: Fields that can be used above for sensors, binary sensors, buttons, numbers, and selects.
+ description: Fields that can be used above for sensors, binary sensors, buttons, covers, images, numbers, selects, and weather entities.
🧹 Nitpick comments (2)
source/_integrations/template.markdown (2)

304-304: Add missing comma in position description.

For clarity, insert a comma after “value”:

- If the template produces a `None` value the current position will be set to `unknown`.
+ If the template produces a `None` value, the current position will be set to `unknown`.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~304-~304: 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)


342-342: Remove extra space before sentence.

There are two spaces after the period—reduce to one for consistency:

- Legal values are numbers between `0` (closed) and `100` (open).  If the template produces a `None` value, the current tilt state will be set to `unknown`.
+ Legal values are numbers between `0` (closed) and `100` (open). If the template produces a `None` value, the current tilt state will be set to `unknown`.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7dc0d60 and 8effc77.

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

[uncategorized] ~304-~304: 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)

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

300-300: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)


312-312: Link fragments should be valid
null

(MD051, link-fragments)

⏰ 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 (1)
source/_integrations/template.markdown (1)

4-14: Add support for cover in ha_category and maintain alphabetical ordering.

The ha_category frontmatter now includes Cover, and the list remains alphabetically ordered. This helps users discover the new template cover option alongside existing categories.

@@ -73,7 +76,7 @@ Entities (sensors, binary sensors, buttons, images, numbers, and selections) are

_For old sensor/binary sensor configuration format, [see below](#legacy-binary-sensor-configuration-format)._

### State-based template binary sensors, buttons, images, numbers, selects, sensors, and weathers
### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weathers
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix pluralization and naming in heading.

The heading reads “weathers” (plural), but the integration uses the singular weather entity type. Please update it as follows for consistency:

- ### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weathers
+ ### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weather
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weathers
### State-based template binary sensors, buttons, covers, images, numbers, selects, sensors, and weather

@@ -292,6 +295,53 @@ button:
description: Defines actions to run to press the button.
required: true
type: action
cover:
state:
description: Defines a template to get the state of the cover. Valid output values from the template are `open`, `opening`, `closing` and `closed` which are directly mapped to the corresponding states. In addition, `true` is valid as a synonym to `open` and `false` as a synonym to `closed`. If [both a `value_template` and a `position_template`](#combining-value_template-and-position_template) are specified, only `opening` and `closing` are set from the `value_template`. If the template produces a `None` value the state will be set to `unknown`.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve broken link to combining templates.

The inline link to #combining-value_template-and-position_template does not point to any anchor. Simplify or correct it, for example:

- If [both a `value_template` and a `position_template`](#combining-value_template-and-position_template) are specified...
+ If both a `value_template` and a `position_template` are specified...
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: Defines a template to get the state of the cover. Valid output values from the template are `open`, `opening`, `closing` and `closed` which are directly mapped to the corresponding states. In addition, `true` is valid as a synonym to `open` and `false` as a synonym to `closed`. If [both a `value_template` and a `position_template`](#combining-value_template-and-position_template) are specified, only `opening` and `closing` are set from the `value_template`. If the template produces a `None` value the state will be set to `unknown`.
description: Defines a template to get the state of the cover. Valid output values from the template are `open`, `opening`, `closing` and `closed` which are directly mapped to the corresponding states. In addition, `true` is valid as a synonym to `open` and `false` as a synonym to `closed`. If both a `value_template` and a `position_template` are specified, only `opening` and `closing` are set from the `value_template`. If the template produces a `None` value the state will be set to `unknown`.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

300-300: Link fragments should be valid
null

(MD051, link-fragments)

@c0ffeeca7 c0ffeeca7 merged commit 05d97eb into home-assistant:next Apr 28, 2025
3 of 7 checks passed
@home-assistant home-assistant bot removed the parent-merged The parent PR has been merged already label Apr 28, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has-parent This PR has a parent PR in a other repo next This PR goes into the next branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants