Added Australian Captial Territory Source (#1059)

* Added ACT Source

* Changed to use a icon dict.

* Added split_suburb

* act_gov_au.md reformatting small fix
fixing
- typos
- invalid link
- adding split_Suburb to configuration section

---------

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
eddster2309
2023-07-05 07:12:26 +10:00
committed by GitHub
parent 7ea7a22103
commit fc65ec9d90
4 changed files with 123 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ Waste collection schedules in the following formats and countries are supported.
<details>
<summary>Australia</summary>
- [Australian Capital Territory (ACT)](/doc/source/act_gov_au.md) / cityservices.act.gov.au/recycling-and-waste
- [Banyule City Council](/doc/source/banyule_vic_gov_au.md) / banyule.vic.gov.au
- [Belmont City Council](/doc/source/belmont_wa_gov_au.md) / belmont.wa.gov.au
- [Brisbane City Council](/doc/source/brisbane_qld_gov_au.md) / brisbane.qld.gov.au

View File

@@ -0,0 +1,72 @@
from datetime import datetime
from waste_collection_schedule import Collection
import requests
TITLE = "Australian Capital Territory (ACT)"
DESCRIPTION = "Source script for Australian Capital Territory (ACT)."
URL = "https://www.cityservices.act.gov.au/recycling-and-waste"
TEST_CASES = {
"Bruce": {"suburb": "Bruce"},
"Amaroo": {"suburb": "amaroo"},
"Charnwood Thursday": {"suburb": "CHARNWOOD", "split_suburb": "Thursday"},
"Charnwood Tuesday": {"suburb": "CHARNWOOD", "split_suburb": "Tuesday"},
"Dunlop North": {"suburb": "DUNLOP", "split_suburb": "NORTH"},
"Dunlop South": {"suburb": "DUNLOP", "split_suburb": "south"}
}
API_URL = "https://www.data.act.gov.au/resource/jzzy-44un.json"
ICON_MAP = {
"Garbage": "mdi:trash-can",
"Recycle": "mdi:recycle",
"Organic": "mdi:leaf",
}
class Source:
def __init__(self, suburb, split_suburb = ""): # argX correspond to the args dict in the source configuration
self.suburb = suburb
self.split_suburb = split_suburb
def fetch(self):
suburb = self.suburb.upper()
split_suburb = self.split_suburb.capitalize()
if split_suburb != "":
r=requests.get(API_URL, params={"suburb": suburb, "split_suburb": split_suburb})
else:
r=requests.get(API_URL, params={"suburb": suburb})
if len(r.json()) == 0:
return []
data = r.json()[0]
entries = [] # List that holds collection schedule
entries.append(
Collection(
date = datetime.strptime(data["garbage_pickup_date"], "%d/%m/%Y").date(), # Collection date
t = "Garbage", # Collection type
icon = ICON_MAP["Garbage"], # Collection icon
)
)
entries.append(
Collection(
date = datetime.strptime(data["recycling_pickup_date"], "%d/%m/%Y").date(), # Collection date
t = "Recycle", # Collection type
icon = ICON_MAP["Recycle"], # Collection icon
)
)
entries.append(
Collection(
date = datetime.strptime(data["next_greenwaste_date"], "%d/%m/%Y").date(), # Collection date
t = "Organic", # Collection type
icon = ICON_MAP["Organic"], # Collection icon
)
)
return entries

49
doc/source/act_gov_au.md Normal file
View File

@@ -0,0 +1,49 @@
# Australian Captial Territory (ACT)
Support for schedules provided by [ACT Goverment City Services](https://www.cityservices.act.gov.au/).
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: act_gov_au
args:
suburb: SUBURB
split_Suburb: SPLIT SUBURB
```
### Configuration Variables
**suburb**
*(string) (required)*
**split_suburb**
*(string) (optional)*
## Examples
### Without split_suburb
```yaml
waste_collection_schedule:
sources:
- name: act_gov_au
args:
suburb: BRUCE
```
### With split_suburb
```yaml
waste_collection_schedule:
sources:
- name: act_gov_au
args:
suburb: DUNLOP
split_Suburb: North
```
## How to get the source arguments
Visit the [ACT City Service's Bin Collection Calendar](https://www.cityservices.act.gov.au/recycling-and-waste/collection/bin-collection-calendar) page and look for your suburb. The suburb argument should be in all uppercase of what is found in the dropdown. Some suburbs like Charnwood and Dunlop have been split into multiple entries, to check if your suburb has been split go to the API: [https://www.data.act.gov.au/resource/jzzy-44un.json?suburb=SUBURB](https://www.data.act.gov.au/resource/jzzy-44un.json?suburb=SUBURB) and swap `SUBURB` for your suburb in uppercase, and check if more than one result is returned, if there is the `split_suburb` argument should be equal to `split_suburb` in your correct API result. For example Dunlop is split into north and south so the `split_suburb` argument would be equal to `North` or `South`.

View File

@@ -16,7 +16,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|--|--|
| Generic | ICS / iCal files |
| Static | User-defined dates or repeating date patterns |<!--Begin of country section-->
| Australia | Banyule City Council, Belmont City Council, Brisbane City Council, Campbelltown City Council (NSW), Cardinia Shire Council, City of Canada Bay Council, City of Kingston, City of Onkaparinga Council, Cumberland Council (NSW), Gold Coast City Council, Hume City Council, Inner West Council (NSW), Ipswich City Council, Ku-ring-gai Council, Lake Macquarie City Council, Macedon Ranges Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Nillumbik Shire Council, North Adelaide Waste Management Authority, Port Adelaide Enfield, South Australia, RecycleSmart, Stonnington City Council, The Hills Shire Council, Sydney, Unley City Council (SA), Whittlesea City Council, Wollongong City Council, Wyndham City Council, Melbourne |
| Australia | Australian Capital Territory (ACT), Banyule City Council, Belmont City Council, Brisbane City Council, Campbelltown City Council (NSW), Cardinia Shire Council, City of Canada Bay Council, City of Kingston, City of Onkaparinga Council, Cumberland Council (NSW), Gold Coast City Council, Hume City Council, Inner West Council (NSW), Ipswich City Council, Ku-ring-gai Council, Lake Macquarie City Council, Macedon Ranges Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Nillumbik Shire Council, North Adelaide Waste Management Authority, Port Adelaide Enfield, South Australia, RecycleSmart, Stonnington City Council, The Hills Shire Council, Sydney, Unley City Council (SA), Whittlesea City Council, Wollongong City Council, Wyndham City Council, Melbourne |
| Austria | Andau, Apetlon, App CITIES, Bad Blumau, Bad Gleichenberg, Bad Loipersdorf, Bad Radkersburg, Bad Tatzmannsdorf, Bildein, Breitenbrunn am Neusiedler See, Breitenstein, Bruckneudorf, Buch - St. Magdalena, Burgau, Burgenländischer Müllverband, Dechantskirchen, Deutsch Goritz, Deutsch Jahrndorf, Deutsch Kaltenbrunn, Deutschkreutz, Dobl-Zwaring, Draßmarkt, Eberau, Eberndorf, Eberstein, Edelsbach bei Feldbach, Eggersdorf bei Graz, Eisenstadt, Fehring, Feistritz ob Bleiburg, Feldbach, Frankenau-Unterpullendorf, Frauenkirchen, Freistadt, Friedberg, Fürstenfeld, Gabersdorf, Gattendorf, Gols, Grafendorf bei Hartberg, Grafenstein, Gratkorn, Großwarasdorf, Großwilfersdorf, Gutenberg-Stenzengreith, Güssing, Hartberg, Heiligenkreuz am Waasen, Hofstätten an der Raab, Horitschon, Hornstein, Hüttenberg, Ilz, infeo, Innsbrucker Kommunalbetriebe, Jabing, Jagerberg, Kaindorf, Kaisersdorf, Kalsdorf bei Graz, Kapfenstein, Kirchberg an der Raab, Kleinmürbisch, Klingenbach, Klöch, Kohfidisch, Korneuburg, Laa an der Thaya, Leithaprodersdorf, Lieboch, Litzelsdorf, Loipersbach im Burgenland, Mariasdorf, Markt Hartmannsdorf, Markt Neuhodis, Marz, Mattersburg, Melk, Mettersdorf am Saßbach, Mischendorf, Mistelbach, Mitterdorf an der Raab, Mureck, Mörbisch am See, Neudorf bei Parndorf, Neufeld an der Leitha, Neusiedl am See, Nickelsdorf, Oberpullendorf, Oberwart, Oslip, Ottendorf an der Rittschein, Paldau, Pamhagen, Parndorf, Peggau, Pernegg an der Mur, Pilgersdorf, Pinggau, Pinkafeld, Podersdorf am See, Poggersdorf, Potzneusiedl, Poysdorf, Pöchlarn, Radmer, Ragnitz, Raiding, Rudersdorf, Rust, Saalfelden am Steinernen Meer, Sankt Oswald bei Plankenwarth, Schäffern, Schützen am Gebirge, Seiersberg-Pirka, Sigleß, Sinabelkirchen, St. Andrä, St. Anna am Aigen, St. Johann in der Haide, St. Lorenzen am Wechsel, St. Margarethen an der Raab, St. Margarethen im Burgenland, St. Peter - Freienstein, St. Peter am Ottersbach, St. Ruprecht an der Raab, St. Veit in der Südsteiermark, Stadt Salzburg, Stadtservice Korneuburg, Stegersbach, Steinbrunn, Steuerberg, Stinatz, Stiwoll, Stockerau, Söchau, Thal, Tieschen, Tulln an der Donau, Umweltprofis, Unterfrauenhaid, Unterkohlstätten, Unterlamm, Vasoldsberg, Vordernberg, Völkermarkt, Weiz, Werfenweng, Wies, Wiesen, Wiesfleck, Wimpassing an der Leitha, Winden am See, Wolfsberg, Wolkersdorf im Weinviertel, WSZ Moosburg, Zagersdorf, Zillingtal, Zurndorf, Übelbach |
| Belgium | Hygea, Limburg.net, Recycle! |
| Canada | City of Toronto, London, Ontario, Canada |