History Statistics Sensor customization

Hi, I have just discovered the history statistics sensor and want to use it to display the on-time of a switch. But I don’t like the time format (hours) it displays. Therefore I used a template sensor to have it in minutes.
What it shows now:
Switch1 5m
Problem is I can’t figure out how to customize the unit. Should be looking something like this:
Switch1 5 Minutes

Does anyone now how to achieve that?
Thanks a lot!

My code is:

  • platform: history_stats
    name: history_stats_switch1
    entity_id: switch.switch1
    state: ‘on’
    type: time
    end: ‘{{ now() }}’
    duration:
    hours: 24

  • platform: template
    sensors:
    stats_switch1:
    friendly_name: Switch 1
    icon_template: mdi:av-timer
    value_template: ‘{{ states.sensor.history_stats_switch1.attributes.value }}’

add below value_template. This will only wrok if states.sensor.history_stats_switch1.attributes.value is a number. If it’s a string, its not going to do anything.

units: Minutes

Hello, there is a way to set the history states to display the values, meaning format the states in order to display the time
e.g. 6:21h ->6h:12m

Thank you in advance.