We just turned december and my last imported gaz consumption was on November 24th, so I have 6 days that are going to count towards consumption in december, which is very annoying as it will make comparing november and december consumption with the previous year invalid.
My gaz distributor did a maintenance/upgrade of his website and while the web grabbing method still worked, the data on the site was not updated over the period - it was just updated today, december 1st.
I noticed that when I added my water meter to the energy dashboard - a function that was recently added - all historical data is available in the energy dashboard - it goes back to june:
So importing historical data was possible for add a water meter to the dashboard.
It should be possible to add meter values to the database at a given date, not just for “now”. That would allow importing long term historical data, or cope with the unavailability of data from the energy provider for whatever reason.
I just wanted to add my wish for making import and export CSV specifically for energy history, available on the GUI. There’s quite a few edge cases where someone may want to either start from scratch but simply retain energy history, or move energy history around different installs easily.
I know it’s do-able via APIs, SQL, whatever, but adding CSV import and export via gui would be real nice. I’ve already had three experiences in 18 months of losing history and having to recover, so for those less able it would also be quite reassuring to have the data tangibly accessible and recoverable.
On the import it could possibly have import (sum) and import (replace) for example. Or mapping fields to existing or new datasets. It could get complex!
I’m interested in this topic too and I have some code that you may find useful.
“Historical Sensors” it’s a helper module to build sensors with historical data. It has the necessary code to import data but the UI for uploading and importing CSV files is still missing. Once it’s figured out how to present the UI it should be trivial.
The ‘delorian’ integration it’s just a test demo for the module, there is no integration ‘per-se’ in my project
The delorian integration depends on homeassistant-historical-sensor module so you have to install the module in the venv of homeassistant running pipenv install -e . or whatever suits you.
Anyway, I have made some changes to make delorian pull homeassistant-historical-sensor from github.
As interesting as this is, i’d LOVE to get a detailed writeup on how to use this websocket API call, so i can write a method to interact with it. I don’t see any documentation on what it expects, examples of usage, anything.
I think Spook is the only way to do this.
It has been a long standing decission by developers that import of historic data was not something they wanted to go into.
Frenck has therefore added it to the Spook integration instead, but I guess this is done by a direct SQL call and not through some API that will be available elsewhere.
So after a few days, i finally figured out why i wasn’t getting this service call… I forgot to actually ADD the spook integration (i added it in HCAS, but forgot to do the integration piece). I can now see the screenshot provided above, and the notes in the “Statistics” field tell me what i need to know.
However, i still have questions about the Statistics ID and Source. I believe i can just use my energy sensor, is this correct? Will this overwrite my existing data (not the worst outcome), or create a new entity? Is the “Source” a random field?
The “Has a mean”, “Has a sum” and "Unit of measurement or simple enough to ascertain, as well as what to provide with statistics. I just don’t want to kill my existing database with non-sensical data.
I created a script that can import historical data from the Dutch energy provider Eneco with their Toon thermostat.
The script should be easily adaptable for other providers that use a different export format. The processing logic to change the statistics stays the same.
I got the stats loaded using the websocket recorder API. However, the following morning HA shows a return of the same cumulative amount to the grid. Why is that? I have no sources feeding energy data to HA apart from what I sent.
It’s not really documented, hence the nature of the spook tools, but here’s a sample working data for the service recorder.import_statistics. Seems that you still may need to do more data manipulation once you call this service, but hopefully this can get you started.