Hi Rob, is it possible to have the timetable of a train at a particular station? as that would give me all the available trains for my journey.
Can you please let me know how I could achieve it?
Thanks.
Hi Rob, is it possible to have the timetable of a train at a particular station? as that would give me all the available trains for my journey.
Can you please let me know how I could achieve it?
Thanks.
Are you after something like this:
In which case the following code will give you it from the standard sensor:
- platform: uk_transport
app_id: !secret transportapi_appid
app_key: !secret transportapi_key
scan_interval: 210 # Check every 210s (limit of 1000/day)
queries:
- mode: train
origin: WIN
destination: WAT
and lovelace code:
- type: custom:flex-table-card title: Trains to Waterloo entities: include: sensor.next_train_to_wat columns: - name: Origin attr_as_list: next_trains modify: x.origin_name - name: Destination attr_as_list: next_trains modify: x.destination_name - name: Time attr_as_list: next_trains modify: x.scheduled - name: Est attr_as_list: next_trains modify: x.estimated
thanks alot mate.
the 210seconds would be 3.5mins and would be suffice for the whole day?
Yes, I have 2 sensors running so that lets me do 2 queries each 3.5mins and not hit the limit.
I seeā¦
well if I dont use the love lace card then I dont get the table like yours
@jchasey thats a neat table! Iām completely new to lovelace, and getting the error below, any advice?
Itās a custom card used, so you need to install that first. Its a similar process for all lovelace custom cards, details are on the github page on how to download and install:
I was getting the following error in Hassio -
core-ssh:~# wget https://raw.githubusercontent.com/custom-cards/flex-table-card/master/flex-table-card.js
Connecting to raw.githubusercontent.com (151.101.0.133:443)
wget: canāt open āflex-table-card.jsā: File exists
So I manually downloaded the flex-table-card.js and placed it into my www folder then using the raw editor on Lovelace I added the resources
resources:
- type: js
url: /local/flex-table-card.js
Working a treat for me so thank you very much
******* my bad - I forgot to change directory into config/www first *******
Hi all - Iām pretty new to HA, but enjoying the platform. Iām doing OK and now have lots added and started to style up everything within Lovelace UI.
But Iām stuck with this UK Travel component and would really appreciate a helping hand, as no data is populating the table. Yaml code is below, appreciate any thoughts.
I have this in my configuration.yaml
sensor:
and this in my ui-lovelace.yaml:
resources:
views:
title: test
icon: mdi:home-outline
cards:
title: lights
title: Heating
# View tab title.
title: Entertainment
cards:
# The markdown card will render markdown text.
type: custom:flex-table-card
title: Trains to Waterloo
entities:
include: sensor.next_train_to_wat
columns:
Check the error log that the sensor is managing to pull data from uk_transport, Iāve had issues the last few days when HA fails to connect to uk_transport and the net result is that the table is not populated.
Thanks for your reply.
Iāve had a look at home-assistant.log, which I presume is the right place to look but thereās no mention of the uk_transport sensor - are you still unable to pull data from uk_transport?
Mine has stopped working the last 2 days - when I checked on the trainline app I could see that there is a replacement bus service and no trains for my station (Totton) are running hence why there is no data - I am guessing that Winchester is also running a bus service and there are currently no trains running
You can test in a browser here, replace MYID & APPLICATIONKEY with your API details -
Thanks Bertrum - I have tried your test string in a browser with my creds and WAT as the destination and the results come back fine, but when I try the same from HA the table just doesnāt populate.
i get this:
Any help appreciated as Iām stumped
Does the sensor āsensor.next_train_to_watā have any data in it ?
Mine is still not pulling data due to the trains not running but here is my raw code as the editor wonāt open for ATM with the data missing
type: 'custom:flex-table-card'
- columns:
- attr_as_list: next_trains
modify: x.origin_name
name: Origin
- attr_as_list: next_trains
modify: x.destination_name
name: Destination
- attr_as_list: next_trains
modify: x.scheduled
name: Time
- attr_as_list: next_trains
modify: x.estimated
name: Est
Mine shows this as the trains are not currently running
Is there a way to specify a specific name or entity_id for a particular route?
Iām trying to set up conditional cards that will display the times for my journey in the correct direction based on which area my phone is in. The problem is my journey consists of a connection meaning two of the four sensors have the same station as the destination (with different departure stations) - these are next_train_to_hhy and next_train_to_hhy_2. When the component loads after a reboot, it isnāt consistently allocating the same entity_id to the same route with the same destination.
This means sometimes sensor.next_train_to_hhy will have my home station as the departure station and sensor.next_train_to_hhy_2 will have my work station as the departure, but after a reboot these may flip around, making it hard to allocate a particular entity_id to an automated conditional card as itāll sometimes be the wrong route!
I canāt find these sensors in the entity registry on the UI, is there a way to force a route to take a particular entity ID?
Did you ever work this out? Iām having the same issue that I can see the automation triggering in the log, but sensor isnt being updated. Also isnāt updating when I run homeassistant.update_entity from the service dev tool.
Having trouble getting this component to work
Sorry for the long post trying to give all the info
My config is as follows
- platform: uk_transport
app_id: <my_app_id>
app_key: <my_app_key>
queries:
- mode: bus
origin: 6200201000
destination: "Easter Road"
- platform: template
sensors:
next_bus_route:
friendly_name: 'Next bus route'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[0].route}}'
next_bus_direction:
friendly_name: 'Next bus direction'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[0].direction}}'
next_bus_scheduled:
friendly_name: 'Next bus scheduled'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[0].scheduled}}'
next_bus_estimated:
friendly_name: 'Next bus estimated'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[0].estimated}}'
I am getting errors in the log
ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus direction: UndefinedError: list object has no element 0
ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus route: UndefinedError: list object has no element 0
ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus estimated: UndefinedError: list object has no element 0
ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus scheduled: UndefinedError: list object has no element 0
if I use the dev templates to examine the sensor like so
{{ states.sensor.next_bus_to_easter_road }}
I get this back
<template state sensor.next_bus_to_easter_road=unknown; atcocode=6200201000, locality=Corstorphine, Edinburgh, stop_name=Castle Avenue, request_time=2019-02-22T07:15:13+00:00, next_buses=[], unit_of_measurement=min, friendly_name=Next bus to Easter Road, icon=mdi:bus @ 2019-02-22T07:13:41.695352+00:00>
So its getting some details back but not all of them
using developer.transportapi site I get
{
"atcocode": "6200201000",
"smscode": "36235785",
"request_time": "2019-02-22T06:49:11+00:00",
"name": "Castle Avenue",
"stop_name": "Castle Avenue",
"bearing": "S",
"indicator": "opp",
"locality": "Corstorphine, Edinburgh",
"location": {
"type": "Point",
"coordinates": [
-3.27998,
55.93789
]
},
"departures": {
"1": [
{
"mode": "bus",
"line": "1",
"line_name": "1",
"direction": "Easter Road",
"operator": "LOB",
"date": null,
"expected_departure_date": "2019-02-22",
"aimed_departure_time": null,
"expected_departure_time": "06:51",
"best_departure_estimate": "06:51",
"source": "NextBuses",
"dir": "outbound",
"id": "https://transportapi.com/v3/uk/bus/route/LOB/1/outbound/6200201000///timetable.json?app_id=f8b27972&app_key=9683e1d3d4e72a5d3e50b7d32bd90513",
"operator_name": "Lothian Buses"
},
{
"mode": "bus",
"line": "1",
"line_name": "1",
"direction": "Easter Road",
"operator": "LOB",
"date": null,
"expected_departure_date": "2019-02-22",
"aimed_departure_time": null,
"expected_departure_time": "07:09",
"best_departure_estimate": "07:09",
"source": "NextBuses",
"dir": "outbound",
"id": "https://transportapi.com/v3/uk/bus/route/LOB/1/outbound/6200201000///timetable.json?app_id=f8b27972&app_key=9683e1d3d4e72a5d3e50b7d32bd90513",
"operator_name": "Lothian Buses"
},
{
"mode": "bus",
"line": "1",
"line_name": "1",
"direction": "Easter Road",
"operator": "LOB",
"date": null,
"expected_departure_date": "2019-02-22",
"aimed_departure_time": null,
"expected_departure_time": "07:24",
"best_departure_estimate": "07:24",
"source": "NextBuses",
"dir": "outbound",
"id": "https://transportapi.com/v3/uk/bus/route/LOB/1/outbound/6200201000///timetable.json?app_id=f8b27972&app_key=9683e1d3d4e72a5d3e50b7d32bd90513",
"operator_name": "Lothian Buses"
}
]
},
"source": "NextBuses"
}
Any help would be amazing
Thanks
Your sensor json is pulling data for field "1" not "0", try this -
- platform: template
sensors:
next_bus_route:
friendly_name: 'Next bus route'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[1].route}}'
next_bus_direction:
friendly_name: 'Next bus direction'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[1].direction}}'
next_bus_scheduled:
friendly_name: 'Next bus scheduled'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[1].scheduled}}'
next_bus_estimated:
friendly_name: 'Next bus estimated'
value_template: '{{states.sensor.next_bus_to_easter_road.attributes.next_buses[1].estimated}}'
Thanks for the response @BertrumUK
tried this and got
1011 2019-02-25 08:01:19 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus estimated: UndefinedError: list object has no element 1
1012 2019-02-25 08:01:19 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus scheduled: UndefinedError: list object has no element 1
1013 2019-02-25 08:01:19 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus route: UndefinedError: list object has no element 1
1014 2019-02-25 08:01:19 ERROR (MainThread) [homeassistant.components.sensor.template] Could not render template Next bus direction: UndefinedError: list object has no element 1
Strange, what data does the API pull for you today ?