Energy 22.10.0

I’m trying to get the energy section working. I have an Api that every minute returns my kWh usage. I’ve stripped down the JSON to a Value 1234567. Every minute the Api updates the value, and then it increases 1234568. Ive tried to create an Rest sensor, that I can add as energy Usage.

But it gives me two errors. A missing statistic, and non numeric value

statistics_not_defined
* sensor.total_energy_1

Entity has non-numeric state
The following entities have a state that cannot be parsed as a number:
* sensor.total_energy_1

My sensors value are :

state_class: total_increasing
value: 12251159
unit_of_measurement: kWh
device_class: energy
friendly_name: total_energy_1

The complete coded is:

- platform: rest
  resource_template: XXX
  headers:
      Authorization: token XXXX
      User-Agent: Home Assistant
      content-type: "application/json"
  method: GET
  name: total_energy_1
  unique_id: total_energy_1_1
  value_template: "{{ value_json.results[-1:].value }}"
  json_attributes_path: "$.results[-1:]"
  json_attributes:
    - results
    - value
  scan_interval: 60
  device_class: energy
  state_class: total_increasing
  unit_of_measurement: kWh

Any ideas what I may have done wrong here ?

The JSON returned is formatted like this, with a section for every minute since midnight

{
    "previous": "http://XXX/?date=2022-10-05",
    "results": [{
        "unit": "impulse",
        "displayUnit": "impuls",
        "value": 12247107,
        "timestamp": "2022-10-06T00:00:03Z"
    }, {
        "unit": "impulse",
        "displayUnit": "impuls",
        "value": 12247111,
        "timestamp": "2022-10-06T00:01:03Z"
    }, {
        "unit": "impulse",
        "displayUnit": "impuls",
        "value": 12247115,
        "timestamp": "2022-10-06T00:02:03Z"
    }, {
        "unit": "impulse",
        "displayUnit": "impuls",
        "value": 12247118,
        "timestamp": "2022-10-06T00:03:03Z"
    }, {
        "unit": "impulse",