home-assistant.io/source/_components/sensor.transport_nsw.markdown
Dav0815 7156cef2dc Add destination and icon; few more samples (#7365)
* Add destination and icon; few more samples

* Minor changes
2018-11-05 08:46:01 +01:00

2.9 KiB

layout, title, description, date, sidebar, comments, sharing, footer, logo, ha_category, ha_iot_class, ha_release
layout title description date sidebar comments sharing footer logo ha_category ha_iot_class ha_release
page Transport NSW Instructions on how to integrate timetable data for Transport NSW (Australia) within Home Assistant. 2018-10-05 00:00 true false true true transport_nsw.png Transport Cloud Polling 0.81

The transport_nsw sensor will give you the time until the next departure from a Transport NSW stop for bus, train, light rail or ferry.

{% linkable_title Setup %}

Prerequisite is a free API key from Transport NSW.

In order to find your stop id, go to Google maps and click on any bus/train/ferry stop. The pop up window shows the stop ID underneath the station name. For train stations the easist way to get a stop id for a platform is through Transport NSW Info.

As a default the sensor picks up the next mode of transport leaving from a stop id.

{% linkable_title Configuration %}

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

# Example configuration.yaml entry
sensor:
  - platform: transport_nsw
    stop_id: '200024'
    api_key: 'YOUR API KEY'

{% configuration %} api_key: description: Your API key for Open Data Transport NSW. required: true type: string stop_id: description: The ID of the stop to get the information for. required: true type: string route: description: Filter on bus route at the stop. This is the same as the bus number, e.g., 83. required: false type: string destination: description: Useful for ferry or train stops to filter the destination of the sensor, e.g. Circular Quay. required: false type: string name: description: A friendly name for this sensor. required: false type: string {% endconfiguration %}

The public information is provided from Transport NSW.

{% linkable_title Examples %}

More example configurations for bus or ferry.

# Example bus route configuration.yaml entry
sensor:
  - platform: transport_nsw
    name: 'Bus'
    stop_id: '209516'
    route:  '199'
    api_key: 'YOUR API KEY'
# Example ferry configuration.yaml entry
sensor:
  - platform: transport_nsw
    name: 'Ferry'
    stop_id: '10102008'
    destination: 'Circular Quay'
    api_key: 'YOUR API KEY'

The sensor returns n/a if no stop event is found within the next 24h. A template sensor can help building a more meaninful string.

{% raw %}

# Sample template sensor
- platform: template
  sensors:
    busmonitor:
      friendly_name: "Bus Mon 199"
      value_template: >-
        {% if is_state_attr('sensor.bus', 'due', 'n/a') %}
          No schedule found
        {% else %}
          {{ states.sensor.bus.attributes.route }} in {{ states.sensor.bus.attributes.due }}m ({{ states.sensor.bus.attributes.delay }})
        {% endif %}

{% endraw %}