OpenSky REST API - Template Sensor

Hi there

I managed to get the data for aircraft of interest, c.f.: in configuration.yaml

sensor:
  - platform: rest
    name: JSONOpensky
    username: !secret opensky_username
    password: !secret opensky_password
    scan_interval: 150
    json_attributes:
      - states
    resource: https://opensky-network.org/api/states/all?icao24=3c6444&icao24=4066cf&icao24=48c5e7&icao24=4d2251 
    value_template: "{{ value_json.opensky }}"

If any of those three aircraft is airborne I get data, e.g.

Question:
How to get out of those comma separated data single values into single sensors? Something like this does not work for me.

  - platform: template
    sensors:
      states0:
        friendly_name: opensky0
        value_template: "{{ states('sensor.opensky').split(',')[-1] | float }}"

MANY THANKS!!
M.

https://openskynetwork.github.io/opensky-api/rest.html

1 Like

This worked finally for the issue.

message: "'{{ state_attr('sensor.jsonopensky', 'states')[0][1] }}'"