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

Add date and datetime conditions #35234

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

Conversation

Passific
Copy link
Contributor

@Passific Passific commented Oct 14, 2024

Proposed change

The goal is to be able to not only compare time, but also date and datetime.

It's a missing feature that I need for my own setup, but as I was looking for it, I noticed I was not the only one.
There is one ticket (#24317), but also forum discussions about it.

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

  • New Features

    • Expanded documentation for conditions, including new sections on "Trigger condition" and "Zone condition."
    • Introduced a new condition type: datetime, with examples for specific date and time checks.
    • Enhanced clarity with updated examples for time, date, and datetime conditions.
  • Documentation

    • Significant updates to the conditions documentation, providing comprehensive examples and explanations for implementing various conditions in automations.

<!--
  You are amazing! Thanks for contributing to our project!
  Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).

  Before submitting your pull request, please verify that you have chosen the correct target branch,
  and that the PR preview looks fine and does not include unrelated changes.
-->
## Proposed change
<!-- 
    Describe the big picture of your changes here to communicate to the
    maintainers why we should accept this pull request. If it fixes a bug
    or resolves a feature request, be sure to link to that issue in the 
    additional information section.
-->
The goal is to be able to not only compare time, but also date and datetime.

It's a missing feature that I need for my own setup, but as I was look for it, I noticed I was not the only one.
There are some ticket (home-assistant#24317), but also [forum discussions](https://community.home-assistant.io/t/automation-during-date-range/133814) about it.


## Type of change
<!--
    What types of changes does your PR introduce to our documentation/website?
    Put an `x` in the boxes that apply. You can also fill these out after
    creating the PR.
-->

- [ ] 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).
  - [ ] I've opened up a PR to add logos and icons in [Brands repository](https://github.com/home-assistant/brands).
- [x] Added documentation for a new feature I'm adding to Home Assistant (`next` branch).
- [ ] Removed stale or deprecated documentation.

## Additional information
<!--
    Details are important, and help maintainers processing your PR.
    Please be sure to fill out additional details, if applicable.
-->

- Link to parent pull request in the codebase: home-assistant/core#128009
- Link to parent pull request in the Brands repository: 
- This PR fixes or closes issue: fixes home-assistant/core#24317

## Checklist
<!--
    Put an `x` in the boxes that apply. You can also fill these out after
    creating the PR. If you're unsure about any of them, don't hesitate to ask.
    We're here to help! This is simply a reminder of what we are going to look
    for before merging your code.
-->

- [x] 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.
- [x] The documentation follows the Home Assistant documentation [standards].

[standards]: https://developers.home-assistant.io/docs/documenting/standards
@home-assistant home-assistant bot added Hacktoberfest An PR on this issue (or the PR itself) is eligible towards Hacktoberfest! has-parent This PR has a parent PR in a other repo next This PR goes into the next branch labels Oct 14, 2024
Copy link

netlify bot commented Oct 14, 2024

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit 19f13c2
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/670d8717969f8d0008a9d74e
😎 Deploy Preview https://deploy-preview-35234--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 bot commented Oct 14, 2024

📝 Walkthrough

Walkthrough

The documentation for script and automation conditions has been extensively revised. Key updates include the renaming of the "Time condition" section to "Time, date or datetime conditions," which now encompasses checks for date and datetime. New examples illustrate these functionalities, including the use of input_datetime entities. Additionally, a "Trigger condition" section has been introduced, detailing how to verify automation triggers, and the "Zone condition" section has been expanded with examples for testing multiple entities against specified zones.

Changes

File Path Change Summary
source/_docs/scripts/conditions.markdown Updated documentation for conditions, including renaming, new examples for datetime, trigger conditions, and expanded zone conditions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Automation
    participant Conditions

    User->>Automation: Trigger automation
    Automation->>Conditions: Check conditions
    alt Time condition
        Conditions->>Conditions: Evaluate time
    else Date condition
        Conditions->>Conditions: Evaluate date
    else Datetime condition
        Conditions->>Conditions: Evaluate datetime
    end
    alt Trigger condition
        Conditions->>Automation: Check trigger ID
    end
    alt Zone condition
        Conditions->>Conditions: Evaluate zone for multiple entities
    end
    Automation-->>User: Automation result
Loading

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>, 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 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

🧹 Outside diff range and nitpick comments (4)
source/_docs/scripts/conditions.markdown (4)

552-554: LGTM: Clear example of datetime condition

The added example effectively demonstrates the usage of the new datetime condition. The future date is appropriate for documentation.

Consider adding a brief comment explaining that this condition will be true after the specified date and time, to enhance clarity for users.


578-579: LGTM: Good example of date condition with sensor

The updated example effectively demonstrates the use of the new date condition, showing how it can reference a sensor for dynamic date values.

Consider adding a brief explanation of what this condition does (e.g., "This condition will be true after the date provided by the shipping_delivery_date sensor") to provide more context for users.


Line range hint 590-638: LGTM: Comprehensive explanation of new Trigger condition

The new "Trigger condition" section is a valuable addition, providing clear explanations and examples for testing specific triggers in automations. This feature will enable more sophisticated automation control.

Consider adding a brief example or explanation of a practical use case for this condition (e.g., "This can be useful when you want different actions based on which trigger fired the automation") to help users understand when they might want to use this feature.


Line range hint 537-638: Great additions to condition capabilities

The changes in this PR significantly enhance the condition system in Home Assistant by:

  1. Adding new date and datetime conditions.
  2. Introducing a trigger condition for more complex automations.
  3. Providing clear examples and explanations for each new feature.

These additions align well with the PR objectives and will provide users with more powerful and flexible automation options.

As these changes introduce new condition types, ensure that the core Home Assistant documentation (e.g., in the automation and script sections) is updated to reflect these new capabilities. This will help maintain consistency across the documentation and ensure users are aware of these new features in relevant contexts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8a9f78b and 19f13c2.

📒 Files selected for processing (1)
  • source/_docs/scripts/conditions.markdown (3 hunks)
🧰 Additional context used
🔇 Additional comments (2)
source/_docs/scripts/conditions.markdown (2)

537-539: LGTM: Expanded condition types accurately described

The updated title and description effectively communicate the addition of date and datetime conditions, providing users with a clear overview of the expanded functionality.


586-587: LGTM: Important clarification on condition behaviors

The added note provides essential information about the scope of each condition type (time, date, and datetime). This clarification will help users choose the appropriate condition type for their needs and prevent potential misunderstandings.

@Passific Passific marked this pull request as ready for review November 14, 2024 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest An PR on this issue (or the PR itself) is eligible towards Hacktoberfest! 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.

1 participant