Getting list from json?

I have a json-list that looks like this:

{"playlist": "["Endorfin", "Flatline", "Nedforsbacke pa varen", "Husbat", "Brotfest", "Electartica", ".DS_Store", "Solnedgang och ol", "Sjunga med", "Ledset", "00s gott", "Elektronisk lowpop", "Ambient", "Afusktiskt", "Raggaragga", "cgi-bin", "Sweet n sour", "Chill", "Konstig pop", "Forfest", "Nyklassiskt"]"}

and I’m trying to get it like this:

  - platform: rest
    resource: http://127.0.0.1:8091/cgi-bin/playlist.py
    value_template: '{{value_json.playlist}}'
    name: playlist

I would like to use the values of that list as the values in a dropdown, but right now I only get “unkown”, i can change the json if that helps, I wrote it :slight_smile:

This doesn’t look like valid JSON.

The documentation contains an example about how to access data in a list.

1 Like

Yes, it was invalid, however still not sure how/if I could use that list in an input_select, I tried this for example:

input_select:
  playlist:
    options: {{ states.sensor.playlist.state }}

but it doesn’t work, and there seems to be no data_options: attribute.

I tried this aswell, but it seems to just make a string of it.

 - platform: rest
    resource: http://127.0.0.1:8091/cgi-bin/playlist.py
    value_template: >-
      {% for playlist in value_json.playlist %}
       - {{ playlist }}
      {% endfor %}

    name: playlist

There you can find an example of how to get a value out of a list.

1 Like

Thankyou! The actual problem: