Total_increasing sensor not working as intented

I currently obtain the value of daily consumption from a device. I want to create a sensor to obtain the increasing value of the daily consumption.

  - sensor:
    - name: "Venta de electricidad (total) v3"
      unit_of_measurement: 'kWh'
      device_class: energy
      state_class: total_increasing
      state: >-
        {{ states.sensor.homekit_91000hku21501076.attributes.Charts_sell }}
    - name: "Compra de electricidad (total) v3"
      unit_of_measurement: 'kWh'
      device_class: energy
      state_class: total_increasing
      state: >-
        {{ states.sensor.homekit_91000hku21501076.attributes.Charts_buy }}       

Problem is that the created sensors give exactly the same information as the original sensors. What I mean is that even when stating total_increasing the created sensors reset daily to 0. On developer tools/states both sensors are stated as total_increasing.

If anyone has any advice please tell. I don’t know where to look for the problem. Thanks.

This is an example from my powerplugs, you could also try to add a rieman integration via the settings > devices > add rieman …

  - platform: template
    sensors:
      gosund_1_consumption:
        friendly_name: "GosundPlug1 current consumption"
        unit_of_measurement: 'W'
        device_class: power
        value_template: "{{ states.switch.gosundplug1.attributes.current_consumption }}"
  - platform: integration
    source: sensor.gosund_1_consumption
    name: gosund_plug_1
    method: left
    round: 2
    unit_prefix: k

I believe thats not exactly my problem.

states.sensor.homekit_91000hku21501076.attributes.Charts_sell already gets me the total (kWh) by day (resets daily). Im just looking to make a new sensor that doesn’t reset daily but keeps adding.

That is the other one…the INTEGRATION sensor

I dont need the integration, I already have energy (kWh) and not power (kW) so no point in using the integration. I do use the integration for other things to get the energy from a power sensor but thats not what I need here.
I need to create a total_increasing sensor (kWh) from a total sensor (kWh) that has a daily reset.
Thanks

I see, missed this point and will withdraw then as no experience myself, sorry for my misunderstanding

Are you recording this item in your database? If you’re using a default config, then you are. Just double checking.

1 Like

Thanks for confirming my suspicion. Its the next thing I was going to try. Lets see if it doesn’t reset today.

states.sensor.homekit_91000hku21501076.attributes.Charts_sell isn’t being recorded on database as its part of an “array” of data thats constantly changing and being updated through URL. I created a new normal sensor from states.sensor.homekit_91000hku21501076.attributes.Charts_sell to then create the total_increasing sensor from this new normal sensor. Hoping it works.

Thanks!

you don’t need states.sensor.homekit_91000hku21501076.attributes.Charts_sell in the database, just the template sensor. Then you have to wait until you have data.

As I was interested in this setup for a near future other project, I tried to the same, i.e. summing up the consumption of my power plug and I see the same unexpected behavior as above…only the current not a increasing value…odd, also no errors
configyaml has default_config: in it
my sensor:

- name: "GosundPlug1 Total Increasing"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: "{{ states.switch.gosundplug1.attributes.current_consumption | float(0) | default(0) }}"

the value doesn’t increase on the sensor, it only shows in the energy panel and long term stats.

So similar as an integration sensor with rieman integral?
Is there another way to have a total increasing sensor that resets daily…i.e. not necessarily related to energy?

there’s a long term stats card that can display long term stats

Hmm… but what if I want to accumulate a value and act on that if it surpasses a certain level?
Edit, I have seen trickeries (not meant to undervalue them) like this but that is a workaround
Calculate cumulative total sensor from daily total sensor - Configuration - Home Assistant Community (home-assistant.io)

Or, I could use a second object alike input_number Total and then a update input_number state using its current state and the value of the source sensor

You have many options:

utility meter
statistics
history statistics
sql

OK…will dig in… reading = learning, thanks :slight_smile: