Run time of automation

I am trying to add a run time to a notification for my washer, like 0:38:01. I have the following…

{{ ((states.automation.Washing_Machine_Finish_Notification.attributes.last_triggered)-(states.automation.Washing_Machine_Start.attributes.last_triggered)) }}

which gives me 0:38:01.291218, and this is great, but is there a way to remove the milliseconds? And just give 0:38:01?

And I can get…

'{{ as_timestamp(states.automation.Washing_Machine_Start.attributes.last_triggered)  | timestamp_custom("%H:%M:%S") }}'

'{{ as_timestamp(states.automation.Washing_Machine_Finish_Notification.attributes.last_triggered)  | timestamp_custom("%H:%M:%S") }}'

to show


But cant seem to get this to subtract with these values.

Would this not be easier?

{% set mystring = (states.automation.Washing_Machine_Finish_Notification.attributes.last_triggered-states.automation.Washing_Machine_Start.attributes.last_triggered) | string %}
{{ mystring.split(".")[0] }}

1 Like

Two great solutions, I will be using both but the second is exactly what I want, thanks!!!