Statistics from mqtt sensor

Hi all,
For reasons that are not important here, I receive the readings from my DSMR smart meter via MQTT in a json string.
from this json string I create sensors like this

  - platform: mqtt
    name: E_Hoog
    state_topic: "SmartConsult/DSMR"
    value_template: "{{ value_json.hoog }}"
    device_class: power
    unit_of_measurement: W

and I can see what is happening at my SmartMeter. So far so good.
Now I want to get these readings into my Energy panel, but apparently the Energy panel is based on semsors which are storing Statics.
Question: How do I get my sensor data in the statictics are?

That is a power sensor, not an energy sensor. The Energy Dashboard only uses energy sensors.

There are many posts on the forum on how to integrate power with respect to time to get energy. Try the search.

Hi Tom,
thank you for pointing out to me that I used the wrong device class. I indeed took a wrong example for the question.
But my energy meter as well as my solar inverter deliver to me power and energy readings. this is a better expample where I get the day energy readings from my PV inverter

  - platform: mqtt
    name: E_day
    state_topic: "SmartConsult/GW8"
    value_template: "{{ value_json.E_day }}"
    device_class: energy
    unit_of_measurement: kWh

So I don’t need to know how to implement de dP/dT integration of my power readings to energy, because I get the energy readings delivered from my equipment.
I would like to now how I get my energy readings into my energy dashboard.
So if I try to configure my grid consumption it tells me that there are no matching statistics found.
So the Energy Dashboard works with statistics of energy sensors.
hence the question remains the same
How do I get my mqtt based energy readings in the Statistics area.
And the answer is here:
Statistics - Home Assistant (home-assistant.io)

I don’t think that is the correct solution. You need long-term statistics, i.e. set state_class: total_increasing on your MQTT energy sensor.

2 Likes

this helps. I seem to finally get there, as I have some data in my Energy Dash now.