As the docs state: “Please note that the time condition only takes the time into account. If a referenced sensor or helper entity contains a timestamp with a date, the date part is fully ignored.”
I don’t know at which times your automation is triggered, but as this method doesn’t take the date into account, the values will roll over in some scenarios.
Example:
Last time the automation fired: 10 PM
Next time you want it to fire: 5 AM
The automation didn’t run for: 7 hours, so over 6 hours delta
It will now do this: IF 5 AM > 10 PM. This will not work as 5 AM obviously comes before 10 PM
You have two options for template conditions instead that check for time delta:
First option (the last time the automation was triggered):
I’d prefer the first because that doesn’t need the input_datetime helper and is less clutter in the automation (don’t need to adjust the date time helper). Note, this only works if this automation is only used for this purpose and doesn’t have multiple triggers.