I want to show the community this module:
https://github.com/ldotlopez/ha-historical-sensor
This module feeds historical data into Home Assistant database and is meant to be used by integrations implementing sensors that cannot use real time data but can provide historical (and useful) data.
HomeAssistant architecture is built around polling (or pushing) data from devices, or data providers, in “real time”. Some data sources (e.g, energy, water or gas providers) can’t be polled in real-time or readings are not accurate. However reading historical data, like last month’s consumption, it’s possible and accurate. This module adds support to this.
This code was developed initially for the “i-de energy consumption integration” and has been tested for over a year. During that time I added some features like statistics generation for the “historical sensors” and I have planned some features like importing data from CSV files.
Within the code there is also a very simple custom integration to show how to use this module.
I have read some discussions on these forums about similar needs and I think that this project may be interesting for the community.
Hoping for comments, suggestions and contributions!