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

HA automation condition to support date ranges #24317

Closed
fermulator opened this issue Jun 5, 2019 · 11 comments
Closed

HA automation condition to support date ranges #24317

fermulator opened this issue Jun 5, 2019 · 11 comments

Comments

@fermulator
Copy link

fermulator commented Jun 5, 2019

Home Assistant release with the issue:
0.92.2

Last working Home Assistant release (if known):
None (this is an enhancement)

Operating environment (Hass.io/Docker/Windows/etc.):
python3.6 virtual env

Component/platform:
https://www.home-assistant.io/docs/scripts/conditions/

Description of problem:

The conditions allow for sun level, time, etc; but no "date range".
https://www.home-assistant.io/docs/scripts/conditions/#time-condition

Use Case (0): Basic Date Ranges
, consider a permanently installed receptacle/switch where the user wants to activate it (ON/OFF) at specific time(s) in the day, but ONLY between certain date ranges in the year.

Use Case (1): Seasonal Repurposing
, I have a seasonal outdoor switch on zwave; in the summer it shall control a water fountain, in the winter it shall control exterior Winter holiday season lights
(i'd like to be able to program HA once for the summer season ranges, and winter time; then if the switch exists, the automation for the appropriate action/times will apply)

Use Case (2): Electrical Utility peak/off-peak seasonal changes
, consider we wish to program certain devices OFF during peak-electrical times; this can be satisified by time conditions, EXCEPT if your utility changes peak times by season. Consider: https://www.wnhydro.com/en/your-home/time-of-use-rates.asp.
(in a perfect world utilities might expose APIs, which would render a separate enhancement to build a "electrical-time-of-use" component similar to https://www.home-assistant.io/components/workday/) - but in the absence of that, the user could program semi-annually their date ranges to match the time-of-use seasonal changes.

Use Case (3): Basic Date Listings and Patterns
, what if a user would like the "1st of every month" or "every other week" or etc?
(not currently in scope)

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
https://www.home-assistant.io/docs/scripts/conditions/#time-condition

  • extend for date?
    , of note, it already has a subsequent weekday filter; so extension for date-range seems reasonable

Traceback (if applicable):
N/A

Additional information:
Feature Suggestion / Idea
(open to implementing myself, would look for stakeholder agreement to the idea first)

Requirements

PROPOSED

  • The time condition component MUST support an additional filter(s) to control date ranges
  • Date ranges MUST support the most common calendar used by most of the world (https://en.wikipedia.org/wiki/Gregorian_calendar)
  • This date-range MUST be an OPTIONAL filter (if unspecified, MUST NOT impact any of the existing time or weekday functionality)
  • Optional filters to time (weekday, date_...) MUST be COMBINATION_AND logic (not OR)
  • The configurations for date ranges MUST be two separate configuration entities (i.e. date_start and date_end)
  • Date ranges MUST be inclusive to the dates specified
  • SHALL support standard ISO formatting YYYY-MM-DD
  • MUST support ranges across months and year boundaries
  • MUST handle leap days/years (and any typical scenarios where dates can come and go)
  • MUST support via configuration.yml as well as GUI automation builder (NOTE: weekday is not currently in the UI)
@fermulator
Copy link
Author

From an implementation perspective, I believe extension for date_start and date_end is reasonably similar to the weekday filter in the time function.

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/condition.py#L360

@fermulator
Copy link
Author

fermulator commented Jul 15, 2019

Implementation wise, we should probably re-use https://pypi.org/project/DateTimeRange/

It supports (of course) checking if a date/time is wtihin a given range via:
https://pypi.org/project/DateTimeRange/#datetimerange

So once we have the date_start and date_end constructs, that can be linked with the condition based on time.now().

@fermulator
Copy link
Author

"TAG": looking for input into my requirements and implementation considerations before proceeding

:)

@bagobones
Copy link

Not sure if it is technically in scope but the current automation editor UI only allows for before and after times, it does not appear to even support any of the existing advanced weekday attributes etc. Hopefully if date ranges are added they are also supported in the UI.

@fermulator
Copy link
Author

fermulator commented Nov 21, 2019

@bagobones

Not sure if it is technically in scope but the current automation editor UI only allows for before and after times, it does not appear to even support any of the existing advanced weekday attributes etc. Hopefully if date ranges are added they are also supported in the UI.

Yes you are correct. See my last requirement in the list which accounted for this.

MUST support via configuration.yml as well as GUI automation builder (NOTE: weekday is not currently in the UI)

Though if the UI itself does not have this as base elements, I probably wouldn't implement that as part of this scope ... (more than I'd like to chew). (haven't looked into this)

@stale
Copy link

stale bot commented Feb 19, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 19, 2020
@shire210
Copy link

Still looking to get this addressed. Specifically the part about the weekday selection being added to the UI.

@stale stale bot removed the stale label Feb 24, 2020
@bagobones
Copy link

I am still interested in this as well.. I shy away from making weekend / weekday automatons currently because of the lack of UI support.

@fermulator
Copy link
Author

Note that the "workday" component and as a condition works fine in the UI as a workaround.
The goal of this is to support date ranges to allow users to automate things based on time of year, seasonal etc.

@frenck
Copy link
Member

frenck commented Mar 6, 2020

I notice this issue now for the first time, but this is a feature request, not a bug (as already mentioned in the OP "this is an enhancement".

We use GitHub for tracking issues, not for providing support or tracking feature requests.

If you want to suggest a feature, you should try our Community Forum: Feature Requests.

If you have additional questions, feel free to join our Discord chat server.

Thanks! 👍

@frenck frenck closed this as completed Mar 6, 2020
@fermulator
Copy link
Author

Passific added a commit to Passific/homeassistant-home-assistant.io that referenced this issue Oct 14, 2024
<!--
  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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants