Date/time trigger

Hi!

I have a very simple task (I thought so) to automate but stuck…
I want an automation to start on a specific date at specific time, but can’t find a way to make it…
In automation triggers I see “time” which I can schedule an automation to start at specified time, but this will happen every day… I have a calendar integration, but it requires to create an event in a calendar which looks like an overhead for this simple task: run something on a required date at specific time… How can I make it? Any advice?

Simple would be using a time as trigger and the date as condition in a template, something like:

Template condition:

{{ now().date() | string == '2024-07-02' }}

The string is there to convert now().date() output to a string so you can compare it easily.

Thanks!
I believe this would work but it still looks more like a workaround rather than smth “native”…

You could use an input_datetime helper and use this as the trigger. :slight_smile:

Haven’t tested it, but as you can set a date and a time, this should work. At least it does for my alarms from the phone. :slight_smile:

1 Like

Great! That’s what I’ve been looking for :slight_smile: Thanks a lot!

1 Like

@paddy0174 the only question now is how to add this helper as a trigger :slight_smile:

1 Like

You can easily set an input_datetime helper as the trigger in a time trigger.

Like so:

trigger:
  - platform: time
    at: input_datetime.your_cool_datetime_helper

If the input_datetime has both, time and date set to true, the trigger is date specific, so not triggering every day! But only, if both options are set to true.

input_datetime:
  your_cool_datetime_helper:
    - name: your_cool_datetime_helper
      has_time: true
      has_date: true

This is, how I’d do it, but I’m sure there are other methods out there. :laughing: Seems simple and effective (as long as it’s working :joy:) and not the mothership of templating… :laughing:

I will try, thanks mate

1 Like

Please let me/us know, how it works or if something comes up! :+1: