I have created an integration that scrapes energy consumption from my provider, and I would like to use this in the energy dashboard if possible.
The problem is that I can’t find any information about how the data should be stored in order to display properly. Am I just looking in the wrong place of the documentation?
My entity show up and I can select it in the Electricity grid dashboard, and I can also see it in Statistics under Developer Tools, so it’s getting stored. I just don’t know how to store it I guess.
Here is the state of my sensor to show how I store the data today.
Another issue is that I get this error message when I edit the Energy dashboard (after adding my sensor under “Grid consumption”):
The following entities have state class ‘measurement’ but ‘last_reset’ is missing:
sensor.electricity_usage
But I can’t add “last_reset” since the sensor state class is “measurement”…
Does anyone know how I should move forward with this?
I might be completely wrong, but I figure since I have the data, it should just be a matter or saving it correctly, right?
It works fine if I change state_class to total and save the last value I got from my provider as the state.
The data is useless though since the timestamp is wrong. My provider only updates the data once a day, but since I can fetch hourly breakdowns from previous days I was hoping for a way to store those with their timestamps.
Seems like the Energy dashboard isn’t for my use case.
I’d try inserting the past data directly into MariaDB (or whatever you are using for recorder). In other words make the data in the recorded look like it would if you logged each value in real time.
Yeah that seems like the only solution. I was hoping I could avoid that since I don’t really want to hack anything into the database. At the end of the day it’s all data in a database, but still. With an API you don’t have to care about the resulting data at all, which is nice.
Maybe I’ll have a go at it in the future. It might be a good way to learn more about HA.
Agree it’d be better to have the recorder support this. The way I’ve seen other systems work, is having an incoming file directory where CSV files are dropped with a specific format and then picked up. parsed and put in the database. I’d imagine there are plenty of tools out there that could do this, though it’d be a nice enhancement for the recorder as more people are trying to integrate with periodic data dumps from external databases.
I have heard that using InfluxDB instead of MariaDB may make this easier.