Importing Long-Term Statistics for the Energy Panel

I love the new energy panel and would really like to make use of it. Unfortunately, I don’t have a way of monitoring my total energy usage directly.

The good news: My electricity provider has a really nice API that lets me fetch power consumption down to the hour, for any time that I’ve been a customer. There’s years worth of data.

The bad news: Data in the API is delayed by about two days. So the current day, and the day before, are always listed as 0 kWh consumed.

I already have a custom component that can report usage for the current month, and correctly reports the last_reset date - and it works fine - but this effectively shifts all my data by about two days, and I can’t make use of the hourly readings.

I don’t actually care that much about real-time data - but I would like to compare actual usage to the devices I have in my house. So I need the dates to be synchronised.

So, the question: Is there any way for me to not use the actual sensor for power consumption, but instead backfill all the data I have available?

3 Likes

I have this exact issue. I don’t want to buy a realtime energy meter, as I really just want to see larger trends. I don’t mind importing the data from my provider’s portal, and can set up a REST sensor to grab it, but want it to be recorded with the accurate date, so that it can be compared properly with other historical data.

Is any news about it?

I think the starting point is importing this data into the history tables. Create a script that calls REST API and inserts the data into the states table in Postgres (assuming you are using Postgres). There is no facility in HA to load old data.

The second step would be to run the energy calcs on this data in the states table.