Why is this timestamp template an hour off?

Need to calculate the time between these 2 scripts last_triggered’s

{{state_attr('script.notify_turn_off_early_parking_light','last_triggered')}}
{{state_attr('script.notify_turn_on_parking_light','last_triggered')}}

and trying to do so with:

{{(as_timestamp(state_attr('script.notify_turn_off_early_parking_light','last_triggered'))
- as_timestamp(state_attr('script.notify_turn_on_parking_light','last_triggered')))| timestamp_custom('%H, %M, %S')}}

or with %X

{{(as_timestamp(state_attr('script.notify_turn_off_early_parking_light','last_triggered'))
- as_timestamp(state_attr('script.notify_turn_on_parking_light','last_triggered')))| timestamp_custom('%X')}}

must be missing something b=obvious here, but can’t see it.
please help me out?

Daylight Savings time?

No, the individual times are alright, but the difference is an hour off (too much, it simply calculates the subtractions without making it a time … I’m doing the conversion incorrectly but forgot why and can’t find the answer…

edit

without the timestamp its getting better…

{{state_attr('script.notify_turn_off_early_parking_light','last_triggered')
- state_attr('script.notify_turn_on_parking_light','last_triggered')}}

results in the correct minutes and seconds, but still unformatted:

@pnbruckner what am I clearly missing…

You need to specify False for the second parameter to timestamp_custom. The default is to convert to local time, which doesn’t make sense when trying to format a difference between timestamps.

{{(as_timestamp(state_attr('script.notify_turn_off_early_parking_light','last_triggered'))
   - as_timestamp(state_attr('script.notify_turn_on_parking_light','last_triggered')))
  |timestamp_custom('%H, %M, %S', False)}}
3 Likes

Yes! Thanks. That second parameter is not always in focus… sorry for that. Will make an extra note in my cookbook.

Don’t know why but can’t mark it as solved by @pnbruckner so ill give you the explicit credits by writing it. @anon34565116 was right also in hindsight, and now understand why I didn’t see why. Never forget now. thanks!

testing:

      - service: notify.system
        data_template:
          title: >
            {{as_timestamp(now()) | timestamp_custom('%X') }}: Parking is set and safely lit.
          message: >
            {%set time = (as_timestamp(state_attr('script.notify_turn_off_early_parking_light','last_triggered'))
                        - as_timestamp(state_attr('script.notify_turn_on_parking_light','last_triggered')))
                        |timestamp_custom('%H hours, %M minutes and %S seconds', False) %}
            Some templating saved you: {{time}} of costly energy.

cool!