Hey there,
It’s my first time trying to hack together a custom integration (which I’ll eventually intend to share on the community store, but it’s too hacky so far).
It’s a relatively straightforward idea: my electricity provider provides a web interface for historic consumption data (kWh in 15min intervals). Unfortunately, there’s a significant delay in the data (multiple hours).
So my plan was to build on top of GitHub - klausj1/homeassistant-statistics: This HA integration allows to import long term statistics from a file like csv or tsv to import historic values. I understand that the long term statistics are only possible with hourly resolution, and I’m okay with that (I simply combine all entries of an hour up to just one entry). But the result of my code is something weird…
As you can see, the entries somehow start at the 26th minute, not the 0th minute. This is thoroughly confusing me. Furthermore, no matter what I try with setting sum and state and last_reset on the StatisticsData, what I end up with in the energy dashboard is a whole load of nonsense:
I’m frankly lost with this. There’s not a single negative state (I don’t produce electricity. It’s all consumption from the grid) in the data, yet the energy dashboard thinks there is??
I’m hoping for a miracle that somebody here encountered something similar before and can point me to the right direction. I’m sharing my code just in case, but beware: it’s a mess, as I’m a bit out of my comfort zone with python and the magic in the home assistant code base (I would have expected quite a bit more “hooking things up”, but apparently with the right method and file names(??) magic happens).
Here are the relevant code pointers:
adding statistics
entity
Any help is greatly appreciated.
Best regards,
Stefan