Subtract 1 minute from datetime in automation

I am using the Irrigation Controller integration and have 2 separate programs, one that turns off master valves and the second that then opens 2 valves in a sequence.

The integrations uses input_datetime (just the “time” element) helpers for the start of the programs.

I have one called input_number.irrigation_master_run_time that is for the master valves and one called input_number.program_1_run_time that acts for the 2 valves program.

I am attempting to automatically change the input_number.irrigation_master_run_time to 1 minute before the input_number.program_1_run_time, whenever the latter is changed.

So if the input_number.program_1_run_time is changed to 21:20, the input_number.irrigation_master_run_time is automatically changed to 21:19

I have several related changes in an automation and so want to continue the automation route.

The code in my automation is coded as follows:

service: input_datetime.set_datetime
data:
  value: >-
    {{ states('input_datetime.program_1_start') | as_datetime - timedelta(minutes=1) }}
target:
  entity_id: input_datetime.irrigation_master_start

The code is being run but the input_datetime.irrigation_master_start is unchanged. Any ideas how this should be coded?

Have you considered this? as_timestamp converts to unix time in seconds from jan 1 1970. as_datetime returns it to a datetime format.

{{ (as_timestamp(states('input_datetime.program_1_start')) - 60) | as_datetime }}

I ran this through the developer tools → template like this