add wollondilly_nsw_gov_au

This commit is contained in:
5ila5
2024-01-31 19:06:51 +01:00
committed by 5ila5
parent f358a92303
commit 7ee931b131
4 changed files with 96 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ Waste collection schedules in the following formats and countries are supported.
- [The Hills Shire Council, Sydney](/doc/source/thehills_nsw_gov_au.md) / thehills.nsw.gov.au
- [Unley City Council (SA)](/doc/source/unley_sa_gov_au.md) / unley.sa.gov.au
- [Whittlesea City Council](/doc/source/whittlesea_vic_gov_au.md) / whittlesea.vic.gov.au/community-support/my-neighbourhood
- [Wollondilly Shire Council](/doc/source/wollondilly_nsw_gov_au.md) / wollondilly.nsw.gov.au
- [Wollongong City Council](/doc/source/wollongongwaste_com_au.md) / wollongongwaste.com
- [Wyndham City Council, Melbourne](/doc/source/wyndham_vic_gov_au.md) / wyndham.vic.gov.au
- [Yarra Ranges Council](/doc/source/yarra_ranges_vic_gov_au.md) / yarraranges.vic.gov.au

View File

@@ -0,0 +1,60 @@
from datetime import datetime
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "Wollondilly Shire Council"
DESCRIPTION = "Source for Wollondilly Shire Council."
URL = "https://www.wollondilly.nsw.gov.au/"
TEST_CASES = {
"87 Remembrance Driveway TAHMOOR NSW": {
"address": "87 Remembrance Driveway TAHMOOR NSW"
},
"Thirlmere Way THIRLMERE NSW": {"address": "Thirlmere Way THIRLMERE NSW"},
}
ICON_MAP = {
"garbage": "mdi:trash-can",
"garden organic": "mdi:leaf",
"recycling": "mdi:recycle",
}
ADDRESS_URL = "https://yokqi4ofx1.execute-api.ap-southeast-2.amazonaws.com/Live/wcc_address_lookup"
INFO_URL = "https://yokqi4ofx1.execute-api.ap-southeast-2.amazonaws.com/Live/wcc_details_lookup"
class Source:
def __init__(self, address: str):
self._address: str = address
def fetch(self):
args = {"fields": self._address}
r = requests.get(ADDRESS_URL, params=args)
r.raise_for_status()
data = r.json()
if len(data) == 0:
raise Exception("Address not found")
id = data[0][1]["value"]
args = {"fields": id}
r = requests.get(INFO_URL, params=args)
r.raise_for_status()
data = r.json()
entries = []
for collection in data[0]:
if "WasteNextPickup" not in collection["name"]:
continue
info_arr = collection["value"].split(", ")
date_str = info_arr[1]
collection_str = info_arr[2]
date = datetime.strptime(date_str, "%d %B %Y").date()
collection_types = collection_str.split(" and ")
for col_type in collection_types:
icon = ICON_MAP.get(col_type.lower())
entries.append(Collection(date=date, t=col_type, icon=icon))
return entries

View File

@@ -0,0 +1,34 @@
# Wollondilly Shire Council
Support for schedules provided by [Wollondilly Shire Council](https://www.wollondilly.nsw.gov.au/), serving Wollondilly Shire Council, Australia.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: wollondilly_nsw_gov_au
args:
address: ADDRESS
```
### Configuration Variables
**address**
*(String) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: wollondilly_nsw_gov_au
args:
address: 87 Remembrance Driveway TAHMOOR NSW
```
## How to get the source argument
Find the parameter of your address using [https://www.wollondilly.nsw.gov.au/waste-services/lookup-your-clean-up-details](https://www.wollondilly.nsw.gov.au/waste-services/lookup-your-clean-up-details) and write them exactly like on the web page.

File diff suppressed because one or more lines are too long