I have some data that looks like the sample below. I want to incorporate this into my HA installation so I can see real-time updates on train status. I’ve tried using the rest sensor to put all this info into attributes as a quick solution, but I’m having trouble using the sensor. It may be the case that the rest sensor won’t work here and instead I’ll write a custom component, but I figured I’d try the easy route first.
Once I can determine how to make any of the data available via attributes, I can probably sort out the rest. Any suggestions?
My config looks like:
- platform: rest
resource: example.com/wp-admin/admin-ajax.php
method: POST
payload: '{"action" :"get_station_feed"}'
headers:
Origin: snip
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
User-Agent: Home Assistant
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://example.com/
X-Requested-With: XMLHttpRequest
Connection: keep-alive
DNT: 1
value_template: '{{value_json}}'
[{
'Id':'17',
'Lat':,
'Lon':,
'MilePost':None,
'Name':'',
'Directions':[
{
'Direction':'N',
'StopTimes':[
{
'ArrivalDate':'2018-08-01T00:00:00',
'ArrivalTime':'6:55 pm',
'TrainId':'P332',
'TripId':'P332',
'RealtimeFlag':True,
'DelayFlag':False
},
{
'ArrivalDate':'2018-08-01T00:00:00',
'ArrivalTime':'7:32 pm',
'TrainId':'P334',
'TripId':'P334',
'RealtimeFlag':True,
'DelayFlag':False
}
]
},
{
'Direction':'S',
'StopTimes':[
{
'ArrivalDate':'2018-08-01T00:00:00',
'ArrivalTime':'6:44 pm',
'TrainId':'P337',
'TripId':'P337',
'RealtimeFlag':True,
'DelayFlag':False
},
{
'ArrivalDate':'2018-08-01T00:00:00',
'ArrivalTime':'8:09 pm',
'TrainId':'P339',
'TripId':'P339',
'RealtimeFlag':True,
'DelayFlag':False
}
]
}
]
},
{
'Id':'2',
etc, etc, etc}
]