Coder Social home page Coder Social logo

ha-mvg's Introduction

Warning

This project is not an official project from the Münchner Verkehrsgesellschaft (MVG). Therefore, the following usage restrictions from the MVG Imprint do apply to all users of this home assistant integration:

Our systems are used for direct customer interaction. The processing of our content or data by third parties requires our express consent. For private, non-commercial purposes, moderate use is tolerated without our explicit consent. Any form of data mining does not constitute moderate use. We reserve the right to revoke this permission in principle or in individual cases. Please direct any questions to: [email protected]

(from https://www.mvg.de/impressum.html, accessed on 13. Nov 2023)

HACS-Plugin: MVG

The mvg sensor will give you the departure time of the next bus, tram, subway, or train at the next station or stop in the Munich public transport network. Additional details such as the line number and destination are present in the attributes.

Credits

I've copied and adapted the code from fellnerse’s PR.

Configuration

To enable this sensor, add the following lines to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: mvg
    nextdeparture:
     - station: STATION_OR_STOP_NAME

Configuration Variables

  • station (string, required):
    Name of the stop or station. Visit the MVG live web site to find valid names. Be aware, that not all data of interest might be available (i.e., bus departure-times in Haar).
  • destinations (list, optional):
    description: One or multiple final stop names, e.g., 'Feldmoching' or ['Feldmoching','Harthof']. This can be used to only consider a particular direction of travel.
  • lines (list, optional):
    description: One or more line numbers, e.g., 'U2' or ['U2','U8','N41'].
  • products (list, optional):
    One or more modes of transport (default: all 5 modes ['U-Bahn', 'Tram', 'Bus', 'S-Bahn', 'Nachteule'])
  • timeoffset (integer, optional, default: 0):
    Do not display departures leaving sooner than this number of minutes. Useful if you are a couple of minutes away from the stop.
  • number (integer, optional, default: 1):
    Store a list of departures in the attribute "departures". If you set this parameter to 3, the next three departures will be stored.
  • name (string, optional):
    You can customize the name of the sensor, which defaults to the station name.

Examples

Full configuration

The example below shows a full configuration with three sensors that showcase the various configuration options.

# Example configuration.yaml entry
sensor:
  - platform: mvg
    nextdeparture:
     - station: Hauptbahnhof
       name: Hbf
       destinations: ['Messestadt Ost','Erding']
       products: ['S-Bahn','U-Bahn']
       timeoffset: 2
     - station: Sendlinger Tor
       lines: ['U2','U8']
       number: 5
     - station: Scheidplatz
       products: ['U-Bahn']

The first sensor will return S-Bahn and U-Bahn departures to Messestadt Ost or Erding that are at least 2 minutes away. The second sensor returns U2 and U8 departures from Sendlinger Tor and stores a total of 5 departures in attributes. To retrieve the time until the second departure, you would use state_attr('sensor.ENTITY_NAME', 'departures')[1].time_in_mins. The third sensor returns all U-Bahn trains from Scheidplatz.

ha-mvg's People

Contributors

danielpotthast avatar faserf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.