Populating sensor history

I have added a few sensors to show temperature differences.
This works well enough.
What I would like to do now is generate and store corresponding values of utility_temp_diff from the existing history of t1_temperature and t2_temperature - going back 30 days.

Looking at the History REST API, it looks like you can only post a current value?
(Of course, in 30 days time this will no longer be a problem as the history will be populated!)

template:
  - sensor:
      - name: "utility_temp_diff"
        unit_of_measurement: "°C"
        unique_id: ukd
        state: >
          {% set utility = states.sensor.t2_temperature.state|float %}
          {% set kitchen = states.sensor.t1_temperature.state| float %}
          {{ utility - kitchen|float (1) }}

You could toy with the idea of writing to the database directly (by writing sql), or do the sensible thing and look away for 30 days (is your purge_keep_days really 30?).

I have created old long-term-statistics records with success, but wouldn’t touch inserting records into the states table. This is because there are interdepencies on these records, and the table structure is more complex.

Note that to get long term statistics you will also have to set state_class to something (“measurement” in your case).

Thanks @michaelblight for your reply. Yes I have 30 days keep. The aim is to see if my improved loft insulation is working, or where it needs improving, by placing thermometers in different rooms around the house.
The other possibility I could try is to export the database into a spreadsheet and play about with it there (just thought of that as I write this!)