Sensor keywords from long JSON

Hi fellow automaters,

Full disclosure: not a lot of API and YAML experience, but I do know my way around some coding.
Haven’t been able to find a solution to something I have wanted for quite a while and I figure it’s because i’m searching in the wrong way or something.

Hope you guys want to nudge me in the right direction.

I have a data feed from a virtual flight simulator network which contains all the information about all flying pilots, their routes and available ATC on the network.

https://data.vatsim.net/v3/vatsim-data.json

I just want to filter out some data on a keyword base:

  • Show when friends are flying (search string would be their names);
  • Show when the Air Traffic Control of the airport nearby is active (search string would be the airport code).

I see a lot of REST API integrations around but it all doesn’t really seem to match the data feed as provided by this network.
And most of them are explained as creating an array.
I actually only want to pick out some data from an existing array.
Any ideas?

“jq” can be used to parse through JSON. It should installed in most all installations to parse and filter JSON. It has a really nice “playground” you can take your JSON and experiment.

https://jqplay.org/

If these can be identified by fixed names/id’s then have a look here
Json path filter - Configuration - Home Assistant Community (home-assistant.io)

You could fairly easy find friends in this JSON.
But it depends on what you want as return.

You could do something like

value_template:  >-
               {% set ns = namespace(friends="") %}

               {% for val in value_json.pilots %}
                 {% if val.name in ['Donald Duck', 'Mickey Mouse', 'Cinderella'] %}
                   {% set ns.friends = ns.friends ~ ", " ~ val.name %}
                 {% endif %}
               {% endfor %}

               {{ ns.friends }}

So if any of your Disney friends is out and flying the sensor should populate with the names of those that is out flying.

I don’t understand the second part about airport.