mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Support for Yarra Ranges Victoria, Australia (#1519)
* Support for Yarra Ranges Victoria, Australia * Create yarra_ranges_vic_gov_au.md * Update yarra_ranges_vic_gov_au.py * Update yarra_ranges_vic_gov_au.py Ignored burning off events as they don't have dates and cause an error * refactoring + reformatting + ./update_docu_links.py --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ repos:
|
||||
hooks:
|
||||
- id: codespell
|
||||
args:
|
||||
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,Adresse,termine,adresse,oder,alle,assistent,hart,marz,worthing,linz
|
||||
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,Adresse,termine,adresse,oder,alle,assistent,hart,marz,worthing,linz,celle,vor
|
||||
- --skip="./.*,*.csv,*.json"
|
||||
- --quiet-level=2
|
||||
exclude_types: [csv, json]
|
||||
|
||||
@@ -62,6 +62,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Whittlesea City Council](/doc/source/whittlesea_vic_gov_au.md) / whittlesea.vic.gov.au/community-support/my-neighbourhood
|
||||
- [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
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "Yarra Ranges Council"
|
||||
DESCRIPTION = "Source for Yarra Ranges Council rubbish collection."
|
||||
URL = "https://www.yarraranges.vic.gov.au"
|
||||
TEST_CASES = {
|
||||
"Petstock Lilydale": {"street_address": "447-449 Maroondah Hwy, Lilydale VIC 3140"},
|
||||
"Beechworth Bakery Healesville": {
|
||||
"street_address": "316 Maroondah Hwy, Healesville VIC 3777"
|
||||
},
|
||||
}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ICON_MAP = {
|
||||
"New weekly FOGO collection": "mdi:leaf",
|
||||
"Rubbish Collection": "mdi:sofa",
|
||||
"Recycling Collection": "mdi:recycle",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, street_address):
|
||||
self._street_address = street_address
|
||||
|
||||
def fetch(self):
|
||||
session = requests.Session()
|
||||
|
||||
response = session.get(
|
||||
"https://www.yarraranges.vic.gov.au/Environment/Waste/Find-your-waste-collection-and-burning-off-dates"
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
response = session.get(
|
||||
"https://www.yarraranges.vic.gov.au/api/v1/myarea/search",
|
||||
params={"keywords": self._street_address},
|
||||
)
|
||||
response.raise_for_status()
|
||||
addressSearchApiResults = response.json()
|
||||
if (
|
||||
addressSearchApiResults["Items"] is None
|
||||
or len(addressSearchApiResults["Items"]) < 1
|
||||
):
|
||||
raise Exception(
|
||||
f"Address search for '{self._street_address}' returned no results. Check your address on https://www.yarraranges.vic.gov.au/Environment/Waste/Find-your-waste-collection-and-burning-off-dates"
|
||||
)
|
||||
|
||||
addressSearchTopHit = addressSearchApiResults["Items"][0]
|
||||
_LOGGER.debug("Address search top hit: %s", addressSearchTopHit)
|
||||
|
||||
geolocationid = addressSearchTopHit["Id"]
|
||||
_LOGGER.debug("Geolocationid: %s", geolocationid)
|
||||
|
||||
response = session.get(
|
||||
"https://www.yarraranges.vic.gov.au/ocapi/Public/myarea/wasteservices",
|
||||
params={"geolocationid": geolocationid, "ocsvclang": "en-AU"},
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
wasteApiResult = response.json()
|
||||
_LOGGER.debug("Waste API result: %s", wasteApiResult)
|
||||
|
||||
soup = BeautifulSoup(wasteApiResult["responseContent"], "html.parser")
|
||||
|
||||
entries = []
|
||||
for article in soup.find_all("article"):
|
||||
waste_type = article.h3.string
|
||||
icon = ICON_MAP.get(waste_type)
|
||||
|
||||
if waste_type == "Burning off":
|
||||
continue
|
||||
|
||||
next_pickup = article.find(class_="next-service").string.strip()
|
||||
|
||||
if not re.match(r"[^\s]* \d{1,2}\/\d{1,2}\/\d{4}", next_pickup):
|
||||
continue
|
||||
|
||||
next_pickup_date = datetime.strptime(
|
||||
next_pickup.split(sep=" ")[1], "%d/%m/%Y"
|
||||
).date()
|
||||
|
||||
if next_pickup_date is None or waste_type is None:
|
||||
continue
|
||||
|
||||
entries.append(Collection(date=next_pickup_date, t=waste_type, icon=icon))
|
||||
|
||||
return entries
|
||||
32
doc/source/yarra_ranges_vic_gov_au.md
Normal file
32
doc/source/yarra_ranges_vic_gov_au.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Yarra Ranges Council
|
||||
|
||||
Support for schedules provided by [Yarra Ranges Council](https://www.yarraranges.vic.gov.au/Environment/Waste/Find-your-waste-collection-and-burning-off-dates).
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: yarra_ranges_vic_gov_au
|
||||
args:
|
||||
street_address: STREET_ADDRESS
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**street_address**
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: yarra_ranges_vic_gov_au
|
||||
args:
|
||||
street_address: 316 Maroondah Hwy, Healesville VIC 3777
|
||||
```
|
||||
|
||||
## How to get the source arguments
|
||||
|
||||
Visit the [Yarra Ranges Council](https://www.yarraranges.vic.gov.au/Environment/Waste/Find-your-waste-collection-and-burning-off-dates) page and search for your address. The arguments should exactly match the street address shown in the autocomplete result.
|
||||
2
info.md
2
info.md
@@ -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 | Armadale (Western Australia), Australian Capital Territory (ACT), Banyule City Council, Belmont City Council, Blacktown City Council (NSW), Brisbane City Council, Campbelltown City Council (NSW), Cardinia Shire Council, City of Canada Bay Council, City of Greater Geelong, 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, Logan City Council, Macedon Ranges Shire Council, Mansfield Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Moreton Bay, Nillumbik Shire Council, North Adelaide Waste Management Authority, Port Adelaide Enfield, South Australia, RecycleSmart, Shellharbour City Council, Stonnington City Council, The Hills Shire Council, Sydney, Unley City Council (SA), Whittlesea City Council, Wollongong City Council, Wyndham City Council, Melbourne |
|
||||
| Australia | Armadale (Western Australia), Australian Capital Territory (ACT), Banyule City Council, Belmont City Council, Blacktown City Council (NSW), Brisbane City Council, Campbelltown City Council (NSW), Cardinia Shire Council, City of Canada Bay Council, City of Greater Geelong, 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, Logan City Council, Macedon Ranges Shire Council, Mansfield Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Moreton Bay, Nillumbik Shire Council, North Adelaide Waste Management Authority, Port Adelaide Enfield, South Australia, RecycleSmart, Shellharbour City Council, Stonnington City Council, The Hills Shire Council, Sydney, Unley City Council (SA), Whittlesea City Council, Wollongong City Council, Wyndham City Council, Melbourne, Yarra Ranges Council |
|
||||
| Austria | Abfallverband Hollabrunn, Abfallverband Korneuburg, Abfallverband Schwechat, Abfallwirtschaft Stadt Krems, Abfallwirtschaft Stadt St Pölten, Altenmarkt an der Triesting, Andau, Apetlon, App CITIES, AWV Neunkirchen, AWV Wr. Neustadt, Bad Blumau, Bad Gleichenberg, Bad Loipersdorf, Bad Radkersburg, Bad Tatzmannsdorf, Bad Waltersdorf, Bernstein, Bildein, Breitenbrunn am Neusiedler See, Breitenstein, Bromberg, Bruckneudorf, Buch - St. Magdalena, Burgau, Burgauberg-Neudauberg, Burgenländischer Müllverband, Dechantskirchen, Deutsch Goritz, Deutsch Jahrndorf, Deutsch Kaltenbrunn, Deutschkreutz, Die NÖ Umweltverbände, Dobl-Zwaring, Drasenhofen, Draßmarkt, Eberau, Eberndorf, Ebersdorf, Eberstein, Edelsbach bei Feldbach, Eggenburg, Eggersdorf bei Graz, Eichgraben, Eisenstadt, Fehring, Feistritz ob Bleiburg, Feldbach, Feldkirchen in Kärnten, Ferndorf, Frankenau-Unterpullendorf, Frauenkirchen, Freistadt, Fresach, Friedberg, Frohnleiten, Fürstenfeld, Gabersdorf, GABL, Gattendorf, GAUL Laa an der Thaya, GAUM Mistelbach, GDA Amstetten, Gemeindeverband Horn, Gitschtal, Gols, Grafendorf bei Hartberg, Grafenschachen, Grafenstein, Gratkorn, Gratwein-Straßengel, Großsteinbach, Großwarasdorf, Großwilfersdorf, Gutenberg, GV Gmünd, GV Krems, GV Zwettl, GVA Baden, GVA Baden, GVA Lilienfeld, GVA Mödling, GVA Tulln, GVA Waidhofen/Thaya, GVU Bezirk Gänserndorf, GVU Melk, GVU Scheibbs, GVU Scheibbs, GVU St. Pölten, Güssing, Hagenberg im Mühlkreis, Hannersdorf, Hartberg, Heiligenkreuz, Heiligenkreuz am Waasen, Heimschuh, Henndorf am Wallersee, Hirm, Hofstätten an der Raab, Horitschon, Horn, Hornstein, Hüttenberg, Ilz, infeo, Innsbrucker Kommunalbetriebe, Inzenhof, Jabing, Jagerberg, Kaindorf, Kaisersdorf, Kalsdorf bei Graz, Kapfenstein, Kemeten, Kirchbach-Zerlach, Kirchberg an der Raab, Kittsee, Kleinmürbisch, Klingenbach, Klosterneuburg, Klöch, Kobersdorf, Kohfidisch, Korneuburg, Krensdorf, Kuchl, Laa an der Thaya, Lackenbach, Lackendorf, Langau, Langenrohr, Leithaprodersdorf, Leutschach an der Weinstraße, Lieboch, Linz AG, Litzelsdorf, Lockenhaus, Loipersbach im Burgenland, Mariasdorf, Markt Hartmannsdorf, Markt Neuhodis, Marktgemeinde Edlitz, Marz, Mattersburg, Meiseldorf, Melk, Mettersdorf am Saßbach, Miesenbach, Mischendorf, Mistelbach, Mitterdorf an der Raab, Mureck, Mönchhof, Mörbisch am See, Neudorf bei Parndorf, Neudörfl, Neufeld an der Leitha, Neusiedl am See, Neustift bei Güssing, Nickelsdorf, Oberpullendorf, Oberschützen, Oberwart, Oslip, Ottendorf an der Rittschein, Paldau, Pama, Pamhagen, Parndorf, Payerbach, Peggau, Pernegg an der Mur, Pernegg im Waldviertel, Pfarrwerfen, Pilgersdorf, Pinggau, Pinkafeld, Podersdorf am See, Poggersdorf, Potzneusiedl, Poysdorf, Pöchlarn, Raach am Hochgebirge, Raasdorf, Radmer, Ragnitz, Raiding, Reichenau, Rohr bei Hartberg, Rohr im Burgenland, Rudersdorf, Rust, Saalfelden am Steinernen Meer, Sankt Georgen an der Stiefing, Sankt Gilgen, Sankt Oswald bei Plankenwarth, Schrattenberg, Schwadorf, Schäffern, Schützen am Gebirge, Seiersberg-Pirka, Siegendorf, Sigleß, Sigmundsherberg, Sinabelkirchen, St. Andrä, St. Andrä am Zicksee, St. Anna am Aigen, St. Egyden am Steinfeld, St. Georgen an der Leys, St. Jakob im Rosental, St. Johann in der Haide, St. Konrad, 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, Straß in Steiermark, Söchau, Tadten, Tattendorf, Thal, Tieschen, Tobaj, Tulln an der Donau, Umweltprofis, Unterfrauenhaid, Unterkohlstätten, Unterlamm, Unterwart, Vasoldsberg, Vordernberg, Völkermarkt, Walpersbach, Weiden am See, Weitersfeld, Weiz, Weppersdorf, Werfenweng, Wies, Wiesen, Wiesfleck, Wiesmath, Wimpassing an der Leitha, Winden am See, Wolfau, Wolfsberg, Wolkersdorf im Weinviertel, WSZ Moosburg, Wulkaprodersdorf, Wörterberg, Zagersdorf, Zelking-Matzleinsdorf, Zillingtal, Zurndorf, Übelbach |
|
||||
| Belgium | Hygea, Limburg.net, Recycle! |
|
||||
| Canada | Aurora (ON), Calgary (AB), Calgary, AB, City of Edmonton, AB, City of Greater Sudbury, ON, City of Peterborough, ON, City of Vancouver, London (ON), Ottawa, Canada, RM of Morris, MB, Strathcona County, ON, Toronto (ON), Waste Wise APPS |
|
||||
|
||||
Reference in New Issue
Block a user