Skip to content

Commit 5599c02

Browse files
committed
HA 2022.3 compatibility: relax dependency requirements.
Due to stricter dependency handling, dependencies can easily conflict if pinned to a specific version. Github workflows previously warned if they were not pinned, but the problems caused by the dependency handling are more severe.
1 parent 175582c commit 5599c02

File tree

9 files changed

+293
-293
lines changed

9 files changed

+293
-293
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
name: Validate with HACS
2-
3-
on:
4-
push:
5-
pull_request:
6-
schedule:
7-
- cron: '54 0 * * THU'
8-
9-
jobs:
10-
validate:
11-
runs-on: 'ubuntu-latest'
12-
steps:
13-
- uses: 'actions/checkout@v2'
14-
- name: HACS validation
15-
uses: 'hacs/action@main'
16-
with:
17-
category: 'integration'
1+
name: Validate with HACS
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '54 0 * * THU'
8+
9+
jobs:
10+
validate:
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- uses: 'actions/checkout@v2'
14+
- name: HACS validation
15+
uses: 'hacs/action@main'
16+
with:
17+
category: 'integration'

README.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
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-
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](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-
[![BuyMeCoffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](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+
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](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+
[![BuyMeCoffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/jasonrumney)
Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
1-
"""Metlink Wellington Transport integration."""
2-
import asyncio
3-
import logging
4-
5-
from homeassistant import config_entries, core
6-
7-
from .const import DOMAIN
8-
9-
_LOGGER = logging.getLogger(__name__)
10-
11-
12-
async def async_setup_entry(
13-
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
14-
) -> bool:
15-
"""Set up platform from a ConfigEntry."""
16-
hass.data.setdefault(DOMAIN, {})
17-
data = {**entry.data, **entry.options}
18-
# Register an update listener to refresh when options are updated.
19-
update_listener = entry.add_update_listener(options_update_listener)
20-
data["unsub_options_update_listener"] = update_listener
21-
hass.data[DOMAIN][entry.entry_id] = data
22-
23-
# Forward the setup to the sensor platform.
24-
_LOGGER.debug(f"Setting up based on {entry.data}")
25-
hass.async_create_task(
26-
hass.config_entries.async_forward_entry_setup(entry, "sensor")
27-
)
28-
return True
29-
30-
31-
async def options_update_listener(
32-
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry
33-
):
34-
"""Handle options update."""
35-
_LOGGER.debug("Reloading config after options update")
36-
await hass.config_entries.async_reload(config_entry.entry_id)
37-
38-
39-
async def async_unload_entry(
40-
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
41-
) -> bool:
42-
"""Unload a config entry."""
43-
_LOGGER.debug("Unloading")
44-
unload_ok = all(
45-
await asyncio.gather(
46-
*[hass.config_entries.async_forward_entry_unload(entry, "sensor")]
47-
)
48-
)
49-
# Remove the listener
50-
hass.data[DOMAIN][entry.entry_id]["unsub_options_update_listener"]()
51-
52-
# Remove from domain
53-
if unload_ok:
54-
hass.data[DOMAIN].pop(entry.entry_id)
55-
else:
56-
_LOGGER.warning("Unload failed")
57-
58-
return unload_ok
59-
60-
61-
async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
62-
"""Setup the Metlink component from yaml configuration."""
63-
_LOGGER.debug("Setting up from YAML config")
64-
hass.data.setdefault(DOMAIN, {})
65-
return True
1+
"""Metlink Wellington Transport integration."""
2+
import asyncio
3+
import logging
4+
5+
from homeassistant import config_entries, core
6+
7+
from .const import DOMAIN
8+
9+
_LOGGER = logging.getLogger(__name__)
10+
11+
12+
async def async_setup_entry(
13+
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
14+
) -> bool:
15+
"""Set up platform from a ConfigEntry."""
16+
hass.data.setdefault(DOMAIN, {})
17+
data = {**entry.data, **entry.options}
18+
# Register an update listener to refresh when options are updated.
19+
update_listener = entry.add_update_listener(options_update_listener)
20+
data["unsub_options_update_listener"] = update_listener
21+
hass.data[DOMAIN][entry.entry_id] = data
22+
23+
# Forward the setup to the sensor platform.
24+
_LOGGER.debug(f"Setting up based on {entry.data}")
25+
hass.async_create_task(
26+
hass.config_entries.async_forward_entry_setup(entry, "sensor")
27+
)
28+
return True
29+
30+
31+
async def options_update_listener(
32+
hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry
33+
):
34+
"""Handle options update."""
35+
_LOGGER.debug("Reloading config after options update")
36+
await hass.config_entries.async_reload(config_entry.entry_id)
37+
38+
39+
async def async_unload_entry(
40+
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
41+
) -> bool:
42+
"""Unload a config entry."""
43+
_LOGGER.debug("Unloading")
44+
unload_ok = all(
45+
await asyncio.gather(
46+
*[hass.config_entries.async_forward_entry_unload(entry, "sensor")]
47+
)
48+
)
49+
# Remove the listener
50+
hass.data[DOMAIN][entry.entry_id]["unsub_options_update_listener"]()
51+
52+
# Remove from domain
53+
if unload_ok:
54+
hass.data[DOMAIN].pop(entry.entry_id)
55+
else:
56+
_LOGGER.warning("Unload failed")
57+
58+
return unload_ok
59+
60+
61+
async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
62+
"""Setup the Metlink component from yaml configuration."""
63+
_LOGGER.debug("Setting up from YAML config")
64+
hass.data.setdefault(DOMAIN, {})
65+
return True

custom_components/metlink/const.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
# Copyright 2021 Jason Rumney
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# https://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
DOMAIN = "metlink"
16-
ATTRIBUTION = "Data provided by Greater Wellington Regional Council"
17-
18-
CONF_STOPS = "stops"
19-
CONF_STOP_ID = "stop_id"
20-
CONF_DEST = "destination"
21-
CONF_ROUTE = "route"
22-
CONF_NUM_DEPARTURES = "num_departures"
23-
24-
ATTR_ACCESSIBLE = "wheelchair_accessible"
25-
ATTR_AIMED = "aimed"
26-
ATTR_ARRIVAL = "arrival"
27-
ATTR_CLOSED = "closed"
28-
ATTR_DELAY = "delay"
29-
ATTR_DEPARTURE = "departure"
30-
ATTR_DEPARTURES = "departures"
31-
ATTR_DESCRIPTION = "description"
32-
ATTR_DESTINATION = "destination"
33-
ATTR_DESTINATION_ID = "destination_id"
34-
ATTR_DIRECTION = "direction"
35-
ATTR_EXPECTED = "expected"
36-
ATTR_FAREZONE = "farezone"
37-
ATTR_MONITORED = "monitored"
38-
ATTR_NAME = "name"
39-
ATTR_OPERATOR = "operator"
40-
ATTR_ORIGIN = "origin"
41-
ATTR_SERVICE = "service_id"
42-
ATTR_STATUS = "status"
43-
ATTR_STOP = "stop_id"
44-
ATTR_STOP_NAME = "stop_name"
45-
ATTR_VEHICLE = "vehicle_id"
1+
# Copyright 2021 Jason Rumney
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
DOMAIN = "metlink"
16+
ATTRIBUTION = "Data provided by Greater Wellington Regional Council"
17+
18+
CONF_STOPS = "stops"
19+
CONF_STOP_ID = "stop_id"
20+
CONF_DEST = "destination"
21+
CONF_ROUTE = "route"
22+
CONF_NUM_DEPARTURES = "num_departures"
23+
24+
ATTR_ACCESSIBLE = "wheelchair_accessible"
25+
ATTR_AIMED = "aimed"
26+
ATTR_ARRIVAL = "arrival"
27+
ATTR_CLOSED = "closed"
28+
ATTR_DELAY = "delay"
29+
ATTR_DEPARTURE = "departure"
30+
ATTR_DEPARTURES = "departures"
31+
ATTR_DESCRIPTION = "description"
32+
ATTR_DESTINATION = "destination"
33+
ATTR_DESTINATION_ID = "destination_id"
34+
ATTR_DIRECTION = "direction"
35+
ATTR_EXPECTED = "expected"
36+
ATTR_FAREZONE = "farezone"
37+
ATTR_MONITORED = "monitored"
38+
ATTR_NAME = "name"
39+
ATTR_OPERATOR = "operator"
40+
ATTR_ORIGIN = "origin"
41+
ATTR_SERVICE = "service_id"
42+
ATTR_STATUS = "status"
43+
ATTR_STOP = "stop_id"
44+
ATTR_STOP_NAME = "stop_name"
45+
ATTR_VEHICLE = "vehicle_id"

0 commit comments

Comments
 (0)