[solved] Rest / json parse working in template module but not as sensor?

Dear Community

I don’t get it why my sensor isn’t working… I got the following code:

- platform: rest
resource: https://fahrplan.search.ch/api/route.json?from=endingen&to=wetzikon&via=niederweningen
    name: Arbeitsweg_Test
    entity_id: sensor.time
    json_attributes:
      - connections
    value_template: >-
      {% set abfahrt1 = value_json["connections"][0]["departure"].title() %}
      {% set ankunft1 = value_json["connections"][0]["arrival"].title() %}
      {% set reisezeit1 = value_json["connections"][0]["duration"].title() | int %}
      {% set minutes = ((reisezeit1 % 3600) / 60) | int %}
      {% set hours = ((reisezeit1 % 86400) / 3600) | int %}
      {{ "Abfahrt: " + abfahrt1[11:] + " | Ankunft: " + ankunft1[11:] + " | Dauer: " + (hours|string) + ":" + (minutes|string) + "!" }}

The url is working and providing the values, when i try the sensor within the template module with fake values it is working:

  {% set abfahrt1 = "2019-05-16 12:47" %}
  {% set ankunft1 = "2019-05-16 14:12" %}
  {% set reisezeit1 = "5640" | int %}
  {% set minutes = ((reisezeit1 % 3600) / 60) | int %}
  {% set hours = ((reisezeit1 % 86400) / 3600) | int %}
  {{ "Abfahrt: " + abfahrt1[11:] + " | Ankunft: " + ankunft1[11:] + " | Dauer: " + (hours|string) + ":" + (minutes|string) + "!" }}

Abfahrt: 12:47 | Ankunft: 14:12 | Dauer: 1:34!

In the json-response from the URL the field duration is without “”, could this be causing the problem that i cannot us the value_json[“connections”][0][“duration”].title() | int maybe?

This is the beginning of the Response from the URL with the relevant fields bold:
{“count”:4,“min_duration”:4860,“rawtime”:4860,“max_duration”:5640,“maxtime”:5640,“connections”:[{“from”:“Endingen, Zentrum”,“departure”:“2019-05-15 12:20:00”,“to”:“Wetzikon”,“arrival”:“2019-05-15 13:41:00”,“duration”:4860,

Any ideas?

Thanks in advance
Dave

BTW: I am trying to display the next bus/train connection to work…

I finally found the solution:

{% set reisezeit1 = value_json["connections"][0]["duration"] | int %

Just without the .title() - so simple… but took me some hours! Perhaps this might help someone else too…