Open government data, departure monitor for public transport

Hey!
I live in Vienna, and the city finaly made it possible to include departures for Google.
I heard Google want a special format for their data.
Open Data i guess.
So i think it would be possible for all bigger citys where Google is working

I would love a departure monitor for the old phone wich i use to turn off all lights when i leave the home.

Info for Vienna (german)


(translated link)
for London

for New York
http://datamine.mta.info/

The gtfs sensor can work with those sources.

Yes and Nay…
Please note: This is a static data source. Currently, there is no GTFS Realtime support in this sensor due to issues surrounding parsing the protocol buffer format in Python 3.

in Vienna possible with a REST sensor over their own API.
But a little hard to set up when you have no idea of json strings and API’s.
the Stop_id can be found out https://till.mabe.at/rbl/
and the API key requested https://go.gv.at/l9ogdechtzeitdatenwienerlinienkeyanforderung

sensor:
  - platform: rest
    name: first
    resource: http://www.wienerlinien.at/ogd_realtime/monitor?rbl=[Stop_ID]&sender=[API_Key]
    value_template: '{{ value_json.data.monitors[0].lines[0].departures.departure[0].departureTime.countdown }}'

  - platform: rest
    name: next
    resource: http://www.wienerlinien.at/ogd_realtime/monitor?rbl=[Stop_ID]&sender=[API_Key]
    value_template: '{{ value_json.data.monitors[0].lines[0].departures.departure[1].departureTime.countdown }}'

Is it possible to filter to specific lines?

I see that you already found

what you mean with specific lines? the RBL are line bounded - so even when you got like the U1 and U4 the RBL number is unic to each line

ahhh, shit. had no idea. sorry :slight_smile:
maybe I misread at GitHub. I thought it was general departure times. stupid me.

I’m waiting for my Wiener Linien API key. Cheers!

hi!

i installed the wienerlinien integration via hacs and added the code to configuration.yaml. unfortunately, it still says, the entities are not available. do you have any clue how to fix this?

part of my configuration.yaml:

sensor systemm:
    platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /
      - type: memory_use_percent
      - type: load_15m
      - type: network_in
        arg: eth0
      - type: network_out
        arg: eth0
      - type: ipv4_address
        arg: eth0
      - type: processor_use
      - type: processor_temperature
      - type: last_boot
      - type: throughput_network_in
        arg: eth0
      - type: throughput_network_out
        arg: eth0
        
sensor wl:
    platform: wienerlinien
    firstnext: next
    stops:
      - '1748'`Preformatted text`

Hi! I was hoping one of you lovely people could point me in the right direction…

I have the sensor data for my local stop working properly, with a nice lovelace card. But … does anyone know how to create an automation which reads the date of the time of the sensor and compares it with the current date and time? So I can run an automation at a certain number of minutes before the bus arrives?

Sorry if I’m not really allowed to post this here, but you guys do have some experience using the wiener linien sensor …

Thanks so much!
Ben

Hey Ben,
No worries, afaik you’re allowed to post here.But, Best head over to the discord server.

I would use a Numeric state trigger

automation:
  trigger:
    - platform: numeric_state
      entity_id: sensor.cossmanngasse_first_departure
      attribute: countdown
      above: 17
      below: 20

here a little template example what might get you starting for more powerful stuff:

 "{{ (   as_timestamp(states('sensor.cossmanngasse_first_departure')) - as_timestamp( now() )   ) /  60  }}"

as_timestamp(states('sensor.cossmanngasse_first_departure')) gives you the next departure as a timestamt (the number of seconds that have elapsed since January 1, 1970)
as_timestamp( now() ) Does the same for the current time
the- substracts the values and / 60 divides the secconds by 60 to get a time by minutes

(mind the brackets)

“{{ ( as_timestamp(states('sensor.cossmanngasse_first_departure')) - as_timestamp( now() ) ) / 60 }}”
without them you would device now() through 60

That’s great – gives me something to read up on on my bus rides! Thanks so much for pointing me in the right direction with this, I really appreciate it.

1 Like