|
1 | | -# Metlink Wellington Transport for Home Assistant |
2 | | - |
3 | | -This is a custom component for Home Assistant which uses |
4 | | -the [Metlink opendata API](https://opendata.metlink.org.nz/) to obtain |
5 | | -realtime departure info for Greater Wellington public transport, which can |
6 | | -then be displayed on your Home Assistant dashboard or used in automations. |
7 | | - |
8 | | - |
9 | | -## Installation |
10 | | - |
11 | | -[](https://github.com/custom-components/hacs) |
12 | | - |
13 | | -The integration can be installed using HACS. |
14 | | -If you prefer to instal manually, copy `custom_components/metlink` to your |
15 | | -installation's `config/custom_components` directory. |
16 | | - |
17 | | -### Configuration |
18 | | - |
19 | | -After installing the custom component, you still need to configure it before |
20 | | -it will do anything. |
21 | | - |
22 | | -The integration can be added from the Integrations configuration screen. |
23 | | - |
24 | | -API keys can be obtained by registering on the |
25 | | -[Metlink Developer Portal](https://opendata.metlink.org.nz/). Be sure to subscribe to the "Metlink Open Data API". Currently this is the only API they offer, and is free, but is still unsubscribed by default. |
26 | | - |
27 | | -If you prefer to configure using yaml instead of the UI, add something like |
28 | | -the following to your `config/configuration.yaml`: |
29 | | - |
30 | | -``` |
31 | | -sensor: |
32 | | - - platform: metlink |
33 | | - api_key: abcdefg1234xzy |
34 | | - stops: |
35 | | - - stop_id: 9999 |
36 | | - - stop_id: WELL |
37 | | - route: HVL |
38 | | - - stop_id: 5016 |
39 | | - destination: 3451 |
40 | | - num_departures: 3 |
41 | | -``` |
42 | | - |
43 | | - |
44 | | -`stop_id` for Train and Cable Car stops is a 4 character alphabetic |
45 | | -code, and for bus and ferry stops, is a 4 digit numeric code. |
46 | | -The IDs are on bus stop signs, or can be looked up on the |
47 | | -[Metlink](https://metlink.org.nz) main web site. |
48 | | - |
49 | | - |
50 | | -If your stop is busy with multiple routes, you can filter by route and/or destination. Currently exact matches are expected and only a single route or destination can be specified, though the destination does check the name as well as the stop id for a match, though some of the names that come through the API are abbreviated in ways that do not match the main web site so stop id will be more reliable. The destination filter is only available on the final destination, not any intermediate stops. |
51 | | - |
52 | | - |
53 | | -Each stop will create a sensor in Home Assistant, which will return the next departure time as its status. |
54 | | - |
55 | | -It will also return attributes for departure time, service, service |
56 | | -name, destination name, stop id for the destination, and status. The |
57 | | -duplication of departure time in the attributes makes more sense when |
58 | | -there is more than one result being returned. |
59 | | - |
60 | | -If more than 1 result is requested in `num_departures`, the attributes |
61 | | -will be suffixed with a number for second and subsequent departures. |
62 | | - |
63 | | -[](https://www.buymeacoffee.com/jasonrumney) |
| 1 | +# Metlink Wellington Transport for Home Assistant |
| 2 | + |
| 3 | +This is a custom component for Home Assistant which uses |
| 4 | +the [Metlink opendata API](https://opendata.metlink.org.nz/) to obtain |
| 5 | +realtime departure info for Greater Wellington public transport, which can |
| 6 | +then be displayed on your Home Assistant dashboard or used in automations. |
| 7 | + |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +[](https://github.com/custom-components/hacs) |
| 12 | + |
| 13 | +The integration can be installed using HACS. |
| 14 | +If you prefer to instal manually, copy `custom_components/metlink` to your |
| 15 | +installation's `config/custom_components` directory. |
| 16 | + |
| 17 | +### Configuration |
| 18 | + |
| 19 | +After installing the custom component, you still need to configure it before |
| 20 | +it will do anything. |
| 21 | + |
| 22 | +The integration can be added from the Integrations configuration screen. |
| 23 | + |
| 24 | +API keys can be obtained by registering on the |
| 25 | +[Metlink Developer Portal](https://opendata.metlink.org.nz/). Be sure to subscribe to the "Metlink Open Data API". Currently this is the only API they offer, and is free, but is still unsubscribed by default. |
| 26 | + |
| 27 | +If you prefer to configure using yaml instead of the UI, add something like |
| 28 | +the following to your `config/configuration.yaml`: |
| 29 | + |
| 30 | +``` |
| 31 | +sensor: |
| 32 | + - platform: metlink |
| 33 | + api_key: abcdefg1234xzy |
| 34 | + stops: |
| 35 | + - stop_id: 9999 |
| 36 | + - stop_id: WELL |
| 37 | + route: HVL |
| 38 | + - stop_id: 5016 |
| 39 | + destination: 3451 |
| 40 | + num_departures: 3 |
| 41 | +``` |
| 42 | + |
| 43 | + |
| 44 | +`stop_id` for Train and Cable Car stops is a 4 character alphabetic |
| 45 | +code, and for bus and ferry stops, is a 4 digit numeric code. |
| 46 | +The IDs are on bus stop signs, or can be looked up on the |
| 47 | +[Metlink](https://metlink.org.nz) main web site. |
| 48 | + |
| 49 | + |
| 50 | +If your stop is busy with multiple routes, you can filter by route and/or destination. Currently exact matches are expected and only a single route or destination can be specified, though the destination does check the name as well as the stop id for a match, though some of the names that come through the API are abbreviated in ways that do not match the main web site so stop id will be more reliable. The destination filter is only available on the final destination, not any intermediate stops. |
| 51 | + |
| 52 | + |
| 53 | +Each stop will create a sensor in Home Assistant, which will return the next departure time as its status. |
| 54 | + |
| 55 | +It will also return attributes for departure time, service, service |
| 56 | +name, destination name, stop id for the destination, and status. The |
| 57 | +duplication of departure time in the attributes makes more sense when |
| 58 | +there is more than one result being returned. |
| 59 | + |
| 60 | +If more than 1 result is requested in `num_departures`, the attributes |
| 61 | +will be suffixed with a number for second and subsequent departures. |
| 62 | + |
| 63 | +[](https://www.buymeacoffee.com/jasonrumney) |
0 commit comments