yes, see
Ah, I see it now. Thanks.
I’ve pushed a significant change in the latest commit, and hopefully will submit this version to HA. Therefore if you could test this version and give any feedback that would be great Note that the config entry has changed.
Project complete
This is brilliant and I would love to use it for my wife, as she has to get the bus. Looks like not all towns etc have ATCO codes, as I cannot see any listed on the bus stops in my town. Or is there any other way to find them please?
Cheers
Mark
answered my own question
you can by running
http://transportapi.com/v3/uk/bus/stops/near.json?lat=xxxxxx&lon=-xxxxx&app_id=xxxxx&app_key=xxxxx
Just set this up for myself and all seems to be working - thank you @robmarkcole!
Did you ever implement the additional items you mention above, namely the polling window etc?
Hi Dave, busy with other projects but if there is sufficient interest could add to my to do.
Basic approach is to add a service for each sensor which allows to set the SCAN_INTERVAL of that sensor. Automations can be used to set it.
If you want to have a go I’m happy to review pull requests
Eeek! I’d love to, but wouldn’t have a clue where to start right now!
I will have a play around / read up and see if I can follow what you just said
My main reason for asking is I want to set up a notification on my return trip as well, and just worried it will hit the request limit before home time.
I am sure I have this setup correctly but getting errors in the logs
2017-10-11 13:45:59 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus direction: UndefinedError: list object has no element 0
2017-10-11 13:47:32 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus route: UndefinedError: list object has no element 0
2017-10-11 13:47:32 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus estimated: UndefinedError: list object has no element 0
2017-10-11 13:47:32 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus scheduled: UndefinedError: list object has no element 0
2017-10-11 13:47:32 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus direction: UndefinedError: list object has no element 0
- platform: uk_transport
app_id: x
app_key: x
queries:
- mode: bus
origin: xxxx
destination: xxx Bus Station
- platform: template
sensors:
next_bus_route:
friendly_name: 'Next bus route'
value_template: '{{states.sensor.next_bus_to_xxxx_bus_station.attributes.next_buses[0].route}}'
next_bus_direction:
friendly_name: 'Next bus direction'
value_template: '{{states.sensor.next_bus_to_xxxx_bus_station.attributes.next_buses[0].direction}}'
next_bus_scheduled:
friendly_name: 'Next bus scheduled'
value_template: '{{states.sensor.next_bus_to_xxxx_bus_station.attributes.next_buses[0].scheduled}}'
next_bus_estimated:
friendly_name: 'Next bus estimated'
value_template: '{{states.sensor.next_bus_to_xxxx_bus_station.attributes.next_buses[0].estimated}}'
info is pulled out when using “/uk/bus/stop/{atcocode}/live.json”
any ideas please?
Cheers
Mark
I tried with a random London bus and it works. hmm
SCAN_INTERVAL gets worse as you add more sensors to ensure you do not breach API requests limit
Must be an invalid route
definitely a valid route… maybe a small town issue ?
Did you try the developer API as recommended in the docs? Cheers
well I played with transportapi and the output was this
{
"atcocode": "0790xxA",
"smscode": "mxxpga",
"request_time": "2017-10-11T21:43:18Z",
"name": "Parxxxe (A)",
"stop_name": "Parkxx",
"bearing": "E",
"indicator": "A",
"locality": "Cxxx",
"departures": {
"10": [
{
"mode": "bus",
"line": "10",
"line_name": "10",
"direction": "Mxxx",
"operator": "PBx7",
"date": "2017-10-12",
"expected_departure_date": null,
"aimed_departure_time": "07:03",
"expected_departure_time": null,
"best_departure_estimate": "07:03",
"source": "NextBuses",
"dir": "inbound",
"id": "https://transportapi.com/v3/uk/bus/route/PBxx/10/inbound/079xxA/2017-10-12/07:03/timetable.json?app_id=31xxx&app_key=xxx240dd",
"operator_name": null
},
{
"mode": "bus",
"line": "10",
"line_name": "10",
"direction": "xxxStation",
"operator": "PBx7",
"date": "2017-10-12",
"expected_departure_date": null,
"aimed_departure_time": "07:23",
"expected_departure_time": null,
"best_departure_estimate": "07:23",
"source": "NextBuses",
"dir": "inbound",
"id": "https://transportapi.com/v3/uk/bus/route/Pxx987/10/inbound/07xxA/2017-10-12/07:23/timetable.json?app_id=31xx&app_key=xxx",
"operator_name": null
},
{
"mode": "bus",
"line": "10",
"line_name": "10",
"direction": "xxx",
"operator": "xx87",
"date": "2017-10-12",
"expected_departure_date": null,
"aimed_departure_time": "07:40",
"expected_departure_time": null,
"best_departure_estimate": "07:40",
"source": "NextBuses",
"dir": "inbound",
"id": "https://transportapi.com/v3/uk/bus/route/PB1xx7/10/inbound/07xxA/2017-10-12/07:40/timetable.json?app_id=313xxapp_key=bxxxd",
"operator_name": null
}
]
},
"source": "NextBuses"
}
Data looks ok. You can see what is expected in the tests. If you are happy to post the origin
and destination
you entered in the configuration I will look into it. DM is ok
Resolved by editing the destination
config entry - had spaces in it, just enter the first word from the destination:
i.e.
destination: Amazing bus station
becomes
destination: Amazing
or GrimNorthern Bus Station
thanks for the solution!
A couple of comments.
I have three sensors set up but seem to be exceeding my daily API call limit, not sure why as I thought the component was self-throttling?
Could be that it’s because I have both train and bus data? Is the throttle applied at transport type level?
Additionally it appears the bus destination is just a filter on the data rather than part of the API call, if like me you want all buses from a stop regardless of direction/destination a simple “.*” in the destination works wonders!