How to calculate energy from this power sensor (why is the output way too low...)

using an electric heater (Mill) that only provides a current power sensor, I need a way to calculate its daily energy consumption.

So, I figured to create an integration helper entity, and that actually updates, but it can not be correct…

according to this, it has used about 0.16 kWh today.

the Utility meter entity I set up for that also reflects that:

This is way off… considering it consumes 1200 W and has been on for a couple of hours.

should be something like this:

11:18-11:42 = 24
12:32-12:51 = 19
13:31:14:05 = 34
14:41-15:06 = 25

102 min * 1200 = 1.7 hr *1200 = 2040 = 2,04kWh

What could possibly be the reason for this Integration entity to not calculate correctly? Somehow I get the feeling it restarts at every period resetting at 0.
I am looking for a total life time sensor, that never resets. It currently is listed to have state_class: total

Not even sure that is correct, because I need this:

Total increasing:

Similar to total , with the restriction that the state represents a monotonically increasing positive total which periodically restarts counting from 0, e.g. a daily amount of consumed gas, weekly water consumption or lifetime energy consumption.

it’s impossible to edit the options in the Integration entity, other than its output, but in entity_registry nothing special is configured:

      {
        "aliases": [],
        "area_id": null,
        "capabilities": {
          "state_class": "total"
        },
        "config_entry_id": "ae6c779ba472f6c64eb89335b5b8917c",
        "device_class": null,
        "device_id": null,
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "sensor.heater_office_energy",
        "hidden_by": null,
        "icon": null,
        "id": "46d49bae70ab00c2b3f8161ae2e8532d",
        "has_entity_name": false,
        "name": null,
        "options": {},
        "original_device_class": null,
        "original_icon": "mdi:chart-histogram",
        "original_name": "Heater Office energy",
        "platform": "integration",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "ae6c779ba472f6c64eb89335b5b8917c",
        "unit_of_measurement": null
      },

and I probably have set all defaults, as we get them upon creating a new entity:

Maybe check in core.config_entries if you are using the correct source for the integration?

yes, I also did that, and, I created a second entity.

      {
        "entry_id": "1ccd73aed62c28d3e71426a8ef726740",
        "version": 1,
        "domain": "integration",
        "title": "Heater Office energy spent",
        "data": {},
        "options": {
          "name": "Heater Office energy spent",
          "source": "sensor.heater_office_current_power",
          "method": "trapezoidal",
          "round": 2.0,
          "unit_prefix": "k",
          "unit_time": "h"
        },
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": null,
        "disabled_by": null
      }

compared to the original:

      {
        "entry_id": "ae6c779ba472f6c64eb89335b5b8917c",
        "version": 1,
        "domain": "integration",
        "title": "Heater Office energy",
        "data": {},
        "options": {
          "name": "Heater Office energy",
          "source": "sensor.heater_office_current_power",
          "method": "trapezoidal",
          "round": 2.0,
          "unit_prefix": "k",
          "unit_time": "h"
        },
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": null,
        "disabled_by": null
      },

and I did set it to be K prefix, (couldnt check that in the helper UI…)

Ofc, from that moment on, the existing entity started counting properly, and the new entity showed the same increase.

Which made me think, there’s another issue with the source. Mill integration has a tendency to lose connection. And, even though I configure it to be local, it might wel be that upon those reconnects, entities get corrupted (reset)… not sure, just trying to figure out why now.

What would you say about that state_class though? Given the fact the integration is supposed to create ‘lifetime’ sensors?

Generally, it’s suggested to use “left” for those sensors that goes from 0 to max and back to 0.

The state class is set by the Rieman integration. It will never go back to zero, so total is the correct one, I think.

1 Like

ok thanks, will add another with ‘left’ method, to see what the difference would be.

meanwhile I found that adding ‘cloud’ sensors to the Mill integration creates actual daily and yearly energy consumption sensors…

Always figurered it to be an issue with my ‘local’ configuration, not having energy sensors.

Apparently we can configure both, and need local for the power sensor, and cloud for the energy sensors…