[Custom Component] OEBB Austria next journeys

@lollopod i just filed you a pull request. i am curious, is there a reason you do not have issues enabled on your repository?

Has anyone testet this in the last weeks? The rt feature is not working anymore
 no updates on delays :frowning:

For me it still works. Did it work for you before?

Hi,
this was working like a charme since about 3 weeks. Then it suddenly stop working.
I did not change anything then the usual updates on HA.

I enabled debug and I got the following error.

2024-07-21 08:46:12.935 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up oebb platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/oebb/sensor.py", line 96, in async_setup_platform
    for idx, journey in enumerate(coordinator.data["journey"]):
                                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'journey'

Unfortunalty I cannot guess whats the issue here.
Does anyone else have the issue? Any ideas?

Thanks

Maybe the api is responding something bad - maybe a evaID/dirInput combination that does no longer work?

Did you try a different combination of settings?
I can say that the following combination is working for me:

  evaId: 1232109
  dirInput: 1291903

Sorry for the newby question, but how do I install this integration? I can’t see it in HACS and there are no instructions in the documentation.

I’m running Home Assistant OS with Core 2024.12.5

I had the same problem and found this as workaround: ÖBB-Monitor-V2

Yeah, been there, done that. :slight_smile:

It really doesn’t fit my intended dashboard, so I’d very much like to display the information in a different way.

In case anyone is still interested, I managed to retrieve departure data from Scotty without the custom integration. Here’s how to do it:

  1. Use the OEBB Link Creator to get your Station IDs (departure and optionally destination) and productsFilter.

  2. Use these IDs to create the URL for data retrieval:

https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&tickerID=dep&start=yes&eqstops=no&evaId=<departure station>&dirInput=<destination>&showJourneys=3&additionalTime=0&productsFilter=1011111111101&boardType=dep&outputMode=tickerDataOnly
  1. Test this URL in your browser, it should give you the next journeys in a somewhat JSONish format. The fields are:
  • da: Date
  • ti: Planned departure time
  • pr: Line
  • st: direction
  • tr: platform
  • rt: real-time information if not running according to schedule
    ** status: e.g. “Ausfall”
    ** dlt: actual departure time
  1. Create a REST sensor to retrieve the data. Unfortunately, Scotty does not provide a clean JSON response but returns a javascript assignment statement. As the RESTful integration’s built-in conversion fails, the returned data is not available in the variable value_json as unual. It needs to be cleaned up before manual conversion.

  2. In my case I used the RESTful integration and I have split the configuration.yaml into separate files.

configuration.yaml:

[...]
rest: !include rest.yaml

rest.yaml:

- resource: "https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&tickerID=dep&start=yes&eqstops=no&evaId=XXXXX&dirInput=XXXXX&showJourneys=3&additionalTime=0&productsFilter=0000000001000&boardType=dep&outputMode=tickerDataOnly"
  scan_interval: 60
  sensor:
    - name: "Bim nach XXXXX Minuten 1"
      unique_id: bim_XXXXX_min_1
      icon: mdi:tram
      device_class: duration
      unit_of_measurement: min
      value_template: >
        {% set value_json = (value[14:])|from_json %}
        {% set timediff = ( (as_timestamp(today_at(value_json.journey[0].ti)) - as_timestamp(now()))/60)|int(default=0) %}
        {% set timediff = timediff if (timediff >= 0) else timediff+1440 %}
        {{ timediff }}
    - name: "Bim nach XXXXX Uhrzeit 1"
      unique_id: bim_XXXXX_time_1
      icon: mdi:tram
      value_template: >
        {% set value_json = (value[14:])|from_json %}
        {{value_json.journey[0].ti}}
    - name: "Bim nach XXXXX Linie 1"
      unique_id: bim_XXXXX_line_1
      icon: mdi:tram
      value_template: >
        {% set value_json = (value[14:])|from_json %}
        {{'Linie ' + value_json.journey[0].pr}}

This will return the next journey, with sensors for

  • minutes left before departure
  • time of departure
  • line
  1. To retrieve the following journeys, simply add more sensors, referencing value_json.journey[1] etc. instead of value_json.journey[0].

Thanks go to @Dave2ooo, whose Link Creator is a valueable resource and whose OEBB Monitor V2 provided the essential hint how to format the URL.