Consuming API results in JSON with no dictionary keys?

The good people of this community have helped dozens of users get the rest integration working by assisting them with formatting their YAML with stuff like json_attributes and json_attributes_path. The question today is what do we do when the API returns something like the result below? I don’t really have a dictionary for each field. Instead it’s just a series of nested arrays. The key for what each row means (rows 0-16) is only provided in the API documentation.

In a perfect world, I would use the first row of each grouping as the sensor state with all subsequent rows an attribute to that state. (Admittedly, I don’t even care if the “key” was just “0”, “1”, “2”, etc. I could sort that out on the frontend.)

Any ideas? Thanks!

{
  "time": 1657259235,
  "states": [
    [
      "ac75ee",
      "AAL1449 ",
      "United States",
      1657259234,
      1657259234,
      -79.8719,
      36.3416,
      6797.04,
      false,
      220.14,
      218.26,
      -8.13,
      null,
      7223.76,
      "3435",
      false,
      0
    ],
    [
      "ab115d",
      "MTN8505 ",
      "United States",
      1657259063,
      1657259067,
      -79.8938,
      36.0061,
      1478.28,
      false,
      128.71,
      32.93,
      -8.13,
      null,
      1516.38,
      null,
      false,
      0
    ]
  ]
}

PS - Yes. This is opensky network’s flight data. The API would work better for me than the integration. (The integration gives me hope that this problem is solvable. Someone else did it!)

Edit: In case I’m missing something obvious, here’s a link to the API documentation: OpenSky REST API — The OpenSky Network API 1.4.0 documentation

Would be interested too but no clue in a direct way so maybe someone else has the answer…

Indirect you could create sensors for each section, the state is then populated with all attributes
From there on you can create a secondary template sensor using these to extract attributes, or … use some automation to update attributes of the initial sensor with some script

1 Like