From 28c7af94073becf9aa8720a6164d073d9bd32f85 Mon Sep 17 00:00:00 2001 From: Dav0815 Date: Mon, 5 Nov 2018 09:47:34 +1100 Subject: [PATCH 1/2] Add destination and icon; few more samples --- .../_components/sensor.transport_nsw.markdown | 57 ++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/source/_components/sensor.transport_nsw.markdown b/source/_components/sensor.transport_nsw.markdown index 9ddf794d0695..319db5089060 100644 --- a/source/_components/sensor.transport_nsw.markdown +++ b/source/_components/sensor.transport_nsw.markdown @@ -14,15 +14,15 @@ ha_release: 0.81 --- -The `transport_nsw` sensor will give you the time until the next departure from a Transport NSW stop (bus, train or ferry). +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. -Get your free API key from [Transport NSW](https://opendata.transport.nsw.gov.au/). +Prerequisite is a free API key from [Transport NSW](https://opendata.transport.nsw.gov.au/). -In order to find the stop id, just go to Google maps and click on the bus/train/ferry stop. It will give you there the stop ID. +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](https://transportnsw.info/). -You can define a bus line, but if you don’t do it, the sensor will pick up the next stop event from any line servicing this stop. +As a default the sensor picks up the next mode of transport leaving from a stop id. -Then add the data to your `configuration.yaml` file as shown in the example: +Minimum sample entries for `configuration.yaml` are the following: ```yaml # Example configuration.yaml entry @@ -42,7 +42,11 @@ stop_id: required: true type: string route: - description: Only show a single bus route at the stop. This is the same as the bus number, e.g., `83` + 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: @@ -51,4 +55,43 @@ name: type: string {% endconfiguration %} -The public information is coming from [Transport NSW](https://opendata.transport.nsw.gov.au/). +The public information is provided from [Transport NSW](https://opendata.transport.nsw.gov.au/). + +{% Examples %} +More example configurations for Bus or Ferry. + +```yaml +# Example bus route configuration.yaml entry +sensor: + - platform: transport_nsw + name: 'Bus' + stop_id: '209516' + route: '199' + api_key: 'YOUR API KEY' +``` + +```yaml +# 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. + +```yaml +# 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 %} +``` From 7c19bed7424a21e2ba029b99d98ab49bc96056ed Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 5 Nov 2018 08:31:10 +0100 Subject: [PATCH 2/2] Minor changes --- .../_components/sensor.transport_nsw.markdown | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/source/_components/sensor.transport_nsw.markdown b/source/_components/sensor.transport_nsw.markdown index 319db5089060..8296ffdedea7 100644 --- a/source/_components/sensor.transport_nsw.markdown +++ b/source/_components/sensor.transport_nsw.markdown @@ -16,13 +16,17 @@ ha_release: 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](https://opendata.transport.nsw.gov.au/). 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](https://transportnsw.info/). As a default the sensor picks up the next mode of transport leaving from a stop id. -Minimum sample entries for `configuration.yaml` are the following: +## {% linkable_title Configuration %} + +To enable the sensor, add the following lines to your `configuration.yaml` file: ```yaml # Example configuration.yaml entry @@ -34,19 +38,19 @@ sensor: {% configuration %} api_key: - description: Your API key for Open Data Transport NSW + 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 + 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` + 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` + description: Useful for ferry or train stops to filter the destination of the sensor, e.g. `Circular Quay`. required: false type: string name: @@ -57,8 +61,9 @@ name: The public information is provided from [Transport NSW](https://opendata.transport.nsw.gov.au/). -{% Examples %} -More example configurations for Bus or Ferry. +## {% linkable_title Examples %} + +More example configurations for bus or ferry. ```yaml # Example bus route configuration.yaml entry @@ -80,8 +85,9 @@ sensor: 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. +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 %} ```yaml # Sample template sensor - platform: template @@ -95,3 +101,4 @@ The sensor returns n/a if no stop event is found within the next 24h. A Template {{ states.sensor.bus.attributes.route }} in {{ states.sensor.bus.attributes.due }}m ({{ states.sensor.bus.attributes.delay }}) {% endif %} ``` +{% endraw %}