Syntax for value_template in rest sensor (from json returned by API)

I cannot figure out what’s wrong with my value_template that does not return the expected value (a number for the time) :thinking:

Here is my sensor in the configuration.yaml :

sensor:
  - platform: rest
    resource: https://api-iv.iledefrance-mobilites.fr/lines/v2/line:IDFM:C01149/stops/stop_area:IDFM:73166/realTime
    name: Bus TEST
    value_template: "{{ value_json.nextDepartures.data[1].time }}"

It works in the Developer Tools > Template though which is why I’m confused :expressionless:

{%
  set value_json = {"nextDepartures":{"data":[{"lineId":"line:IDFM:C01149","shortName":"120","lineDirection":"Noisy Mont d'Est <RER>","time":"20","destination":{"stopPointId":"stop_point:IDFM:NoisyMontdEstRER","stopAreaId":null}},{"lineId":"line:IDFM:C01149","shortName":"120","lineDirection":"Nogent-Sur-Marne <RER>","time":"26","destination":{"stopPointId":"stop_point:IDFM:NogentSurMarneRER","stopAreaId":null}},{"lineId":"line:IDFM:C01149","shortName":"120","lineDirection":"Noisy Mont d'Est <RER>","time":"49","destination":{"stopPointId":"stop_point:IDFM:NoisyMontdEstRER","stopAreaId":null}},{"lineId":"line:IDFM:C01149","shortName":"120","lineDirection":"Nogent-Sur-Marne <RER>","time":"56","destination":{"stopPointId":"stop_point:IDFM:NogentSurMarneRER","stopAreaId":null}}],"statusCode":200},"crowdsourcingReports":{"congestions":[{"directionId":"stop_area:IDFM:412697","nearTimeReports":{"rating":null}},{"directionId":"stop_area:IDFM:71590","nearTimeReports":{"rating":null}}],"statusCode":200}}
%}
{{ value_json.nextDepartures.data[1].time }} // <= returns 26 which is correct !

But I only get unknown if I inspect that sensor in the Dev Tools > State :frowning: