How to combine two input_datetime helpers and use the result in a device_class timestamp sensor to trigger time based automations

Hello HA community,

so far I’ve always been able to solve my issues by reading the docs and searching on the forum but now I’m stuck and need some advise.

I want to create some automations for my garden watering. I have 5 different water circuits in my garden. The watering should start at a specific time and each circuit should water the plants separately (so only 1 circuit runs at a time). All water circuits should run consecutively.

I have created two input_datetime helpers. The first one defines the start date and the second input should define the duration of the watering. The second circuit should start 15:15h + 6 Minutes.

image

Start Time #2 is a sensor with the device_class timestamp (I read that it needs to be a device class timestamp sensor in order to use it as a time trigger for automations).

  - sensor:
      - name: "Start Time #2"
        state: "{{ ((state_attr('input_datetime.test', 'timestamp') | int + state_attr('input_datetime.test_2', 'timestamp') | int) | timestamp_custom('%H:%M:%S', false)) }}"
        device_class: timestamp        

The template gives me the correct time (15:21:00) but it’s not in the right format:

Log: sensor.start_time_2 rendered invalid timestamp: 15:21:00

Any help or suggestions how I can achieve that would be great!

Thank you.