Skip to content
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

Explain time entity support in time condition #33217

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

markbergsma
Copy link
Contributor

@markbergsma markbergsma commented Jun 11, 2024

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 (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
    • Added support for referencing a time entity in the before option in the conditions script.
    • Introduced an example that references a time entity in the conditions script.

@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 Jun 11, 2024
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

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.
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 9f24997 and 3aae1c7.

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 for template(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: sunrise and after: sunset keys 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: sunrise and after: sunset keys 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: sunrise and before: sunset keys 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: sunrise and before: sunset keys 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 weekday are `mon`, `tue`, `wed`, `thu`, `fri`, `sat`, `s...


[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US)
Context: ... Valid values for weekday are mon, tue, wed, thu, fri, sat, sun. No...


[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US)
Context: ... for weekday are mon, tue, wed, thu, fri, sat, sun. Note that if onl...


[misspelling] ~555-~555: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US)
Context: ...eekdayaremon, tue, wed, thu, fri, sat, sun. Note that if only befo...


[misspelling] ~566-~566: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US)
Context: ...erandbefore options 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 new time entity functionality.

The updated example clearly demonstrates how to use a time entity with the before option. 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?

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>.
    • 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 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 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to 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.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

netlify bot commented Jun 11, 2024

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit 3aae1c7
🔍 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...

QR Code

Use your smartphone camera to open QR code link.

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

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

@@ -563,7 +563,7 @@ A better weekday condition could be by using the [Workday Binary Sensor](/integr

</div>

For the `after` and `before` options a time helper (`input_datetime` entity)
For the `after` and `before` options a time helper (`input_datetime` entity), a `time` entity,
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the usage of time entity in the after and before options.

The addition of a time entity alongside input_datetime and other sensors is a significant enhancement. It would be beneficial to include a brief explanation or link to further documentation on how a time entity differs from input_datetime and other timestamp-containing sensors, especially for new users.

Tools
LanguageTool

[misspelling] ~566-~566: Possible spelling mistake found. (MORFOLOGIK_RULE_EN_US)
Context: ...erandbefore options a time helper (input_datetimeentity), atime` entity, or another ...

Markdownlint

566-566: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces

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