I have a rest sensor that returns an array.
Is there any way to assign the entire JSON response into an attribute of the sensor?
This is a working example of the rest sensor (works for anyone) but obviously I haven’t got the json_attributes_path or json_attributes correct despite several attempts.
sensor:
- platform: rest
name: Train Data
unique_id: train_data
resource: https://api.tfl.gov.uk/StopPoint/910GFRNDXR/ArrivalDepartures?lineIds=elizabeth
value_template: ok
json_attributes_path: $
json_attributes: []
which returns a JSON array in this format:
[
{
"$type": "Tfl.Api.Presentation.Entities.ArrivalDeparture, Tfl.Api.Presentation.Entities",
"platformName": "Platform B",
"destinationNaptanId": "910GMDNHEAD",
"destinationName": "Maidenhead Rail Station",
"naptanId": "910GFRNDXR",
"stationName": "Farringdon",
"estimatedTimeOfArrival": "2025-07-29T21:37:00Z",
"scheduledTimeOfArrival": "2025-07-29T21:37:00Z",
"estimatedTimeOfDeparture": "2025-07-29T21:38:00Z",
"scheduledTimeOfDeparture": "2025-07-29T21:38:00Z",
"minutesAndSecondsToArrival": "39:58",
"minutesAndSecondsToDeparture": "40:58",
"departureStatus": "OnTime"
},
{
"$type": "Tfl.Api.Presentation.Entities.ArrivalDeparture, Tfl.Api.Presentation.Entities",
"platformName": "Platform B",
"destinationNaptanId": "910GHTRWTM4",
"destinationName": "Heathrow Terminal 4 Rail Station",
"naptanId": "910GFRNDXR",
"stationName": "Farringdon",
"estimatedTimeOfArrival": "2025-07-29T22:14:00Z",
"scheduledTimeOfArrival": "2025-07-29T22:14:00Z",
"estimatedTimeOfDeparture": "2025-07-29T22:15:00Z",
"scheduledTimeOfDeparture": "2025-07-29T22:15:00Z",
"minutesAndSecondsToArrival": "76:58",
"minutesAndSecondsToDeparture": "77:58",
"departureStatus": "OnTime"
},
{
"$type": "Tfl.Api.Presentation.Entities.ArrivalDeparture, Tfl.Api.Presentation.Entities",
"platformName": "Platform B",
"destinationNaptanId": "910GHAYESAH",
"destinationName": "Hayes & Harlington Rail Station",
"naptanId": "910GFRNDXR",
"stationName": "Farringdon",
"estimatedTimeOfArrival": "2025-07-29T22:26:00Z",
"scheduledTimeOfArrival": "2025-07-29T22:26:00Z",
"estimatedTimeOfDeparture": "2025-07-29T22:27:00Z",
"scheduledTimeOfDeparture": "2025-07-29T22:27:00Z",
"minutesAndSecondsToArrival": "88:58",
"minutesAndSecondsToDeparture": "89:58",
"departureStatus": "OnTime"
},
]

