ryanbateman / bvg-sensor

A HomeAssistant / HACS integration of Berlin Public Transport (BVG)
The Unlicense
14 stars 1 forks source link

Next departure "unknown" #5

Open tinkerberlin opened 2 years ago

tinkerberlin commented 2 years ago

Hi there, this might be a simple config problem/mistake on my side... however, I'm trying to add four connections. However, only one connection is working (U6 > Alt Mariendorf). All the other entries are displaying "unknown". I've pasted my config.yaml entry below. Thanks for your help!! image

tinkerberlin commented 2 years ago

Any help possible? Thanks!

  # BVG
  - platform: bvg_berlin_public_transport
    stop_id: "900000089303"
    direction:
      - "Henningsdorf"
    name: "S25 > Henningsdorf"
  - platform: bvg_berlin_public_transport
    stop_id: "900000089301"
    direction:
      - "Alt-Mariendorf"
    name: "U6 > Alt-Mariendorf"
  - platform: bvg_berlin_public_transport
    stop_id: "900000089303"
    direction:
      - "Teltow Stadt"
      - "Südkreuz"
    name: "S25 > Teltow Stadt / Südkreuz"
  - platform: bvg_berlin_public_transport
    stop_id: "900000089301"
    direction:
      - "Alt-Tegel"
    name: "U6 > Alt-Tegel"

    # https://github.com/ryanbateman/bvg-sensor
amrutprabhu commented 1 year ago

You can set the walking_distance: 0. If you check the description, If the time to your station is not possible to catch the train, it will not display it. by default, it is 10, if not set.

It works for some, but for many stations I could not get it working. e.g this worked for the following


- platform: bvg_berlin_public_transport
  name: Alex > S+U Hauptbahnhof - 2
  stop_id: "900000100031"
  direction: 
     - "Hauptbahnhof"
  walking_distance: 0

- platform: bvg_berlin_public_transport
  name: Alex > S+U Hauptbahnhof - 3
  stop_id: "900000100707"
  direction: 
     - "Hauptbahnhof"
  walking_distance: 0

but dint work for

- platform: bvg_berlin_public_transport
  name: "Alex > Ruhleben - 2"
  stop_id: "900000100031"
  direction: 
    - "Ruhleben"
  walking_distance: 0

- platform: bvg_berlin_public_transport
  name: "Alex > Ruhleben - 3"
  stop_id: "900000100707"
  direction: 
    - "Ruhleben"
  walking_distance: 0
amrutprabhu commented 1 year ago

I figured it out. I went through the code and figured this out. You need to chose your direction based on the output of this URL

https://v5.bvg.transport.rest/stops/{stop id}/departures?duration={ cache duration}

find all the directions from the output JSON, choose the direction you want, and add to the direction property.

eg. for Alexanderplatz,

curl https://v5.bvg.transport.rest/stops/900000100731/departures\?duration\=90 | jq '.[].direction'
- platform: bvg_berlin_public_transport
  name: "Alex > Ruhleben "
  stop_id: "900000100731"
  direction: 
    - "Ruhleben"
  walking_distance: 0

Works !!!