Getting error with input_datetime.set_datetime

Hello,

I have a piece of code that works fine in the Template editor, returning a value like 06:45:00 but, it gives me an error in te automation: Unable to determine action @ data[0]

I cannot figure out why. The input_datetime helpers are set to Time only, triple checked that.

Can anyone give a hint how to make this work in the automation as well?
Using the latest HA build.

service: input_datetime.set_datetime
metadata: {}
data:
  value: "{{ (strptime(states('input_datetime.vw_bathroom_friday_warm'), "%H:%M:%S") - 
  timedelta(minutes=states('input_number.bathroom_heatingtime_fr')|int)).strftime('%H:%M:%S') }}"
target:
  entity_id: input_datetime.test_time_fr

value is not one of the service call’s supported options.

Change it to time.

Thank you for your answer.
I did try those options, but to now avail.
When I change value to time I get the error: Service does not match format . for dictionary value @ data[0][‘service’]

While trying and retrying to get the date calculation working with various statements, I fell into the trap I thought I double checked… I used double qoutes in one of the time formats: “%H:%M:%S”

I should learn to check on quotes again when I lazily copy and paste some code…

That’s a minor syntax error compared to using a non-existent option like value.

Your template may not even need to use strptime and strftime depending on how the Input Datetime helper is configured. Is it configured to store time only or both date and time?

It only uses Time.

When I left it out I got errors, and this was the way I got it working.

In that case, you can use today_at to convert the time string to a datetime object. Subtract the timedelta object from the datetime object and then convert the result to a timestamp value.

{{ (today_at(states('input_datetime.vw_bathroom_friday_warm')) -
  timedelta(minutes=states('input_number.bathroom_heatingtime_fr') | int(0))).timestamp() }}

Use the template with the service call’s timestamp option.

service: input_datetime.set_datetime
data:
  timestamp: >
    {{ (today_at(states('input_datetime.vw_bathroom_friday_warm')) -
      timedelta(minutes=states('input_number.bathroom_heatingtime_fr') | int(0))).timestamp() }}
target:
  entity_id: input_datetime.test_time_fr

EDIT

If you want, you can use variables to improve the template’s legibility.

service: input_datetime.set_datetime
data:
  timestamp: >
    {% set t = states('input_datetime.vw_bathroom_friday_warm') %}
    {% set offset = states('input_number.bathroom_heatingtime_fr') | int(0) %}
    {{ (today_at(t) - timedelta(minutes=offset)).timestamp() }}
target:
  entity_id: input_datetime.test_time_fr