How to retain an accumulated value untill i reset it manually

Dear all,

I have a shelly switch which is behind a heating device. The switch is triggered in a specific case and will swith off if certain values are met.
I want to calculate the minutes this switch has been on. I want to retain that data in a way untill i decide to reset that value.
I already created a sensor that is calculating the minutes per day the device was on. At midnight this data is reset.
How do i save this value and where? I want to be able to see over a period of time howlong the device was actually on, so i want to see accumulated data over time.

I hope someone can help me on this!

Marcel

Are you using the History Stats integration to track your on time?

If so share your config for it.

You can use an input_datetime helper in the start time template. Set the end time as now().

This way you can set the input_datetime to now() either manually or with a script called by a button to reset it.

Hi Tom,

I have created the following Sensor which is holding todays value of minutes the switch was on.

  • platform: template
    sensors:
    kachel_minutes:
    friendly_name: “Kachel Minutes”
    entity_id: sensor.kachel # Replace with the actual entity_id of your history_stats sensor
    value_template: “{{ states(‘sensor.kachel’) | float * 60 }}”
    unit_of_measurement: ‘min’

Can you help me further in retain this value before this sensor will get it’s reset before midnight and keep this value accumulated untill i decide to reset.

Many thanks so far!