Influx sensor for historical energy data

I am trying to read some energy data into a sensor in Home Assistant from InfluxDB (2.x.x) to display it in the energy dashboard. Somehow, I am not getting the syntax right, and find it difficult to know what the errors are. Hope someone here can guide me a bit, what I have so far:

sensor:
  - platform: influxdb
    api_version: 2
    organization: XXX
    token: !secret token
    host: !secret local_ip
    port: 8086
    ssl: false
    bucket: ctc/autogen
    queries_flux:
      - name: heater_effect
        range_start: "-1d"
        unique_id: influx001
        unit_of_measurement: W
        query: >
          filter(fn: (r) => r["_measurement"] == "electric power")
          |> filter(fn: (r) => r["_field"] == "Heater")
          |> keep(columns: ["_value", "_time"])

The data is read into the influxdb database in batches from a USB stick (logging my CTC EcoZenith heater) manually at varying frequency.

If I query it without the range_start variable it will populate the HA sensor with the latest value from the database (but no historical data will show).

If I query it with range_start: "-1d" it will populate the home assistant sensor with yesterdays data as a starting point and add data that are 24 hours offset continuously until there are no more data in InfluxDB.

Is it possible to populate a HA sensor with historical data at all?

Did you ever get anywhere with this? I’m trying to do something very similar - reading into Influx in batches and wanting to bring it into Home Assistant.

No my use case changed so I didn’t need it anymore