home-assistant.io
home-assistant.io copied to clipboard
Explain time entity support in time condition
Proposed change
Updating the documentation for a new feature to support time entities in automation conditions.
Type of change
- [ ] Spelling, grammar or other readability improvements (
currentbranch). - [ ] Adjusted missing or incorrect information in the current documentation (
currentbranch). - [x] Added documentation for a new integration I'm adding to Home Assistant (
nextbranch).- [ ] I've opened up a PR to add logos and icons in Brands repository.
- [ ] Added documentation for a new feature I'm adding to Home Assistant (
nextbranch). - [ ] Removed stale or deprecated documentation.
Additional information
- Link to parent pull request in the codebase: https://github.com/home-assistant/core/pull/124575
- Link to parent pull request in the Brands repository:
- This PR fixes or closes issue: fixes #
Checklist
- [x] This PR uses the correct branch, based on one of the following:
- I made a change to the existing documentation and used the
currentbranch. - I made a change that is related to an upcoming version of Home Assistant and used the
nextbranch.
- I made a change to the existing documentation and used the
- [x] The documentation follows the Home Assistant documentation standards.
Summary by CodeRabbit
- Documentation
- Added support for referencing a
timeentity in thebeforeoption in the conditions script. - Introduced an example that references a
timeentity in the conditions script.
- Added support for referencing a
Walkthrough
Walkthrough
This update introduces the ability to reference a time entity in the before option within the conditions script. It enhances the script's flexibility by allowing users to utilize time entities along with input_datetime entities. Additionally, an example showcasing how to reference a time entity has been included to illustrate the new functionality.
Changes
| File | Change Summary |
|---|---|
source/_docs/scripts/conditions.markdown |
Added support for referencing a time entity in the before option and updated examples accordingly. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant Script
participant TimeEntity
participant ConditionChecker
User->>Script: Define condition with `before` option using a `time` entity.
Script->>TimeEntity: Retrieve time value.
TimeEntity-->>Script: Return time value.
Script->>ConditionChecker: Evaluate condition using retrieved time.
ConditionChecker-->>Script: Condition result.
Script-->>User: Return condition evaluation result.
Recent review details
Configuration used: CodeRabbit UI Review profile: ASSERTIVE
Commits
Files that changed from the base of the PR and between 9f24997943350bbe7419bd2b16ce71e17844cc45 and 3aae1c75f6840284a674f67d43e7ee68dd6e2f3c.
Files selected for processing (1)
- source/_docs/scripts/conditions.markdown (2 hunks)
Additional context used
LanguageTool
source/_docs/scripts/conditions.markdown
[uncategorized] ~14-~14: If a new sentence starts here, add a space and start with an uppercase letter. (LC_AFTER_PERIOD) Context: ...s support an optional
alias. {{ page.content | markdownify | toc_only }} ## Logical...
[misspelling] ~14-~14: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...an optional
alias. {{ page.content | markdownify | toc_only }} ## Logical conditions #...
[misspelling] ~14-~14: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...lias`. {{ page.content | markdownify | toc_only }} ## Logical conditions ### AND...
[duplication] ~35-~35: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE) Context: ...: 20 ``` If you do not want to combine AND and OR conditions, you can list them sequen...
[uncategorized] ~48-~48: A comma may be missing after the conjunctive/linking adverb ‘Currently’. (SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA) Context: ..."sensor.temperature" below: 20 ``` Currently you need to format your conditions like...
[duplication] ~96-~96: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE) Context: ...erature" below: 20 ``` ### Mixed AND and OR conditions Test multiple AND and OR...
[duplication] ~98-~98: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE) Context: ...ed AND and OR conditions Test multiple AND and OR conditions in one condition statemen...
[duplication] ~99-~99: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE) Context: ...is true. This allows you to mix several AND and OR conditions together. ```yaml condit...
[misspelling] ~195-~195: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ... "{{ float(state.state) + 2 }}" ``` {% endraw %} It is also possible to test the con...
[misspelling] ~338-~338: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...input_number.lock_sec')|int }}" ``` {% endraw %} The
fortemplate(s) will be evalu...
[misspelling] ~383-~383: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...sun.sun', 'elevation') > -6 }}"
{% endraw %} {% raw %}yaml condition: con...
[misspelling] ~393-~393: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...sun.sun', 'elevation') < -6 }}" ``` {% endraw %} ### Sunset/sunrise condition The s...
[typographical] ~399-~399: Do not use a colon (:) before a series that is introduced by a preposition (‘before’). Remove the colon or add a noun or a noun phrase after the preposition. (RP_COLON) Context: ...unset/sunrise until midnight. If both
before: sunriseandafter: sunsetkeys are u...
[typographical] ~399-~399: Do not use a colon (:) before a series that is introduced by a preposition (‘after’). Remove the colon or add a noun or a noun phrase after the preposition. (RP_COLON) Context: ...idnight_. If both
before: sunriseandafter: sunsetkeys are used, the condition wi...
[typographical] ~399-~399: Do not use a colon (:) before a series that is introduced by a preposition (‘after’). Remove the colon or add a noun or a noun phrase after the preposition. (RP_COLON) Context: ...* from sunset until midnight. If both
after: sunriseandbefore: sunsetkeys are ...
[typographical] ~399-~399: Do not use a colon (:) before a series that is introduced by a preposition (‘before’). Remove the colon or add a noun or a noun phrase after the preposition. (RP_COLON) Context: ...midnight_. If both
after: sunriseandbefore: sunsetkeys are used, the condition wi...
[misspelling] ~450-~450: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ... 'battery_level')|int) > 50 }}" ``` {% endraw %} Within an automation, template cond...
[misspelling] ~466-~466: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ... 'battery_level')|int) > 50 }}" ``` {% endraw %} Or in a list of conditions, allowin...
[misspelling] ~482-~482: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...ce_tracker.iphone', 'away') }}" ``` {% endraw %} This shorthand notation can be used...
[misspelling] ~500-~500: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...or.temperature" below: 20 ``` {% endraw %} It's also supported in the
repeat...
[misspelling] ~512-~512: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ... < 10 }}" sequence: - ...
{% endraw %} {% raw %}yaml - choose: - ...
[misspelling] ~523-~523: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...}" sequence: - ... ``` {% endraw %} It's also supported in script or au...
[misspelling] ~533-~533: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...ce_tracker.iphone', 'away') }}" ``` {% endraw %} [template]: /docs/configuration/tem...
[uncategorized] ~540-~540: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA) Context: ...er a specified time, before a specified time or if it is a certain day of the week. ...
[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...fri ``` Valid values for
weekdayaremon,tue,wed,thu,fri,sat, `s...
[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ... Valid values for
weekdayaremon,tue,wed,thu,fri,sat,sun. No...
[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ... for
weekdayaremon,tue,wed,thu,fri,sat,sun. Note that if onl...
[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...eekday
aremon,tue,wed,thu,fri,sat,sun. Note that if onlybefo...
[misspelling] ~566-~566: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...er
andbeforeoptions a time helper (input_datetimeentity), atime` entity, or another ...
[misspelling] ~697-~697: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...urned_off_5min state: "off" ``` {% endraw %} ## Disabling a condition Every ind...
[misspelling] ~750-~750: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US) Context: ...ed: "{{ _enable_number < 50 }}" ``` {% endraw %}
Markdownlint
source/_docs/scripts/conditions.markdown
566-566: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces) Trailing spaces
408-408: null (MD031, blanks-around-fences) Fenced code blocks should be surrounded by blank lines
603-603: null (MD031, blanks-around-fences) Fenced code blocks should be surrounded by blank lines
403-403: Element: div (MD033, no-inline-html) Inline HTML
560-560: Element: div (MD033, no-inline-html) Inline HTML
584-584: Element: div (MD033, no-inline-html) Inline HTML
556-556: Expected: underscore; Actual: asterisk (MD049, emphasis-style) Emphasis style
556-556: Expected: underscore; Actual: asterisk (MD049, emphasis-style) Emphasis style
557-557: Expected: underscore; Actual: asterisk (MD049, emphasis-style) Emphasis style
557-557: Expected: underscore; Actual: asterisk (MD049, emphasis-style) Emphasis style
Additional comments not posted (1)
source/_docs/scripts/conditions.markdown (1)
577-579: Update the example to demonstrate the newtimeentity functionality.The updated example clearly demonstrates how to use a
timeentity with thebeforeoption. This is a practical illustration that aligns well with the documentation's goal of educating users on the new feature.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
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>.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
@coderabbitaiin 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
@coderabbitaiin 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 generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@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 as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Deploy Preview for home-assistant-docs ready!
| Name | Link |
|---|---|
| Latest commit | 3aae1c75f6840284a674f67d43e7ee68dd6e2f3c |
| Latest deploy log | https://app.netlify.com/sites/home-assistant-docs/deploys/6668b1ccee8cfe00083fd3af |
| Deploy Preview | https://deploy-preview-33217--home-assistant-docs.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.