Hi
I’m struggling with parsing bus times from a json response I get from a bus company website.I want to put the time for when the next bus is leaving in a sensor. This works well for busstops that are only served by one route. I use this as a sensor:
platform: rest
resource: https://skyss.giantleap.no/public/departures?Hours=12&StopIdentifiers=12012101
name: skyss50E_1
value_template: '{{ value_json["PassingTimes"][0]["DisplayTime"] }}'
The json I get from a busstop with multiple routes:
{"PassingTimes":[{"RouteDirectionIdentifier":"000004_0_Direction2","RoutePublicIdentifier":"4","StopIdentifier":"12015177","TripDestination":"Flaktveit","TripDestinationDescription":"","Status":"Late","AimedTime":"2018-10-12T06:59:00.000Z","DisplayTime":"2 min"},{"RouteDirectionIdentifier":"000050_E0_Direction1","RoutePublicIdentifier":"50E","StopIdentifier":"12012101","TripDestination":"Bergen busstasjon","TripDestinationDescription":"","Status":"Early","AimedTime":"2018-10-12T07:03:00.000Z","DisplayTime":"3 min"},{"RouteDirectionIdentifier":"000024_0_Direction1","RoutePublicIdentifier":"24","StopIdentifier":"12012101","TripDestination":"Oasen terminal","TripDestinationDescription":"","Status":"Late","AimedTime":"2018-10-12T07:02:00.000Z","DisplayTime":"4 min"},{"RouteDirectionIdentifier":"000004_0_Direction2","RoutePublicIdentifier":"4","StopIdentifier":"12015177","TripDestination":"Flaktveit","TripDestinationDescription":"","Status":"Late","AimedTime":"2018-10-12T07:09:00.000Z","DisplayTime":"11 min"},{"RouteDirectionIdentifier":"000050_E0_Direction1","RoutePublicIdentifier":"50E","StopIdentifier":"12012101","TripDestination":"Bergen busstasjon","TripDestinationDescription":"","Status":"Early","AimedTime":"2018-10-12T07:18:00.000Z","DisplayTime":"09:17"}}}
The sensor then gives me the time for the next bus, independent of the bus route. What if I only want the times for bus 50E? I don’t know how to tell the sensor to only take the values where the RoutePublicIdentifier is 50E.
any tips?
Thank you