there is actually a way to store historic values in ESPHome directly:
- Create a globals array
- In the sensor statement, update that array with an on_value statement
- Use the array values to print historic values.
Please be aware that arrays in ESPHome are barely documented… 
Here are some code sniplets that worked for me:
globals array
globals:
- id: myhistory
type: float[10]
restore_value: no
initial_value: "{'0','1','2','3','4','5','6','7','8','9'}"
sensor statement filling historic values on_value updates
sensor:
- platform: homeassistant
id: mysensor
entity_id: sensor.whatever_sensor_you_have
internal: true
on_value:
then:
- lambda: |-
for (int i = 9; i > 0; i--) {
id(myhistory)[i] = id(myhistory)[i-1];
}
id(myhistory)[0] = id(mysensor).state;
This worked well to show some historic values on an M5 stack.
I will try some custom c++ code for some minigraphs next.