Calculate cumulative total sensor from daily total sensor

I’m using the Daikin Residential integration which reports the daily, monthly and yearly energy usage in kWh.
This is great, but in order to use and track them in the new Energy dashboard I’d like to have an ever increasing total sensor. But… this is more difficult than I had hoped. The daily, monthly and yearly totals reset every night (and not at precisely 00:00 but at a random time slightly later than that, such as 00:01).

In essence, lets say these are the reported values for the daily sensor:
day 1 00:05:00 1kWh
day 1 12:05:00 2kWh
day 1 23:55:00 5kWh
day 2 00:01:00 0.5kWh
day 2 15:50:00 4.5kWh

Then the resulting total sensor should become:
day 1 00:05:00 1kWh
day 1 12:05:00 2kWh
day 1 23:55:00 5kWh
day 2 12:05:00 5.5kWh
day 2 23:55:00 10kWh

Can anyone give any pointers to how I would go about and create this total sensor? Or maybe a different suggestion that removes the need for the sensor?

Thanks!

I looked into that, but that seems to do exactly what I don’t want.
I already have the daily, monthy, and yearly cycle and want to exact opposite of that: not a cycle :smile: .

Did you solve this? I’m in the same boat. I have hourly usage data and want to keep a running total. I could do it in node-red easily but it’d be easier if there’s a sensor built into HA. I’ve seen references to the Integration sensor, but this seems like a estimation of a curve whereas we have the exact values to sum.

Same here for PV energy meter. I do have a total, but it is reporting every 1kwh, so I got false looking graphs in case of cloudy or mixed weather.

I was thinking of creating a template sensor with condition but I am not sure how to increment the value ( as reference one is resting to 0 every day )

i did it like this;
in my case when PV is off the sensor becomes unavailable. you can try with 0 as a value in your case.

create 2 input.number helpers: pv_today, pv_total and create automation on the sensor:

alias: pv_total
description: ''
trigger:
  - platform: state
    entity_id: sensor.solis_energy_today
condition:
  - condition: template
    value_template: >-
      {{ trigger.to_state.state in [trigger.from_state.state, 'unknown',
      'unavailable'] }}
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.pv_total
    data:
      value: >-
        {{ states('input_number.pv_total') | float +
        states('input_number.pv_today') | float }}
  - service: input_number.set_value
    target:
      entity_id:
        - input_number.pv_today
    data:
      value: 0
mode: single

alias: pv_today
description: ''
trigger:
  - platform: state
    entity_id: sensor.solis_energy_today
condition:
  - condition: template
    value_template: >-
      {{ trigger.to_state.state not in [trigger.from_state.state, 'unknown',
      'unavailable'] }}
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.pv_today
    data:
      value: '{{ states(''sensor.solis_energy_today'')  }}'
mode: single

then in config calculate the total kWh

sensor:
  - platform: template
    sensors:
      solis_energy_total_kwh:
        value_template: "{{ states('input_number.pv_today') | float + states('input_number.pv_total') | float }}"
        unit_of_measurement: 'kWh'

and customize sensor to fit into energy dashboard:

  customize:
    sensor.solis_energy_total_kwh:
      device_class: energy
      state_class: total_increasing
      last_reset: '1970-01-01T00:00:00+00:00'
1 Like