Help with Automation time helper input_datetime.set_datetime (DST trouble)

Hi, i am working on a new automation, among the various things he will have to do, I need him to add time to a time helper. For now everything is ok but I realized that the code I wrote does not reflect the Daylight saving time (DST):

alias: Gestione luci stanzetta
description: ""
trigger:
  - platform: state
    entity_id:
      - input_datetime.luce_on
condition: []
action:
  - service: input_datetime.set_datetime
    data:
      datetime: >-
        {{ (state_attr('input_datetime.luce_on', 'timestamp') + 60 ) |
        timestamp_custom ('%Y-%m-%d %H:%M:%S') }}
    target:
      entity_id: input_datetime.luce_off
mode: single

In this case if i set input_datetime.luce_on to 09:00 the input_datetime.luce_off become 10:01
A workaroud that i have tried is to subtract 3600 seconds:
{{ (state_attr(‘input_datetime.luce_on’, ‘timestamp’) + 60 - 3600 )
But it seems to me a dirty solution, I wondered if there was a way to calculate the DST period in a cleaner way.

Thank you

I think if you use the time_date integration, the time will be based on the timezone in your General Configuration, so daylight saving time will automatically be taken into account.

How i can use time_date in my situation? Working with time and templates is a bit hard for me :frowning:

Aargh! Me too! :roll_eyes:

In this way seems to work very well.

{{ ((strptime(states('input_datetime.luce_1_on'),
                '%H:%M:%S').timestamp() + 18*3600 + (utcnow().timestamp() -
                now().timestamp())) + 1) | timestamp_custom('%Y-%m-%d %H:%M:%S',
                true) }}