dwhite56
(Dwhite56)
November 30, 2024, 10:19pm
1
Take the example of an alarm clock using an input_datetime to trigger an automation. Why can’t I trigger the automation with an offset from the input_datetime, using the value from an input_number rather than a fixed offset - i.e. 15 minutes before the alarm goes off, turn on the coffee machine; 30 minutes after my preset bedtime, turn down the heating.
tom_l
November 30, 2024, 10:35pm
2
To be clear: you are asking for the time trigger to support entities with a numeric value (or templates) in the offset option?
+1
Just gonna jump in with agreement here - I have already set this up by following someone’s guidelines to write some yaml in the config file, but for such a powerful and useful automation trigger it should not be locked behind manual yaml editing!
15 minutes before alarm: fade lights on
10 minutes before calendar event: turn entrance lights on
20 minutes before calendar event tagged D&D: turn on guest mode
etc.
Mayhem_SWE
(Magnus Helin)
December 18, 2024, 12:58pm
4
Does offsets work at all for a time trigger wired to an input_datetime
? Last I checked I am pretty sure they only worked when wired to a sensor
.
was just about to open a new WTH, because this comes up systematically during the years, and it really feels underwhelming we cant (read: seems so natural to do, I was amazed we still cant)
to give a yaml example:
- id: turn_on_quooker_before_alarmclock
mode: queued
triggers:
trigger: time
at:
entity_id: input_datetime.alarmclock_wd
offset: -00:15:00
Documentation is right, but you have to read carefully, including the placement of the comma:
requesting this feature is especially valid, since we’re told to move from eg template sensors all the time to use input_datetimes.
not being able to trigger off those with an offset is not very consistent from the point of view.
hope this will be considered
parautenbach
(Pieter Rautenbach)
December 30, 2024, 9:49am
6
To extend this good idea, I’d like to provide a list of offsets.
petro
(Petro)
December 31, 2024, 1:09pm
7
home-assistant:dev
← Petro31:fix-input-datetime-time-offset
opened 04:05PM - 25 Nov 24 UTC
<!--
You are amazing! Thanks for contributing to our project!
Please, DO N… OT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
<!--
If your PR contains a breaking change for existing users, it is important
to tell them what breaks, how to make it work again and why we did this.
This piece of text is published with the release notes, so it helps if you
write it towards our users, not us.
Note: Remove this section if this PR is NOT a breaking change.
-->
## 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.
-->
Time triggers with offsets are restricted to only allow sensors. We have a user attempting to do an offset with an input datetime. They have 2 automations, 1 automation that triggers off the input datetime, then a second automation that should trigger 20 minutes before the input_datetime. Right now, the user would have to create 2 input datetimes because of this restriction.
This PR removes the restriction.
relevant thread: https://community.home-assistant.io/t/trigger-using-input-datetime-with-time-offset/799710
also it's a WTH too: https://community.home-assistant.io/t/wth-offset-input-datetime-automation-trigger-by-input-number/802293
## Type of change
<!--
What type of change does your PR introduce to Home Assistant?
NOTE: Please, check only 1! box!
If your PR requires multiple boxes to be checked, you'll most likely need to
split it into multiple PRs. This makes things easier and faster to code review.
-->
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
-->
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
## 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] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] I have followed the [perfect PR recommendations][perfect-pr]
- [x] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [x] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
<!--
This project is very active and we have a high turnover of pull requests.
Unfortunately, the number of incoming pull requests is higher than what our
reviewers can review and merge so there is a long backlog of pull requests
waiting for review. You can help here!
By reviewing another pull request, you will help raise the code quality of
that pull request and the final review will be faster. This way the general
pace of pull request reviews will go up and your wait time will go down.
When picking a pull request to review, try to choose one that hasn't yet
been reviewed.
Thanks for helping out!
-->
To help with the load of incoming pull requests:
- [ ] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
<!--
Thank you for contributing <3
Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/development_checklist/
[manifest-docs]: https://developers.home-assistant.io/docs/creating_integration_manifest/
[quality-scale]: https://developers.home-assistant.io/docs/integration_quality_scale_index/
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr
Doesn’t offset from an input number, but it does allow input_datetimes to be used with a static offset.
Baby steps.
3 Likes
Mayhem_SWE
(Magnus Helin)
December 31, 2024, 2:03pm
8
The logical thing would be if offset:
works the same way as similar fields like delay:
and timeout:
, which can accept either a timestring, a number which then is interpreted as seconds, or a mapping which can contain values for hours:
, minutes:
, seconds:
etc.
petro
(Petro)
December 31, 2024, 2:04pm
9
It does support that already.
That PR just allows us to use input_datetime
s. Currently we can use an offset with timestamp sensors. The offset
field from it’s inception supports seconds, a time string, or hours/minutes/seconds.
mituns
January 5, 2025, 10:23am
10
any idea, when this PR will go live? Currently I still can’t set any offset for a time based trigger
but does it allow datetimes with only time? That would be the biggest enhancement imho.
My alarm clock time doesn’t use a day… creating a template sensor for that doesnt work, as we cant set timestamp on that apparently.
the next_alarm (remember?) has states that cant be used as trigger (when both weekday and weekend days are off, the state is either 0 or unavailable, so not very useful in an automation).
great. Fingerscrossed then even more.
is this merged for 2025.2 now? since I didnt see any mention of it at all yet in the discord, or noteworthy etc etc
heck I missed it there.
imho it should be upgraded to the Noteworthy changes
Ill mention it in the Beta channel so we all can have a go at it
thx