How to start an automation 30 minutes before input time helper value

Tags: #<Tag:0x00007f3267a391c0> #<Tag:0x00007f3267a39030>

I want to use the input time helper (input_datetime.tidtest) and then use this as a trigger in an automation BUT start 30 minutes earlier. I can calculate as below but how can I use that as trigger in automation?

{{ strptime(states(‘input_datetime.tidtest’), “%H:%M:%S”) - strptime(‘00:30’, “%H:%M”) }}

Thanks in advance!

easier to use now():

{{ (state_attr('input_datetime.tidtest', 'timestamp') - as_timestamp(now()) ) < 1800 }}

this can be used in a template trigger:

trigger:
    - platform: template
      vaslue_template: "{{ (state_attr('input_datetime.tidtest', 'timestamp') - as_timestamp(now()) ) < 1800 }}"

the above assumes that your input_datetime has both a data and time.

Thanks, but I get true all the time. I have only time as input if that can be problem.

So the idea is to use the helper (input_datetime.tidtest and as time only) to set a time (example 23.00)

Then I want the automation to start 30 minutes earlier (22.30)

{% set date = states('input_datetime.tidtest')%}
{{as_timestamp('date') - 1800}}

1800 seconds equal 30 minutes

The problem is that the input_datetime they are using won’t work with the as_timestamp function. It will only work with a valid datetime string.

to the OP -

try this then:

{{ strptime(states('input_datetime.tidtest'), '%H:%M:%S') - strptime('30', '%M') }}

Thanks!
Seems to get correct value in developer tools but it will not trigger in automation…

Well, yeah, you’re right. I totally lost track of what you were actually asking.

Sorry about that.

you will need to compare the time value to the time now and if they are equal then make the trigger return “true”.

EDIT:

Ok, I’ve tried to manipulate this every way I know to do and I can’t seem to get any comparison to return a true for the trigger.

Unless someone else has any ideas I think the best (and only way I know) to do this is to change your input_datetime to contain the date and then just use the trigger template I gave in the beginning.

I think it has to do with the native data type changes in the latest versions but I can’t even e sure of that.