UK Transport component

You need https://www.home-assistant.io/integrations/london_underground/

Thanks! Got it working already. Also looking for an API that will tell me the arrival times from a certain tube station (similar to what is available with UK Transport, but for the tube)

Im not aware of an API for that

Hi,

I’m new to HA and stumbled across this…

I’m wondering is if there is some way to see is some kind of live departures board for a certain station showing the trains to depart regardless of destination along with any delay?

I have the same issue - the card is not populating - no errors in logs or anything else, strange.

The transport sensor is definitely working, as I have the next train, origin and destination stations etc. etc. (in a different tab) - I’d just like a list of train times for the next couple hours or so - any advice on troubleshooting?

Ok, scrap the post from 20 minutes ago, the card was sitting inside a vertical-stacked card and wasn’t rendering (although a new tab appeared, which obviously was blank… weird).

I purposely embedded it within the last vertical-stacked card and the flex-table-card is working fine. A superb custom piece of code; I especially like the regex matching :wink:

I wonder if the card can match template sensors that I’ve created for battery monitors? like: {{states.binary_sensor.motion_sensor_158d0001e15d57.attributes.battery_level}}
to:
{{states.binary_sensor.*.attributes.battery_level}}

Hi @jchasey

Wonder if you could assist with this, I’ve seen this a couple of times today and want to change “undefinedundefinedundefined” to “Cancelled”. Obviously a cancelled train won’t have an ETA but it’s obviously looking for an integer(?) and not a string.

image

Tried this, and doesn’t work
modify: ‘if (x.estimated == “undefined”) { “Cancelled” } else { x.estimated }’
(the whole column shows as “Cancelled” even when the trains have an ETA).

Thanks
B

You are trying to check x.estimated against a string, whereas its likely set to null and undefined is what is rendered in that situation. So instead try:

‘if (x.estimated) { “Cancelled” } else { x.estimated }’

doing that makes the whole Est column “Cancelled”, hmmm… would it be easier to have:

‘if (x.estimated =/= ‘00:00’ {“Cancelled”} else {x.estimated}’

?

Sorry flip the order:

if (x.estimated) { x.estimated } else { “Cancelled” }

Ah! Simples, why didn’t I think of that.

Ok, will test it on a couple of cancelled trains/lines and see how we go.

Thanks

I wonder why the transportapi doesnt return number of coaches?
My train home is often shortformed so it would be great to be able to get an alert when it has e.g. 2 carriages instead of the normal 4.
You can see the number of coaches returned in XML using this service, but its beyond my ability to extract it I think:

http://iris2.rail.co.uk/tiger/#support

I wonder if anyone might be able to help. In order for me to use the UK transport API I have to append “&source_config=dws_staff” to force the api to use a different source for the data as normal data is not available for the Tyne and Wear Metro. Is there any way I can add this tag into the home assistant component?

Anyone else experience the Christmas edge case where flex-table-card has an error and stops the whole page (any other cards on the page) from loading ? Basically happens when no trains are running!

“No card type found”

Same here…

For some other poor lost soul trying to understand the stupid complexities of Lovelace formatting, this works if you paste it in a “manual card”:

type: conditional
conditions:
  - entity: sensor.next_train_to_lbg
    state_not: No departures
card:
  type: 'custom:flex-table-card'
  title: Trains to London Bridge
  icon: 'mdi:train'
  entities:
    include: sensor.next_train_to_lbg
  columns:
    - name: Time
      attr_as_list: next_trains
      modify: x.scheduled
    - name: Time
      attr_as_list: next_trains
      modify: x.scheduled
    - name: Est
      attr_as_list: next_trains
      modify: x.estimated
    - name: Status
      attr_as_list: next_trains
      prefix: '<style> cc { color: red; } </style>'
      modify: >-
        if (x.status == "LATE") { "<cc>" + x.status + "</cc>" } else { x.status
        }
    - name: Delay
      attr_as_list: next_trains
      modify: >-
        if (x.estimated ) { (parseInt(x.estimated) * 60 +
        parseInt((x.estimated).slice(3,5))) - (parseInt(x.scheduled) * 60 +
        parseInt((x.scheduled).slice(3,5))) } else { " " }
      suffix: m
      align: right

From memory I got around this with: UK Transport component

So basically when no trains are running the Vertical-Stacked-Card renders nothing, but the flex-table-card keeps plodding along - the idea is if the render fails, then only that Card fails to load, rather than your whole tab failing to load

I have read through the thread and there was brief mention of an “arrival time” function but I couldn’t see if anything was done about this.

Has anyone implemented anything like that function?

Anyway I can avoid this? :smiley: thanks

dasdsadsa

I’m pulling my hair out over this :rofl:

Using the below in configuration.yaml the sensor is returning state ‘unknown’.

  - platform: uk_transport
    app_id: MYIDHERE
    app_key: MYKEYHERE
    queries:
      - mode: bus
        origin: 0500SHILD002
        destination: 0500CCITY321

I’ve sent both of the Atco codes to uk/bus/stop/{atcocode}/live.json and they both return info correctly with status 200, but yet HA shows Unknown.

Does anyone have any clue why this doesn’t work?

TIA

1 Like