Template history_stats hours minutes

Hi Iam using hassio I would like to see in different format the time, but I could not set the right template, maybe somebody can help on this.

The time is show in this fromat : 2.41 h, but I would like to see in this format 2:24
Is that posibbile to write sach template ?

  • platform: history_stats
    name: Boiler On Duration
    entity_id: switch.boiler
    state: ‘on’
    type: time
    start: ‘{{ now().replace(hour=12).replace(minute=0).replace(second=0) }}’
    duration:
    hours: 24
    value_template: '{{ states.sensor.boiler_on_duration.attributes.value }}

Capture

Thx !

Did you ever resolve this?

I have the same problem…

Not yet :frowning:

sensor:
  - platform: template
    sensors:
      time_at_work_rounded:
        value_template: "{% set hours = states('sensor.time_at_work') | float %} 
        {% set minutes = ((hours % 1) * 60) | int %}  
        {% set hours = (hours - (hours % 1)) | int %}  
        {{ '%02i:%02i'%(hours, minutes) }}"

this works for me now

2 Likes

Thx for the script

Also works for me

1 Like

Thx was looking for readable time format as well.

1 Like