Formatting "Remaing Time" Sensor to only show hours and minutes

I am trying to convert a sensor from showing “hours:minutes:seconds” to show “hours:minutes”
This might be very straight forward but I cant find the right solution and would be very greatful for any help.

This is how far I got:

- platform: template
  sensors:
    waschmaschine_verbleibende_zeit:
      friendly_name: "Waschmaschine verbleibende Zeit"
      value_template: "{{ state_attr('sensor.waschmaschine', 'remain_time') | timestamp_custom('%H:%M', false) }}"

In the dev-tools, I get the following error:

ValueError: Template error: timestamp_custom got invalid input '2:52:00' when rendering template '{{ state_attr('sensor.waschmaschine', 'remain_time') | timestamp_custom('%H:%M', false) }}

Thanks a lot!

"{{ state_attr('sensor.waschmaschine', 'remain_time').split(':')[:-1] | join(':') }}"

for error trapping…

      value_template: >
        {% set t = state_attr('sensor.waschmaschine', 'remain_time') or '0:0:0' %}
        {{ t.split(':')[:-1] | join(':') }}
1 Like