Energy dashboard does not find my energy statistics

I really don’t understand what is going wrong with my energy statistics.
I have a Current Cost Envir monitor with 3 current clamps. I pick the data up using RTL433 and it all works beautifully. I have just tried to set up the energy dashboard using the example in the Rieman Integral doc and got nothing. Then realised I was using w instead of W in the sensor and briefly the the statistic showed up. The following day nothing is showing and no statistic are found.
I made a few minor changes along the way because no data was appearing and I must have screwed something up.
Please can someone help me understand what I have done wrong.

My sensors are:

- platform: integration
  source: sensor.CC_Power_0
  name: house_energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.CC_Power_1
  name: solar_energy
  unit_prefix: k
  round: 2

- platform: mqtt
  name: "CC_Power_0"
  state_topic: "/CurrentCost-TX/3311"
  value_template: '{{ value_json.power0_W }}'
  unit_of_measurement: "W"
- platform: mqtt
  name: "CC_Power_1"
  state_topic: "/CurrentCost-TX/3311"
  value_template: '{{ value_json.power1_W }}'
  unit_of_measurement: "W"

The state of the entity is:

state_class: total
source: sensor.cc_power_0
unit_of_measurement: kWh
icon: mdi:chart-histogram
friendly_name: house_energy

Go to Developer Tools / Statistics.

Are there any issues there you can fix?

Also try adding device_class: power to your power sensors and device_class: energy to your energy sensors, you will have to use customize for that last one.

Thank you so much for providing such a simple fix to something that had become truly frustrating. It was adding the device class of energy that worked. Everything now works nicely and I can see how the panels are doing vs forecast.

I tried to add the device class yesterday but got the error that it wasn’t allowed. Your suggestion to use customize did the trick. Not being an intuitive coder I really don’t understand why that is necessary. It seems so messy.

The new template integration supports state_class but it has not been added to the legacy template sensor platform (thus the need to use customize). It’s one good reason to start using the new integration.

Hi! I am sorry for posting in such an old topic but I think I have a related question.
I have a Homey hub which allows me to connect, among money others, z-wave devices to it. I have a smart plug with power and energy measurement connected to it. I do not have a Z-wave dongle for my HA setup.
I can expose the device and its 3 entities to HA using MQTT. This lets me turn it on/of, read out the power and energy use. I would like to add the reading from this device to the energy dashboard but it does not appear on the list of entities. I can however add it as a card to my other dashboards and get correct readings.
Is there any way around it? I understand that HA cannot track statistics for this entity as per: Expected data source not listed - Home Assistant but can I do anything about it?

I would greatly appreciate your help!