metbril / HomeAssistant9292OvApiSensor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HomeAssistant9292OvApiSensor

hacs_badge

A Home Assistant sensor using the 9292Ov Api for Dutch public transport companies.

Installation

HACS installation (preferred)

The easiest way to install the integration is through HACS.

First, add this repository to HACS:

  1. Open HACS from the side panel.
  2. Go to any of the sections (integrations, frontend, automation).
  3. Click on the 3 dots in the top right corner.
  4. Select "Custom repositories".
  5. Add the URL to this repository.
  6. Select "Integrations" as the category.
  7. Click the "ADD" button.

Next, add the integration to your Home Assistant:

  1. Open HACS from the side panel.
  2. Go to the sections Integrations.
  3. Click the button "Explore % Download Repositories".
  4. Search for or scroll to "Sensor 9292 OV API".
  5. Select the integration.

Now is the time to add the new platform to your Configuration.

Manual installation

Create <config_directory>/custom_components/dutch_public_transport_api/ and copy these files into the directory.

Configuration

Example config:

sensor:
  - platform: dutch_public_transport_api
    name: Amsterdam naar Vlissingen        # (required)
    station: station-amsterdam-centraal    # (required)
    destination: Vlissingen                # (required)
    show_future_departures: 2              # (optional)

name

Name of the sensor

station

The station from where the bus, tram, metro or train should depart. This can be found by following querying the 9292Ov API (reference: Thomas Brus). The 'id' field of a location will be used as station.

Example

Example query:

GET /0.1/locations?lang=nl-NL&q=amsterdam HTTP/1.1 
Host: api.9292.nl

Example response

destination

The destination is equal to the destination of the bus, tram, metro or train. This can be found by following querying the 9292Ov API (reference: Thomas Brus). The 'destinaton' field of a departure will be used as destination. Destination is used for a string compare to find the right departures, make sure it is an exact copy.

Example query:

GET /0.1/locations/station-amsterdam-centraal/departure-times?lang=nl-NL HTTP/1.1 
Host: api.9292.nl

Example response

show_future_departures

Number of future departures that should be shown, every future departure is a new sensor.

Credits

  • Paul-Dh This sensor is based on the sensor of Paul.
  • Thomas Brus Thanks for figuring the 9292OV Api out, was very useful for this sensor.

About

License:MIT License


Languages

Language:Python 100.0%