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…
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.
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.