Rest API with JSON output

I am attempting to create sensors from an API returning JSON. I’ve attempted to use all of the variations in the RESTful Sensor doc but I cant get any variation to work.

Goal: Create a sensor returning the stats of each item in [0], [1] and [2]

Payload:

[
    {
        "eid": 123,
        "state": "enabled",
        "measurementType": "production",
        "phaseMode": "split",
        "phaseCount": 2,
        "meteringStatus": "normal",
        "statusFlags": []
    },
    {
        "eid": 456,
        "state": "enabled",
        "measurementType": "net-consumption",
        "phaseMode": "split",
        "phaseCount": 2,
        "meteringStatus": "normal",
        "statusFlags": []
    },
    {
        "eid": 789,
        "state": "enabled",
        "measurementType": "storage",
        "phaseMode": "split",
        "phaseCount": 2,
        "meteringStatus": "normal",
        "statusFlags": []
    }
]

Here is one example of what I tried.

sensor:
  platform: rest
  resource: https://127.0.0.1/ivp/meters
  verify_ssl: false
  headers:
    Authorization: !secret api
    Content-Type: application/json
  json_attributes_path: "$."
  json_attributes:
    - eid
    - state
    - measurementType
    - phaseMode
    - phaseCount
    - meteringStatus
  name: "Meters"
  value_template: "{{ value_json[0].state }}"

Even calling a specific item, nothing returns.
All I see in the log is REST result could not be parsed as JSON
Using JSONPath Online Evaluator, $.[0].state returns as expected.
The payload above is exactly what is returned when using curl.

Any ideas on how to approach this?
Is there a way to see exactly what is being returned to home assistant?

Edit: Since there is no response so far, I’ll post things I learn along the way trying to figure it out.

I found part of the problem. when using !secret with a bearer token, the secret must contain Bearer <token>, not just the token. :man_facepalming:

I was able to return data into a sensor. Everything in value_json[0] is showing as expected.

{'eid': 704643328, 'state': 'enabled', 'measurementType': 'production', 'phaseMode': 'split', 'phaseCount': 2, 'meteringStatus': 'normal', 'statusFlags': []}

Where I am stuck now is getting the individual items to show as a sensor in a group.
I thought using the above rest call I would get eid, state, measurementType, etc. as an individual sensor.

How would I go about creating a group of sensors like
values_json[0]

Production Meter

sensor.production_meter.eid 704643328
sensor.production_meter.state enabled
sensor.production_meter.measurementType production
sensor.production_meter.phaseMode split
sensor.production_meter.phaseCount 2
sensor.production_meter.meteringStatus normal

then values_json[1]

Consumption Meter

sensor.production_meter.eid 704645555
sensor.production_meter.state enabled
sensor.production_meter.measurementType production
sensor.production_meter.phaseMode split
sensor.production_meter.phaseCount 2
sensor.production_meter.meteringStatus normal

and so on?

I changed the template to

rest:
  - resource: https://10.1.1.1/ivp/meters/reports/consumption
    verify_ssl: false
    headers:
      Authorization: !secret api
      Content-Type: application/json
    scan_interval: 360
    timeout: 30
    sensor:
      - name: "Total Consumption"
        unique_id: d9275d77b9fe4ebbbf9e4efeeb3e4c40
        json_attributes_path: "$.[0]"
        json_attributes:
          - createdAt
          - reportType
          - cumulative
          - lines
        value_template: "{{ value_json[0]['createdAt'] | timestamp_local }}"

I can see all of the JSON attributes. I added this sensor however in the UI, clicking on Related, there is no association back to Total Consumption

      - name: "Total Consumption Cumulative Test Watts"
        unique_id: a2f1f04e603c45a7a2a1f66227b78d49
        value_template: "{{ states.sensor.total_consumption.attributes.cumulative.currW }}"

My goal is to relate the sensors like seen here