Start an automation 1,2,3,4,5 hours before a given time

heyhey
Im charging my car with PV Excess power.
For leaving work with full batterie I want to check my batterie sometimes before my departure time.
Therefor I want to set a departure time (input_datetime) and check batterie 1 hour before, 2 hours before, 3 hours before and so on (I got a slow loading PV)
But I have no idea how to set this automation.

For easy example lets say, I define an input_datetime - 7pm
now I want to run an automation at 6pm
If I change my input_datetime to 4pm I want my automation to run at 3pm.
How to do that?

If it’s always an offset of one hour from a set input datetime, you can use a template trigger such as this:

    - platform: template
      value_template: >-
        {% set t = (states('input_datetime.departure_time') | as_datetime | as_local - timedelta(hour=1)).strftime('%Y-%d-%m %H:%M') %}
        {% set n = now().strftime('%Y-%d-%m %H:%M') %}
        {{ n == t }}

Heyhey, thanks for your answer.
But I dont get any further with this codesnippet and the link. (Sorry im very HASS nobish).
Is there any way to get an ID from the value template?
If its 1 hour before departure time I need to check if my cars batterie is at 80% (or do sth.).
2 hours before I need 60% (or do sth.) and so on.
Ofcourse I now could create 5 template triggers, but am kinda sure its also possible with 1.

It’s kinda same (but more detail)
In my first post, I said:
“Im charging my car with PV Excess power.
For leaving work with full batterie I want to check my batterie sometimes before my departure time.”

Why else should I check 1 hour before departure time, whats my batteriestate?
Exactly to leave work with a fully charged batterie! As I told in my first post.
This means (I didnt write this, because its obvious) if my cars batterie is one hour before departure time below a certain state (80% in my case) stop PV escess charging and load from grid.
2 hours before departure the limit is 60%, and so on.

So the only thing you can reproach is, that it took 11 days to an answer.
Youre right, but… is it really worth reproaching?

Dont worry bro, I dont take anything written on the internet personal :smile:

Just wanted to show your thesis:

is bullshit.

But anyway I dont think you’ll post any somewhat purposeful to the main topic and Im really not interested in strange smalltalk.
So Im quiet now and hope there will be an answer within the next 11 days :smile:

If not I keep my 5 singe Template trigges (what took a newbie like me a lot of time btw.)