London tube status component

Assuming that is the only 8:04 train then I would advise creating a template sensor on the planned departure time which is an attribute.
Operator is also an attribute so you could add that as a filter.
I’m out fishing at the moment so can’t be more specific til I try myself at home.

Hi guys, would you be able to help me with the syntax to reference the description field from these tube line sensors? So far my automation creates a pushover notification with both the title and message showing the sesnsor status i.e. “good service” or “minor delays”, what I’d like is to be able to include the sensor description in the message body.

My automation looks like this:

> - id: '1543353858266'
>   alias: TFL (Hammersmith & City)
>   trigger:
>   - entity_id: sensor.hammersmith__city
>     from: Good Service
>     platform: state
>     to: '*'
>   condition: []
>   action:
>   - data:
>       data:
>         priority: 0
>         sound: bike
>       message: 'Hammersmith & City Line: {{ states(''sensor.hammersmith__city'') }}'
>       title: 'Hammersmith & City Line: {{ states(''sensor.hammersmith__city'') }}'
>     service: notify.notify
- id: '1543353858266'
  alias: TFL (Hammersmith & City)
  trigger:
    platform: state
    entity_id: sensor.hammersmith__city
  action:
    service: notify.notify
    data_template:
      priority: 0
      sound: bike
      message: "{{ states('sensor.hammersmith__city') }}" 
      title: "Hammersmith & City Line" 

Thanks @anon43302295 sadly that doesn’t work, I get the error

Invalid service data for notify.notify: extra keys not allowed @ data[‘priority’]. Got ‘0’
extra keys not allowed @ data[‘sound’]. Got ‘bike’

Also by using message: “{{ states(‘sensor.hammersmith__city’) }}” wouldn’t I just end up with the sensor state i.e. “good service” which is what I already get with my automation. I was assuming I would need to use state.attributes.description somehow but was unable to work out the syntax.

Apologies for two things, first I misread what you wanted to do, and second I don’t use pushover so I don’t know where the keys sit for priority and sound - try this…

  action:
    service: notify.notify
    priority: 0
    sound: bike
    data_template:
      title: "Hammersmith & City Line: {{ states('sensor.hammersmith__city') }}"
      message: "{{ state_attr('sensor.hammersmith__city' , 'NAME_OF_ATTRIBUTE') }}"

Obviously replacing the capitals appropriately :slight_smile:

Perfect, thanks @anon43302295, a little tweaking led me to this which works perfectly:

- id: '1543353858266'
  alias: TFL (Hammersmith & City)
  trigger:
  - entity_id: sensor.hammersmith__city
    from: Good Service
    platform: state
    to: '*'
  condition: []
  action:
  - data:
      data:
        priority: 0
        sound: bike
      message: '{{ state_attr(''sensor.hammersmith__city'' , ''Description'') }}'
      title: 'Hammersmith & City Line: {{ states(''sensor.hammersmith__city'') }}'
    service: notify.notify
1 Like

I know this was mentioned at the start but it kinda got dropped, but Is there any chance or plan of adding tube station train arrival times? I’ve used the awesome UK Transport component but that uses transportapi which doesn’t look like it properly supports the tube anymore so I cant see this being integrated into that. Theres the tfl api which this component uses and I know how to use it to fetch a list of upcoming trains at a specific station and how many seconds they are away and stuff but it’s just frustrating that I don’t know how to integrate it as my own component or something since I’m new totally new to json yaml and HA itself.

Like for example this returns a json object(?) of upcoming trains going southbound from Bermondsey station, with how long until each of the trains arrive.
https://api.tfl.gov.uk/line/jubilee/arrivals/940GZZLUBMY?direction=inbound

jubilee is the train line, the 940… id is the station id, and the optional direction is pretty much which platform or direction you want to see trains heading to.

I guess to integrate it as a “time until next train” badge or whatever in HA I’d have to select the train in the array with the lowest amount of seconds until arrival and then grab the time in seconds and the destination of the train and then display that info. Ideally the seconds would be divided by 60 to get a number in minutes instead of seconds too.

Hi Rob,

I’ve added your london_underground component. Works well. I’ve got a great idea for an automation. Using the ‘workday’ integration and the time sensor I could theoretically automate a notification of the status of my home tube line as I have breakfast every working day morning. I happen to have a custom integration that can pass text to speech notifications to an alexa, so I could have alexa tell me. Any idea how to pass the tube status detail from your custom component to another service call?

It is just a sensor attribute so break it out with a template sensor

Of course! Thanks. Got that working, but it only pulls back the top line info e.g. Good service. Do you know how I can access the description text that goes with it?

Good service is the description, this will change at some point :slight_smile:

Ha, undoubtedly! There is a second part to the service description though. When it’s stating good service, there is another text field of “nothing to report”. If the main description changes to e.g, “severe delays” that additional text changes to a more detailed description of the reason for the service status such as “bellend under a train because his hedge fund tanked” or something like that, so it’s a two part description. Calling the state of the sensor only gets me the first part.

Whats the config for your template sensor? You need to be accessing the Description attribute

Ah, great, thanks.i was just using the output straight from the line sensor instead of templating it to grab the description part. Don’t suppose you know a good way to string these two outputs into one instead of having to have two separate entity lines? Would be great to have a single template sensor that could output e.g. “Good service. Nothing to report” or “severe delays. Signal failure blah blah…”

Well you can do that with a template sensor too :slight_smile:

Do you know the syntax for that (i.e. pulling two variables on a single value_template line? Can’t get it to work.

Hi Guys. Any way to actually pull status for London Tramlink via this component? @robmarkcole

Im sure that q came up before

I can’t find a way as when I try to add it in whatever name I can think off it just doesn’t work.