BVG Public Transport Sensor for Berlin

I just discovered Home Assistant and I’m setting things up. It would be amazing to have this running on its latest version. Any updates?
Thanks!

1 Like

I’ve had trouble setting this component up as well so I created a fork and migrated the repo to the new component structure required since “The Great Migration”. Additionally the API endpoint had changed so I made some minor tweaks there. It is now working correctly again.

Just make sure to rename the folder to bvg after cloning/unpacking the repository.

If fluffykraken wants to continue maintaining the component I am happy to submit a pull request. Perhaps the documentation would need some additional changes so just let me know if you encounter any issues.

@disrupted Hi. Thanks for doing this! I have two questions:

  1. Why is is necessary to change the name?
  2. Is there a type of card for Lovelace to show the info?
  1. when creating the manifest.json I renamed the integration to simply bvg, because a platform name shouldn’t contain the domain name to avoid confusion. In your config.yaml it looks like this:
sensor:
  - platform: bvg
    ...
  1. I don’t know of any custom lovelace card if that’s what you’re looking for but feel free to create something if you have an idea :slight_smile:
    at the moment I am just using an entities card with secondaryinfo-entity-row to display the delay
1 Like

@disrupted so I do need to download it manually right? I try to keep all integrations by adding its Github link to HACS so I can easily keep all integrations visible and get notified when an update appears.

I’m asking since HACS will not let me change the name and the manifest will not work I guess. (Still getting familiar with how everything works)

I’ll look into that, it sure would be nice to have it in HACS. If you wanna start using it right away I’d recommend downloading the zip archive or cloning the repo as described.

@disrupted as long as no changes need to be made I can quickly add your github url into HACS and should work automatically

I have been trying to add this as a Custom Repo but I get:

Exception: HacsException
Message: Repostitory structure for master is not compliant
Could not add this repository, make sure it is compliant with HACS.

Can you share the YAML for this please?

as previously mentioned it’s not compatible with HACS. please follow the steps described in my original post or in the repository.

here’s an example:

- type: entities
  entities:
    - type: custom:secondaryinfo-entity-row
      entity: sensor.bvg_moritzplatz_u8_wittenau
      name: U8 Wittenau
      secondary_info: "[[ sensor.bvg_moritzplatz_u8_wittenau.attributes.delay ]] min delayed"

Understood, thank you.

Thank you.

I wanted it to say “On time” instead of 0 minutes but I could not get that working.

type: entities
title: Tram
entities:
  - entity: sensor.tram_some_str
    type: 'custom:secondaryinfo-entity-row'
    secondary_info: >-
      [[ if(sensor.tram_some_str.attributes.delay < 0, "On time",
      "Delayed by [ sensor.tram_some_str.attributes.delay ]") ]]

It just says

Delayed by [ sensor.tram_some_str.attributes.delay ]

How could I fix that?

where did you find the syntax for your if-condition? afaik it’s not supported by this custom lovelace card but if you find a better alternative let me know.

EDIT: you’re right, I totally overlooked that feature. Unfortunately it’s not as advanced as the standard jinja2 templating in Home Assistant though so for your use-case you would need 2 if-clauses like this which is kinda ugly:

secondary_info: '[[ if(sensor.bvg_some_line.attributes.delay == 0, "On Time", sensor.bvg_some_line.attributes.delay) ]][[ if(sensor.bvg_some_line.attributes.delay == 0, "", " min delayed") ]]'

it doesn’t even work if I try to use {entity} as described in the documentation

Great to see that this component is still usefull for some. As I am still running a HA installation pre “The Great Migration” its awesome that @disrupted created a working version. Thanks! I wont have time to take care of HA or this component any time soon, so please feel free to take it from here :wink:

Kraken

2 Likes

Hi guys,

any chance that this component gets fixed so it will work after 2021.6 ?

Best
J

1 Like

You need a manifest.json, use the one from @disrupted and add a Version like e.g.
“version“:“1.0.0“

Hi @Oggymator , does that mean you have this working? I’m on Home Assistant Core 2022.5.2 with "version": "1.0.0", in the manifest.json, an updated API URL

self.url = "https://v5.bvg.transport.rest/stops/{}/departures?duration={}".format(
            self._stop_id, self._cache_size
        )

in sensor.py but still get “Platform error sensor.bvg - Integration ‘bvg’ not found.” after adding a sensor.