Questions about making a runtime display for a device

I would like to create a running time display in the dashboard for my gas boiler.

I once managed to create template sensors that show me the runtime in hh:mm:ss.

But - I can only manage to add up the running time.
I would like the running time to start again at 00:00:00 every time the boiler start up.
It would be nice if I could save the runtime values, but I think I should also find out about doing that via the history.

What I would also like to have is a higher refresh rate. Currently the counter is only updated every 60 seconds.

And finally I would like to combine the gauge card with the hh:mm:ss display.
So gauge display but hh:mm:ss as values ​​and not 0.xx as hourly value.
Like in the picture montage here:
soll

I tried to use information from various posts for my project.
These are the templates that I created in the configuration.yaml:

- platform: template
    
      sensors:
        laufzeit_therme_rounded:
            friendly_name: "Laufzeit Therme Stunden-Minuten gerundet"
            unique_id: "history_laufzeit_therme_rounded"
            value_template: >
                {{ (timedelta(hours=states('sensor.laufzeit_therme') | float(0)) | string)[:-7] }}


    - platform: history_stats
      unique_id: "history_laufzeit_therme"
      entity_id: switch.og_bad_therme_schalter
      name: history_laufzeit_therme
      state: 'on'
      type: time
      start: '{{ as_timestamp( now().replace(hour=0).replace(minute=0).replace(second=0)) }}'
      end: '{{ now() }}'
Why I want to do this:

All my radiators are smart and influence the control of the gas boiler.
My experience is that the gas boiler runs on average twice a day for 2-2.5 hours.
However, it has happened a few times that the gas boiler runs longer if, for example, a temperature sensor is stuck.
That’s why I want to know at a glance how long the gas boiler has been running since it was last switched on.
I’m currently doing this with a workaround and automation and showing how many quarters of an hour the gas boiler has already been running.
This serves the purpose, but a running time counter in hours and minutes obviously looks more elegant. :slight_smile:

I can also use the running time counter for other areas, for example when cooking, as my stove and oven are also smart. As well as a dishwasher and washing machine.

Thank you in advance for your help!

I did something similar, so maybe this will help you.

I have an automation that checks every minute if the heat pump is generating hot water and increments the value of an input_number if it is. At the end of each day, I update a sensor based on the total value and reset the input_number. This means the input_number always holds the amount of time the heat pump has been generating hot water during the current day and the sensor tells me the daily total. You could adjust this to reset the input_number each time the boiler turns off and update once a second in your case.

I hope that’s helpful.

-David

@dbs
Thank you for your hint!

I never thought in that way. :slight_smile:

I made a Helper which store the runtime in Seconds.
I also made a Sensor in my configuration.yaml which convert the Helper into a hh:mm:ss value.

      sensors:
      
        therme_laufzeit_template:
            friendly_name: "Therme Laufzeit"
            unique_id: "therme_dlaufzeit_template"
            value_template: >
              {{ (states('input_number.laufzeit_therme')|int) | timestamp_custom("%H:%M:%S",0) }}    

Now I only have to find a Gauge that can visualize the Runtime.
At the moment I’m experimenting with the Horseshoe Card because it can show the Gauge from the Seconds and show the hh:mm:ss from the template Sensor.

The only thing I didn’t get to work yet is the gradient color in the Gauge depending on the value.
I tried evry horseshoe_style parameter but nothing works in that way I want it.
It ignore the Colorsteps and only show the color of the max value.

Bildschirmfoto vom 2023-09-26 22-41-26

type: custom:flex-horseshoe-card
entities:
  - entity: input_number.laufzeit_therme
    decimals: 0
    unit: ' '
  - entity: sensor.therme_laufzeit_template
    decimals: 0
    unit: ' '
show:
  horseshoe_style: autominmax
  scale_tickmarks: false
layout:
  states:
    - id: 1
      entity_index: 1
      xpos: 50
      ypos: 60
      styles:
        - font-size: 3.0em;
horseshoe_scale:
  min: 0
  max: 15000
  width: 16
color_stops:
  '0': '#006400'
  '1800': '#008000'
  '3600': '#228b22'
  '5400': '#32cd32'
  '7200': '#7cfc00'
  '9000': '#ffff00'
  '10800': '#ffd700'
  '12600': '#ff8c00'
  '14400': '#ff0000'

Here’s how I show it, using the standard history card: