From 794e280de2e74d99e7545b4533d6f9cfd8415632 Mon Sep 17 00:00:00 2001 From: mampfes Date: Tue, 27 Dec 2022 17:07:01 +0100 Subject: [PATCH] prepare for automatic docu generation - check source titles - check source urls - add extra info for sources which serve multiple districts/municipalities --- .../source/abfall_io.py | 3 +- .../abfall_neunkirchen_siegerland_de.py | 4 +- .../source/abfall_zollernalbkreis_de.py | 23 +-- .../source/abfallnavi_de.py | 2 +- .../source/abfalltermine_forchheim_de.py | 2 +- .../source/alw_wf_de.py | 13 +- .../source/art_trier_de.py | 2 +- .../source/aucklandcouncil_govt_nz.py | 2 +- .../source/aw_harburg_de.py | 11 +- .../source/awb_oldenburg_de.py | 6 +- .../source/awido_de.py | 2 +- .../source/awn_de.py | 2 +- .../source/awr_de.py | 2 +- .../source/awsh_de.py | 2 +- .../source/banyule_vic_gov_au.py | 2 +- .../source/berlin_recycling_de.py | 2 +- .../source/bmv_at.py | 2 +- .../source/bracknell_forest_gov_uk.py | 9 +- .../source/bradford_gov_uk.py | 31 +-- .../source/braintree_gov_uk.py | 6 +- .../source/brisbane_qld_gov_au.py | 2 +- .../source/bsr_de.py | 2 +- .../source/buergerportal_de.py | 40 +++- .../source/c_trace_de.py | 2 +- .../source/cambridge_gov_uk.py | 8 +- .../source/canadabay_nsw_gov_au.py | 2 +- .../source/canterbury_gov_uk.py | 8 +- .../source/ccc_govt_nz.py | 2 +- .../source/cheshire_east_gov_uk.py | 6 +- .../source/chesterfield_gov_uk.py | 20 +- .../source/colchester_gov_uk.py | 8 +- .../source/cornwall_gov_uk.py | 5 +- .../source/data_umweltprofis_at.py | 2 +- .../source/derby_gov_uk.py | 8 +- .../source/ecoharmonogram_pl.py | 4 +- .../source/egn_abfallkalender_de.py | 11 +- .../source/elmbridge_gov_uk.py | 18 +- .../source/environmentfirst_co_uk.py | 23 ++- .../source/fccenvironment_co_uk.py | 24 ++- .../source/grafikai_svara_lt.py | 6 +- .../source/guildford_gov_uk.py | 7 +- .../source/huntingdonshire_gov_uk.py | 6 +- .../source/hvcgroep_nl.py | 134 +++++++++---- .../source/infeo_at.py | 9 +- .../source/innerwest_nsw_gov_au.py | 2 +- .../source/ipswich_qld_gov_au.py | 6 +- .../source/kaev_niederlausitz.py | 8 +- .../source/kingston_gov_uk.py | 4 +- .../source/korneuburg_stadtservice_at.py | 13 +- .../source/kwb_goslar_de.py | 4 +- .../source/kwu_de.py | 15 +- .../source/landkreis_rhoen_grabfeld.py | 29 +-- .../source/landkreis_wittmund_de.py | 20 +- .../source/lerum_se.py | 2 +- .../source/lewisham_gov_uk.py | 3 +- .../source/lindau_ch.py | 8 +- .../source/lrasha_de.py | 7 +- .../source/manchester_uk.py | 11 +- .../source/melton_vic_gov_au.py | 2 +- .../source/middlesbrough_gov_uk.py | 25 +-- .../source/miljoteknik_se.py | 8 +- .../source/minrenovasjon_no.py | 55 +++--- .../source/mrsc_vic_gov_au.py | 2 +- .../source/newcastle_gov_uk.py | 24 +-- .../source/nottingham_city_gov_uk.py | 2 +- .../source/nsomerset_gov_uk.py | 2 +- .../source/oslokommune_no.py | 18 +- .../source/peterborough_gov_uk.py | 8 +- .../source/pgh_st.py | 6 +- .../source/recyclesmart_com.py | 1 + .../source/regioentsorgung_de.py | 19 +- .../source/republicservices_com.py | 1 + .../source/rh_entsorgung_de.py | 2 +- .../source/richmondshire_gov_uk.py | 8 +- .../source/rushmoor_gov_uk.py | 3 +- .../source/sbazv_de.py | 22 ++- .../source/scambs_gov_uk.py | 9 +- .../source/seattle_gov.py | 3 +- .../source/sector27_de.py | 2 +- .../source/sheffield_gov_uk.py | 31 ++- .../south_norfolk_and_broadland_gov_uk.py | 7 +- .../source/srvatervinning_se.py | 4 +- .../source/ssam_se.py | 4 +- .../source/stadt_willich_de.py | 13 +- .../source/stadtreinigung_dresden_de.py | 2 +- .../source/stadtservice_bruehl_de.py | 2 +- .../source/staedteservice_de.py | 7 +- .../source/stevenage_gov_uk.py | 7 +- .../source/stonnington_vic_gov_au.py | 2 +- .../source/stuttgart_de.py | 2 +- .../source/sysav_se.py | 2 +- .../source/tewkesbury_gov_uk.py | 8 +- .../source/thehills_nsw_gov_au.py | 2 +- .../source/toronto_ca.py | 8 +- .../source/vasyd_se.py | 4 +- .../source/waipa_nz.py | 4 +- .../source/walsall_gov_uk.py | 25 +-- .../source/warszawa19115_pl.py | 4 +- .../source/wastenet_org_nz.py | 2 +- .../source/wermelskirchen_de.py | 9 +- .../source/westberks_gov_uk.py | 11 +- .../source/wiltshire_gov_uk.py | 5 +- .../source/wsz_moosburg_at.py | 2 +- .../source/wuerzburg_de.py | 14 +- .../source/wyndham_vic_gov_au.py | 7 +- .../source/york_gov_uk.py | 6 +- .../source/zva_wmk_de.py | 2 +- .../abfall_neunkirchen_siegerland_de.md | 2 +- doc/source/art_trier_de.md | 4 +- doc/source/bracknell_forest_gov_uk.md | 4 +- doc/source/braintree_gov_uk.md | 4 +- doc/source/korneuburg_stadtservice_at.md | 13 +- doc/source/nillumbik_vic_gov_au.md | 2 +- doc/source/srvatervinning_se.md | 4 +- doc/source/stadtservice_bruehl_de.md | 5 +- doc/source/toronto_ca.md | 2 +- doc/source/zva_wmk_de.md | 7 +- make_docu.py | 185 ++++++++++++++++++ 118 files changed, 781 insertions(+), 486 deletions(-) create mode 100755 make_docu.py diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_io.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_io.py index 1e678411f..86988763b 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_io.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_io.py @@ -7,11 +7,12 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "AbfallPlus" +TITLE = "Abfall.IO / AbfallPlus" DESCRIPTION = ( "Source for AbfallPlus.de waste collection. Service is hosted on abfall.io." ) URL = "https://www.abfallplus.de" +COUNTRY = "de" TEST_CASES = { "Waldenbuch": { "key": "8215c62763967916979e0e8566b6172e", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_neunkirchen_siegerland_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_neunkirchen_siegerland_de.py index 40c0e9e09..2fe4deca7 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_neunkirchen_siegerland_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_neunkirchen_siegerland_de.py @@ -3,11 +3,11 @@ from waste_collection_schedule import Collection from waste_collection_schedule.service.ICS import ICS -TITLE = "Abfall Neunkirchen Siegerland" +TITLE = "Neunkirchen Siegerland" DESCRIPTION = " Source for 'Abfallkalender Neunkirchen Siegerland'." URL = "https://www.neunkirchen-siegerland.de" TEST_CASES = { - "Waldstraße":{ "street":"Waldstr"} + "Waldstraße":{ "strasse":"Waldstr"} } _LOGGER = logging.getLogger(__name__) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_zollernalbkreis_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_zollernalbkreis_de.py index 245a964cc..a139e04a5 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_zollernalbkreis_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfall_zollernalbkreis_de.py @@ -4,7 +4,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "Abfall Zollernalbkreis" +TITLE = "Abfallwirtschaft Zollernalbkreis" DESCRIPTION = "Source for Abfallwirtschaft Zollernalbkreis waste collection." URL = "https://www.abfallkalender-zak.de" TEST_CASES = { @@ -42,6 +42,16 @@ }, } +ICON_MAP = { + "Restmüll": "mdi:trash-can", + "Grünabfall" : "mdi:leaf", + "Gelber Sack" : "mdi:sack", + "Papiertonne" : "mdi:package-variant", + "Bildschirm-/Kühlgeräte" : "mdi:television-classic", + "Schadstoffsammlung" : "mdi:biohazard", + "altmetalle" : "mdi:nail", +} + class Source: def __init__(self, city, types, street=None): @@ -49,15 +59,6 @@ def __init__(self, city, types, street=None): self._street = street self._types = types self._ics = ICS() - self._iconMap = { - "Restmüll": "mdi:trash-can", - "Grünabfall" : "mdi:leaf", - "Gelber Sack" : "mdi:sack", - "Papiertonne" : "mdi:package-variant", - "Bildschirm-/Kühlgeräte" : "mdi:television-classic", - "Schadstoffsammlung" : "mdi:biohazard", - "altmetalle" : "mdi:nail", - } def fetch(self): now = datetime.now() @@ -95,6 +96,6 @@ def fetch_year(self, year, city, street, types): waste_type = d[1] next_pickup_date = d[0] - entries.append(Collection(date=next_pickup_date, t=waste_type, icon=self._iconMap.get(waste_type,"mdi:trash-can"))) + entries.append(Collection(date=next_pickup_date, t=waste_type, icon=ICON_MAP.get(waste_type,"mdi:trash-can"))) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py index b6e14a02b..bf1d552d6 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py @@ -1,7 +1,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.AbfallnaviDe import AbfallnaviDe -TITLE = "AbfallNavi" +TITLE = "AbfallNavi (RegioIT.de)" DESCRIPTION = ( "Source for AbfallNavi waste collection. AbfallNavi is a brand name of regioit.de." ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfalltermine_forchheim_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfalltermine_forchheim_de.py index 9fd18d815..537e59b18 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfalltermine_forchheim_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfalltermine_forchheim_de.py @@ -4,7 +4,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "Landkreis Forchheim" +TITLE = "Abfalltermine Forchheim" DESCRIPTION = "Source for Landkreis Forchheim" URL = "https://www.abfalltermine-forchheim.de/" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/alw_wf_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/alw_wf_de.py index 3df86d2eb..cfb319041 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/alw_wf_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/alw_wf_de.py @@ -5,9 +5,9 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "ALW Wolfenbüttel" +TITLE = "Abfallwirtschaft Landkreis Wolfenbüttel" DESCRIPTION = "Source for ALW Wolfenbüttel." -URL = "https://abfallapp.alw-wf.de" +URL = "https://alw-wf.de" TEST_CASES = { "Linden alte Straße": {"ort": "Linden mit Okertalsiedlung", "strasse": "Siedlung"}, "Linden neuere Straße": { @@ -17,6 +17,7 @@ "Dettum": {"ort": "Dettum", "strasse": "Egal!"}, } +API_URL = "https://abfallapp.alw-wf.de" AUTH_DATA = { "auth": { "Name": "ALW", @@ -41,7 +42,7 @@ def fetch(self): auth_params = json.dumps(AUTH_DATA) # ALW WF uses a self-signed certificate so we need to disable certificate verification - r = requests.post(f"{URL}/GetOrte.php", data=auth_params, verify=False) + r = requests.post(f"{API_URL}/GetOrte.php", data=auth_params, verify=False) orte = r.json() if orte["result"][0]["StatusCode"] != 200: raise Exception(f"Error getting Orte: {orte['result'][0]['StatusMsg']}") @@ -53,7 +54,7 @@ def fetch(self): if ort_id is None: raise Exception(f"Error finding Ort {self._ort}") - r = requests.post(f"{URL}/GetStrassen.php", data=auth_params, verify=False) + r = requests.post(f"{API_URL}/GetStrassen.php", data=auth_params, verify=False) strassen = r.json() if strassen["result"][0]["StatusCode"] != 200: raise Exception( @@ -73,7 +74,7 @@ def fetch(self): if strasse_id is None: raise Exception(f"Error finding Straße {self._strasse}") - r = requests.post(f"{URL}/GetArten.php", data=auth_params, verify=False) + r = requests.post(f"{API_URL}/GetArten.php", data=auth_params, verify=False) arten = r.json() if arten["result"][0]["StatusCode"] != 200: raise Exception(f"Error getting Arten: {arten['result'][0]['StatusMsg']}") @@ -84,7 +85,7 @@ def fetch(self): entries = [] r = requests.post( - f"{URL}/GetTermine.php/{strasse_id}", data=auth_params, verify=False + f"{API_URL}/GetTermine.php/{strasse_id}", data=auth_params, verify=False ) termine = r.json() if termine["result"][0]["StatusCode"] != 200: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/art_trier_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/art_trier_de.py index 3c196ff90..932e108f5 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/art_trier_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/art_trier_de.py @@ -7,7 +7,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "Abfall ART Trier" +TITLE = "ART Trier" DESCRIPTION = "Source for waste collection of ART Trier." URL = "https://www.art-trier.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/aucklandcouncil_govt_nz.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/aucklandcouncil_govt_nz.py index 682f5c178..f183ebc4d 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/aucklandcouncil_govt_nz.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/aucklandcouncil_govt_nz.py @@ -7,7 +7,7 @@ # Include work around for SSL UNSAFE_LEGACY_RENEGOTIATION_DISABLED error from waste_collection_schedule.service.SSLError import get_legacy_session -TITLE = "Auckland council" +TITLE = "Auckland Council" DESCRIPTION = "Source for Auckland council." URL = "https://aucklandcouncil.govt.nz" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/aw_harburg_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/aw_harburg_de.py index 52487925c..32fcb03b0 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/aw_harburg_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/aw_harburg_de.py @@ -3,9 +3,9 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "AW Harburg" +TITLE = "Abfallwirtschaft Landkreis Harburg" DESCRIPTION = "Abfallwirtschaft Landkreis Harburg" -URL = "https://www.landkreis-harburg.de/bauen-umwelt/abfallwirtschaft/abfallkalender/" +URL = "https://www.landkreis-harburg.de" TEST_CASES = { "CityWithTwoLevels": {"level_1": "Hanstedt", "level_2": "Evendorf"}, @@ -16,6 +16,7 @@ }, } +API_URL = "https://www.landkreis-harburg.de/bauen-umwelt/abfallwirtschaft/abfallkalender/" HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)", } @@ -33,11 +34,11 @@ def fetch(self): # Get the IDs of the districts on the first level # Double loading is on purpose because sometimes the webpage has an overlay # which is gone on the second try in a session - r = session.get(URL, headers=HEADERS) + r = session.get(API_URL, headers=HEADERS) if "Zur aufgerufenen Seite" in r.text: - r = session.get(URL, headers=HEADERS) + r = session.get(API_URL, headers=HEADERS) if r.status_code != 200: - raise Exception(f"Error: failed to fetch first url: {URL}") + raise Exception(f"Error: failed to fetch first url: {API_URL}") # Get the IDs of the districts on the first level id = self.parse_level(r.text, 1) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awb_oldenburg_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awb_oldenburg_de.py index 1f8a5766e..054663af2 100755 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awb_oldenburg_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awb_oldenburg_de.py @@ -6,11 +6,13 @@ TITLE = "AWB Oldenburg" DESCRIPTION = "Source for 'Abfallwirtschaftsbetrieb Stadt Oldenburg (Oldb)'." -URL = "https://services.oldenburg.de/index.php" +URL = "https://oldenburg.de" TEST_CASES = { "Polizeiinspektion Oldenburg": {"street": "Friedhofsweg", "house_number": 30} } +API_URL = "https://services.oldenburg.de/index.php" + class Source: def __init__(self, street, house_number): @@ -39,7 +41,7 @@ def fetch(self): args = urllib.parse.urlencode(args, quote_via=urllib.parse.quote) # post request - r = requests.get(URL, params=args) + r = requests.get(API_URL, params=args) dates = self._ics.convert(r.text) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py index a58abaf45..bfbd4699a 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py @@ -5,7 +5,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "AWIDO" +TITLE = "AWIDO Online" DESCRIPTION = "Source for AWIDO waste collection." URL = "https://www.awido-online.de/" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awn_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awn_de.py index 685f6dcef..058d38daf 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awn_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awn_de.py @@ -5,7 +5,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "AWN" +TITLE = "Abfallwirtschaft Neckar-Odenwald-Kreis" DESCRIPTION = "Source for AWN (Abfallwirtschaft Neckar-Odenwald-Kreis)." URL = "https://www.awn-online.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awr_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awr_de.py index 8f6fef4b2..e2e0b5204 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awr_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awr_de.py @@ -5,7 +5,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "AWR" +TITLE = "Abfallwirtschaft Rendsburg" DESCRIPTION = "Source for Abfallwirtschaft Rendsburg" URL = "https://www.awr.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awsh_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awsh_de.py index ca9b61c36..8a8c371fc 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awsh_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awsh_de.py @@ -5,7 +5,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "AWSH" +TITLE = "Abfallwirtschaft Südholstein" DESCRIPTION = "Source for Abfallwirtschaft Südholstein" URL = "https://www.awsh.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/banyule_vic_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/banyule_vic_gov_au.py index ca13e793f..7cf8e1635 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/banyule_vic_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/banyule_vic_gov_au.py @@ -10,7 +10,7 @@ TITLE = 'Banyule City Council' DESCRIPTION = 'Source for Banyule City Council rubbish collection.' -URL = 'https://www.banyule.vic.gov.au/binday' +URL = 'https://www.banyule.vic.gov.au' TEST_CASES = { 'Monday A': {'street_address': '6 Mandall Avenue, IVANHOE'}, 'Monday A Geolocation ID': {'geolocation_id': '4f7ebfca-1526-4363-8b87-df3103a10a87'}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/berlin_recycling_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/berlin_recycling_de.py index 82537d83e..f1f7e9562 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/berlin_recycling_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/berlin_recycling_de.py @@ -5,7 +5,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Berline Recycling" +TITLE = "Berlin Recycling" DESCRIPTION = "Source for Berlin Recycling waste collection." URL = "https://berlin-recycling.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py index 9ab5d21dd..cd58d4645 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py @@ -5,7 +5,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "BMV.at" +TITLE = "Burgenländischer Müllverband" DESCRIPTION = "Source for BMV, Austria" URL = "https://www.bmv.at" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bracknell_forest_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bracknell_forest_gov_uk.py index 720bf7ac8..f423633ac 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bracknell_forest_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bracknell_forest_gov_uk.py @@ -4,7 +4,7 @@ from dateutil import parser from waste_collection_schedule import Collection -TITLE = "bracknell-forest.gov.uk" +TITLE = "Bracknell Forest Council" DESCRIPTION = "Bracknell Forest Council, UK - Waste Collection" URL = "https://selfservice.mybfc.bracknell-forest.gov.uk" TEST_CASES = { @@ -13,7 +13,8 @@ "32 Ashbourne": {"house_number": "32", "post_code": "RG12 8SG"}, "1 Acacia Avenue": {"house_number": "1", "post_code": "GU47 0RU"}, } -ICONS = { + +ICON_MAP = { "General Waste": "mdi:trash-can", "Recycling": "mdi:recycle", "Garden": "mdi:leaf", @@ -68,7 +69,7 @@ def fetch(self): collection_lookup.raise_for_status() collections = collection_lookup.json()["response"]["collections"] entries = [] - for waste_type in ICONS.keys(): + for waste_type in ICON_MAP.keys(): try: entries.append( Collection( @@ -78,7 +79,7 @@ def fetch(self): ]["date"] ).date(), t=waste_type, - icon=ICONS[waste_type], + icon=ICON_MAP[waste_type], ) ) except (StopIteration, TypeError): diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bradford_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bradford_gov_uk.py index 2e6bcd6ad..869dc0585 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bradford_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bradford_gov_uk.py @@ -11,18 +11,19 @@ import ssl import urllib3 -TITLE = "Bradford.gov.uk" +TITLE = "Bradford Metropolitan District Council" DESCRIPTION = ( "Source for Bradford.gov.uk services for Bradford Metropolitan Council, UK." ) -URL = "https://onlineforms.bradford.gov.uk/ufs/" +URL = "https://bradford.gov.uk" TEST_CASES = { "Ilkley": {"uprn": "100051250665"}, "Bradford": {"uprn": "100051239296"}, "Baildon": {"uprn": "10002329242"}, } -ICONS = { +API_URL = "https://onlineforms.bradford.gov.uk/ufs/" +ICON_MAP = { "REFUSE": "mdi:trash-can", "RECYCLING": "mdi:recycle", "GARDEN": "mdi:leaf", @@ -30,16 +31,16 @@ from pprint import pprint -class CustomHttpAdapter (requests.adapters.HTTPAdapter): - '''Transport adapter" that allows us to use custom ssl_context.''' - - def __init__(self, ssl_context=None, **kwargs): - self.ssl_context = ssl_context - super().__init__(**kwargs) - - def init_poolmanager(self, connections, maxsize, block=False): - self.poolmanager = urllib3.poolmanager.PoolManager( - num_pools=connections, maxsize=maxsize, +class CustomHttpAdapter (requests.adapters.HTTPAdapter): + '''Transport adapter" that allows us to use custom ssl_context.''' + + def __init__(self, ssl_context=None, **kwargs): + self.ssl_context = ssl_context + super().__init__(**kwargs) + + def init_poolmanager(self, connections, maxsize, block=False): + self.poolmanager = urllib3.poolmanager.PoolManager( + num_pools=connections, maxsize=maxsize, block=block, ssl_context=self.ssl_context) class Source: @@ -59,7 +60,7 @@ def fetch(self): s.cookies.set( "COLLECTIONDATES", self._uprn, domain="onlineforms.bradford.gov.uk" ) - r = s.get(f"{URL}/collectiondates.eb") + r = s.get(f"{API_URL}/collectiondates.eb") soup = BeautifulSoup(r.text, features="html.parser") div = soup.find_all("table", {"role": "region"}) @@ -87,7 +88,7 @@ def fetch(self): entry.text.strip(), "%a %b %d %Y" ).date(), t=type, - icon=ICONS[type], + icon=ICON_MAP[type], ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py index b76826c99..e3c9c19a8 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/braintree_gov_uk.py @@ -3,7 +3,7 @@ from dateutil import parser from waste_collection_schedule import Collection -TITLE = "braintree.gov.uk" +TITLE = "Braintree District Council" DESCRIPTION = "Braintree District Council, UK - Waste Collection" URL = "https://www.braintree.gov.uk" TEST_CASES = { @@ -13,7 +13,7 @@ "20 Peel Crescent": {"house_number": "20", "post_code": "CM7 2RS"}, } -ICONS = { +ICON_MAP = { "Grey Bin": "mdi:trash-can", "Clear Sack": "mdi:recycle", "Green Bin": "mdi:leaf", @@ -51,7 +51,7 @@ def fetch(self): Collection( date=parser.parse(collection_date).date(), t=collection_type, - icon=ICONS[collection_type] + icon=ICON_MAP[collection_type] ) ) except (StopIteration, TypeError): diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/brisbane_qld_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/brisbane_qld_gov_au.py index 510b47619..5288aeebb 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/brisbane_qld_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/brisbane_qld_gov_au.py @@ -6,7 +6,7 @@ TITLE = "Brisbane City Council" DESCRIPTION = "Source for Brisbane City Council rubbish collection." -URL = "https://www.brisbane.qld.gov.au/clean-and-green/rubbish-tips-and-bins/rubbish-collections/bin-collection-calendar" +URL = "https://www.brisbane.qld.gov.au" TEST_CASES = { "Suburban Social": { "suburb": "Chapel Hill", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bsr_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bsr_de.py index fa420feef..f4a0675f2 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bsr_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bsr_de.py @@ -4,7 +4,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "BSR" +TITLE = "Berliner Stadtreinigungsbetriebe" DESCRIPTION = "Source for Berliner Stadtreinigungsbetriebe waste collection." URL = "https://bsr.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/buergerportal_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/buergerportal_de.py index 888d43160..fcdbd9737 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/buergerportal_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/buergerportal_de.py @@ -8,6 +8,8 @@ TITLE = "Bürgerportal" URL = "https://www.c-trace.de" DESCRIPTION = "Source for waste collection in multiple service areas." +def EXTRA_INFO(): + return [ { "title": s["title"], "url": s["url"] } for s in SERVICE_MAP ] TEST_CASES = { "Cochem-Zell": { "operator": "cochem_zell", @@ -30,7 +32,8 @@ "number": 1, }, } -ICONS = { + +ICON_MAP = { "mobil": "mdi:truck", "bio": "mdi:leaf", "papier": "mdi:package-variant", @@ -49,12 +52,27 @@ "Cache-Control": "no-cache", } Operator = Literal["cochem_zell", "alb_donau", "biedenkopf"] -# Important: Remove the trailing slash -OPERATOR_URLS: dict[Operator, str] = { - "cochem_zell": "https://buerger-portal-cochemzell.azurewebsites.net", - "alb_donau": "https://buerger-portal-albdonaukreisabfallwirtschaft.azurewebsites.net", - "biedenkopf": "https://biedenkopfmzv.buergerportal.digital", -} + +SERVICE_MAP = [ + { + "title": "KV Cochem-Zell", + "url": "https://www.cochem-zell-online.de/", + "api_url": "https://buerger-portal-cochemzell.azurewebsites.net/api", + "operator": "cochem_zell" + }, + { + "title": "Abfallwirtschaft Alb-Donau-Kreis", + "url": "https://www.aw-adk.de/", + "api_url": "https://buerger-portal-albdonaukreisabfallwirtschaft.azurewebsites.net/api", + "operator": "alb_donau" + }, + { + "title": "MZV Bidenkopf", + "url": "https://mzv-biedenkopf.de/", + "api_url": "https://biedenkopfmzv.buergerportal.digital/api", + "operator": "biedenkopf" + }, +] def quote_none(value: Optional[str]) -> str: @@ -64,6 +82,10 @@ def quote_none(value: Optional[str]) -> str: return f"'{value}'" +def get_api_map(): + return { s["operator"]:s["api_url"] for s in SERVICE_MAP } + + class Source: def __init__( self, @@ -73,7 +95,7 @@ def __init__( subdistrict: Optional[str] = None, number: Union[int, str, None] = None, ): - self.api_url = f"{OPERATOR_URLS[operator]}/api" + self.api_url = get_api_map()[operator] self.district = district self.subdistrict = subdistrict self.street = street @@ -120,7 +142,7 @@ def fetch(self): icon = None # Maybe append collection["Abfuhrplan"]["GefaesstarifArt"]["Volumen"]["VolumenWert"] to waste type - for icon_type, tested_icon in ICONS.items(): + for icon_type, tested_icon in ICON_MAP.items(): if icon_type.lower() in waste_type.lower(): icon = tested_icon diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py index 8a02c0818..ee46980a3 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py @@ -2,7 +2,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "C-Trace.de" +TITLE = "C-Trace" DESCRIPTION = "Source for C-Trace.de." URL = "https://c-trace.de/" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/cambridge_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/cambridge_gov_uk.py index 1e0415991..ced93d217 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/cambridge_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/cambridge_gov_uk.py @@ -4,11 +4,11 @@ import requests from waste_collection_schedule import Collection -TITLE = "Cambridge.gov.uk" +TITLE = "Cambridge City Council" DESCRIPTION = ( "Source for cambridge.gov.uk services for Cambridge and part of Cambridgeshire" ) -URL = "cambridge.gov.uk" +URL = "https://cambridge.gov.uk" TEST_CASES = { "houseNumber": {"post_code": "CB13JD", "number": 37}, "houseName": {"post_code": "cb215hd", "number": "ROSEMARY HOUSE"}, @@ -19,7 +19,7 @@ "collection": "https://servicelayer3c.azure-api.net/wastecalendar/collection/search/{}/", } -ICONS = { +ICON_MAP = { "DOMESTIC": "mdi:trash-can", "RECYCLE": "mdi:recycle", "ORGANIC": "mdi:leaf", @@ -63,7 +63,7 @@ def fetch(self): collection["date"], "%Y-%m-%dT%H:%M:%SZ" ).date(), t=round_type.title(), - icon=ICONS.get(round_type), + icon=ICON_MAP.get(round_type), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/canadabay_nsw_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/canadabay_nsw_gov_au.py index b4ca87c2e..c4db33bc2 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/canadabay_nsw_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/canadabay_nsw_gov_au.py @@ -6,7 +6,7 @@ TITLE = "City of Canada Bay Council" DESCRIPTION = "Source for City of Canada Bay Council rubbish collection." -URL = "https://www.canadabay.nsw.gov.au/residents/waste-and-recycling/my-bins/my-bin-collection" +URL = "https://www.canadabay.nsw.gov.au" TEST_CASES = { "Harry's Shed": { "suburb": "Concord", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/canterbury_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/canterbury_gov_uk.py index 7bd4e4723..e5b4ae9a6 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/canterbury_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/canterbury_gov_uk.py @@ -5,11 +5,11 @@ import requests from waste_collection_schedule import Collection -TITLE = "canterbury.gov.uk" +TITLE = "Canterbury City Council" DESCRIPTION = ( "Source for canterbury.gov.uk services for canterbury" ) -URL = "canterbury.gov.uk" +URL = "https://canterbury.gov.uk" TEST_CASES = { "houseNumber": {"post_code": "ct68ru", "number": "63"}, "houseName": {"post_code": "ct68ru", "number": "KOWLOON"}, @@ -20,7 +20,7 @@ "collection": "https://zbr7r13ke2.execute-api.eu-west-2.amazonaws.com/Beta/get-bin-dates", } -ICONS = { +ICON_MAP = { "General": "mdi:trash-can", "Recycling": "mdi:recycle", "Food": "mdi:food-apple", @@ -77,7 +77,7 @@ def fetch(self): date, "%Y-%m-%dT%H:%M:%S" ).date(), t=collection, - icon=ICONS.get(collection), + icon=ICON_MAP.get(collection), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ccc_govt_nz.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ccc_govt_nz.py index 052b2c0dc..ca3c4a6c6 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ccc_govt_nz.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ccc_govt_nz.py @@ -9,7 +9,7 @@ TITLE = "Christchurch City Council" DESCRIPTION = "Source for Christchurch City Council." -URL = "https://ccc.govt.nz/services/rubbish-and-recycling/collections" +URL = "https://ccc.govt.nz" TEST_CASES = {"53 Hereford Street": {"address": "53 Hereford Street"}} diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/cheshire_east_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/cheshire_east_gov_uk.py index 603e26dc6..bd63ebc32 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/cheshire_east_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/cheshire_east_gov_uk.py @@ -4,11 +4,9 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection -TITLE = "cheshireeast.gov.uk" +TITLE = "Cheshire East Council" DESCRIPTION = "Source for cheshireeast.gov.uk services for Cheshire East" -URL = "cheshireeast.gov.uk" - - +URL = "https://cheshireeast.gov.uk" TEST_CASES = { "houseUPRN": {"uprn": "100010132071"}, "houseAddress": {"postcode": "WA16 0AY", "name_number": "1"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/chesterfield_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/chesterfield_gov_uk.py index da6da807c..929e1ab3e 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/chesterfield_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/chesterfield_gov_uk.py @@ -14,12 +14,8 @@ urllib3.disable_warnings() -TITLE = "chesterfield.gov.uk" - -DESCRIPTION = ( - "Source for waste collection services for Chesterfield Borough Council" -) - +TITLE = "Chesterfield Borough Council" +DESCRIPTION = "Source for waste collection services for Chesterfield Borough Council" URL = "https://www.chesterfield.gov.uk/" HEADERS = { @@ -33,13 +29,13 @@ "Test_004": {"uprn": "74020930"}, } -ICONS = { +ICON_MAP = { "DOMESTIC REFUSE": "mdi:trash-can", "DOMESTIC RECYCLING": "mdi:recycle", "DOMESTIC ORGANIC": "mdi:leaf", } -APIS = { +API_URLS = { "session": "https://www.chesterfield.gov.uk/bins-and-recycling/bin-collections/check-bin-collections.aspx", "fwuid": "https://myaccount.chesterfield.gov.uk/anonymous/c/cbc_VE_CollectionDaysLO.app?aura.format=JSON&aura.formatAdapter=LIGHTNING_OUT", "search": "https://myaccount.chesterfield.gov.uk/anonymous/aura?r=2&aura.ApexAction.execute=1", @@ -57,13 +53,13 @@ def fetch(self): s = requests.Session() r = s.get( - APIS["session"], + API_URLS["session"], headers=HEADERS, ) # Capture fwuid value r = s.get( - APIS["fwuid"], + API_URLS["fwuid"], verify=False, headers=HEADERS, ) @@ -83,7 +79,7 @@ def fetch(self): "aura.token": "null", } r = s.post( - APIS["search"], + API_URLS["search"], data=payload, verify=False, headers=HEADERS, @@ -108,7 +104,7 @@ def fetch(self): Collection( date=dt_local.date(), t=waste_type, - icon=ICONS.get(waste_type.upper()), + icon=ICON_MAP.get(waste_type.upper()), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/colchester_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/colchester_gov_uk.py index 42ac875b8..ce0fea323 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/colchester_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/colchester_gov_uk.py @@ -4,7 +4,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Colchester.gov.uk" +TITLE = "Colchester Borough Council" DESCRIPTION = "Source for Colchester.gov.uk services for the borough of Colchester, UK." URL = "https://colchester.gov.uk" TEST_CASES = { @@ -13,7 +13,7 @@ "The Lane, Colchester": {"llpgid": "7cd96a3d-6027-e711-80fa-5065f38b56d1"}, } -ICONS = { +ICON_MAP = { "Black bags": "mdi:trash-can", "Glass": "mdi:glass-fragile", "Cans": "mdi:trash-can", @@ -63,7 +63,7 @@ def fetch(self): Collection( date=date.date(), t=day["Name"].title(), - icon=ICONS[day["Name"]], + icon=ICON_MAP[day["Name"]], ) ) # As Colchester.gov.uk only provides the current collection cycle, the next must be extrapolated @@ -73,7 +73,7 @@ def fetch(self): Collection( date=date.date() + timedelta(days=14), t=day["Name"].title(), - icon=ICONS[day["Name"]], + icon=ICON_MAP[day["Name"]], ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/cornwall_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/cornwall_gov_uk.py index 118962343..6b57b8cc9 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/cornwall_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/cornwall_gov_uk.py @@ -4,13 +4,14 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection -TITLE = "Cornwall Council, UK" +TITLE = "Cornwall Council" DESCRIPTION = "Source for cornwall.gov.uk services for Cornwall Council" -URL = "cornwall.gov.uk" +URL = "https://cornwall.gov.uk" TEST_CASES = { "known_uprn": {"uprn": "100040118005"}, "unknown_uprn": {"postcode": "TR261SP", "housenumberorname": "7"}, } + SEARCH_URLS = { "uprn_search": "https://www.cornwall.gov.uk/my-area/", "collection_search": "https://www.cornwall.gov.uk/umbraco/Surface/Waste/MyCollectionDays?subscribe=False", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/data_umweltprofis_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/data_umweltprofis_at.py index 8ccd1004f..a86928002 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/data_umweltprofis_at.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/data_umweltprofis_at.py @@ -5,7 +5,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "UMWELTPROFIS" +TITLE = "Umweltprofis" DESCRIPTION = "Source for Umweltprofis" URL = "https://www.umweltprofis.at" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/derby_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/derby_gov_uk.py index e82f1b295..c7ccaaa28 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/derby_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/derby_gov_uk.py @@ -6,9 +6,9 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Derby.gov.uk" +TITLE = "Derby City Council" DESCRIPTION = "Source for Derby.gov.uk services for Derby City Council, UK." -URL = "https://secure.derby.gov.uk/binday/" +URL = "https://derby.gov.uk" TEST_CASES = { # Derby City council wants specific addresses, hopefully these are generic enough. "Community Of The Holy Name, Morley Road, Derby, DE21 4TB": { @@ -20,7 +20,7 @@ }, } -ICONS = { +ICON_MAP = { "Black bin": "mdi:trash-can", "Blue bin": "mdi:recycle", "Brown bin": "mdi:leaf", @@ -82,7 +82,7 @@ def fetch(self): Collection( date=date, t=collection_type, - icon=ICONS[collection_type], + icon=ICON_MAP[collection_type], ) ) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ecoharmonogram_pl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ecoharmonogram_pl.py index 568fdeb0a..679ccaa97 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ecoharmonogram_pl.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ecoharmonogram_pl.py @@ -3,8 +3,9 @@ from ..service.EcoHarmonogramPL import Ecoharmonogram +TITLE = "Ecoharmonogram" DESCRIPTION = "Source for ecoharmonogram.pl" -URL = "ecoharmonogram.pl" +URL = "https://ecoharmonogram.pl" TEST_CASES = { "Simple test case": {"town": "Krzeszowice", "street": "Wyki", "house_number": ""}, "Sides multi test case": {"town": "Częstochowa", "street": "Boczna", "additional_sides_matcher": "wie"}, @@ -14,7 +15,6 @@ "additional_sides_matcher": "Wielorodzinna - powyżej 7 lokali"}, "Simple test with community": {"town": "Gdańsk", "street": "Jabłoniowa", "house_number": "55", "additional_sides_matcher": "", "community": "108" }, } -TITLE = "ecoharmonogram.pl" class Source: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/egn_abfallkalender_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/egn_abfallkalender_de.py index 5a3971b37..e60dd3239 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/egn_abfallkalender_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/egn_abfallkalender_de.py @@ -7,7 +7,7 @@ TITLE = "EGN Abfallkalender" DESCRIPTION = "Source for EGN Abfallkalender" -URL = "https://www.egn-abfallkalender.de/kalender" +URL = "https://www.egn-abfallkalender.de" TEST_CASES = { "Grevenbroich": { "city": "Grevenbroich", @@ -31,7 +31,8 @@ _LOGGER = logging.getLogger(__name__) -IconMap = { +API_URL = "https://www.egn-abfallkalender.de/kalender" +ICON_MAP = { "Grau": "mdi:trash-can", "Gelb": "mdi:sack", "Blau": "mdi:package-variant", @@ -48,7 +49,7 @@ def __init__(self, city, district, street, housenumber): def fetch(self): s = requests.session() - r = s.get(URL) + r = s.get(API_URL) soup = BeautifulSoup(r.text, features="html.parser") tag = soup.find("meta", {"name": "csrf-token"}) @@ -62,7 +63,7 @@ def fetch(self): "street": self._street, "street_number": self._housenumber, } - r = s.post(URL, data=post_data, headers=headers) + r = s.post(API_URL, data=post_data, headers=headers) data = r.json() @@ -85,7 +86,7 @@ def fetch(self): .capitalize() ) entries.append( - Collection(date=date, t=color, icon=IconMap.get(color)) + Collection(date=date, t=color, icon=ICON_MAP.get(color)) ) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/elmbridge_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/elmbridge_gov_uk.py index 4fc986555..0431d9233 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/elmbridge_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/elmbridge_gov_uk.py @@ -5,15 +5,9 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection -TITLE = "elmbridge.gov.uk" +TITLE = "Elmbridge Borough Council" DESCRIPTION = "Source for waste collection services for Elmbridge Borough Council" -URL = "https://www.elmbridge.gov.uk/waste-and-recycling/" - - -HEADERS = { - "user-agent": "Mozilla/5.0", -} - +URL = "https://www.elmbridge.gov.uk" TEST_CASES = { "Test_001": {"uprn": 10013119164}, "Test_002": {"uprn": "100061309206"}, @@ -38,13 +32,17 @@ "Sunday": 6, } -ICONS = { +ICON_MAP = { "REFUSE": "mdi:trash-can", "RECYCLING": "mdi:recycle", "FOOD": "mdi:food", "GARDEN": "mdi:leaf", } +HEADERS = { + "user-agent": "Mozilla/5.0", +} + _LOGGER = logging.getLogger(__name__) @@ -117,7 +115,7 @@ def fetch(self): Collection( date=new_date.date(), t=waste + " bin", - icon=ICONS.get(waste.upper()), + icon=ICON_MAP.get(waste.upper()), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/environmentfirst_co_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/environmentfirst_co_uk.py index 1bdfc1b3d..ed9a8a3d3 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/environmentfirst_co_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/environmentfirst_co_uk.py @@ -5,24 +5,31 @@ from dateutil.parser import parse from waste_collection_schedule import Collection -TITLE = "environmentfirst.co.uk" - +TITLE = "Environment First" +URL = "https://environmentfirst.co.uk" +EXTRA_INFO = [ + { + "title": "Eastbourne Borough Council", + "url": "https://lewes-eastbourne.gov.uk" + }, + { + "title": "Lewes District Council", + "url": "https://lewes-eastbourne.gov.uk" + }, +] DESCRIPTION = ( """Consolidated source for waste collection services from: Eastbourne Borough Council Lewes District Council """ ) - -URL = "https://environmentfirst.co.uk" - TEST_CASES = { "houseUPRN" : {"uprn": "100060063421"}, "houseNumber": {"post_code": "BN228SG", "number": 3}, "houseName": {"post_code": "BN73LG", "number": "Garden Cottage"}, } -ICONS = { +ICON_MAP = { "RUBBISH": "mdi:trash-can", "RECYCLING": "mdi:recycle", "GARDEN WASTE": "mdi:leaf", @@ -92,13 +99,13 @@ def fetch(self): x = soup.findAll("p") for i in x[1:-1]: # ignores elements containing address and marketing message if " day " in i.text: - for round_type in ICONS: + for round_type in ICON_MAP: if round_type in i.text.upper(): entries.append( Collection( date = parse(str.split(i.text, ":")[1]).date(), t = round_type, - icon = ICONS.get(round_type), + icon = ICON_MAP.get(round_type), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py index d475a9563..5312407e4 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py @@ -5,8 +5,7 @@ from dateutil import parser from waste_collection_schedule import Collection -TITLE = "fccenvironment.co.uk" - +TITLE = "FCC Environment" DESCRIPTION = """ Consolidated source for waste collection services for ~60 local authorities. Currently supports: @@ -14,8 +13,21 @@ South Hams (Generic Provider) Market Harborough (Custom Provider) """ - URL = "https://fccenvironment.co.uk" +EXTRA_INFO = [ + { + "title": "Harborough District Council", + "url": "https://harborough.gov.uk" + }, + { + "title": "South Hams District Council", + "url": "https://southhams.gov.uk/" + }, + { + "title": "West Devon Borough Council", + "url": "https://www.westdevon.gov.uk/" + }, +] TEST_CASES = { "14_LE16_9QX": {"uprn": "100030491624"}, # region ommited to test default values @@ -28,7 +40,7 @@ "4_SL21_0HZ": {"uprn": "100040281987", "region": "southhams"}, } -ICONS = { +ICON_MAP = { "Refuse": "mdi:trash-can", "Recycling": "mdi:recycle", "Garden": "mdi:leaf", @@ -66,7 +78,7 @@ def getcollectiondetails(self, endpoint: str) -> list[Collection]: """ Handle duplication before creating the list of Collections """ - for type in ICONS: + for type in ICON_MAP: if type in service: if type in results.keys(): if date < results[type]: @@ -80,7 +92,7 @@ def getcollectiondetails(self, endpoint: str) -> list[Collection]: Collection( date=results[result], t=result, - icon=ICONS[result], + icon=ICON_MAP[result], ) ) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/grafikai_svara_lt.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/grafikai_svara_lt.py index 9c36cc395..e15b77a46 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/grafikai_svara_lt.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/grafikai_svara_lt.py @@ -4,7 +4,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Grafikai.svara.lt" +TITLE = "Kauno švara" DESCRIPTION = 'Source for UAB "Kauno švara".' URL = "http://grafikai.svara.lt" TEST_CASES = { @@ -22,7 +22,7 @@ }, } -ICONS = { +ICON_MAP = { "mišrių atliekų": "mdi:trash-can", "antrinių žaliavų (popierius/plastikas)": "mdi:recycle", "antrinių žaliavų (stiklas)": "mdi:glass-fragile", @@ -86,7 +86,7 @@ def fetch(self): collection_waste_object["date"], "%Y-%m-%dT%H:%M:%S" ).date(), t=collection["descriptionFmt"].title(), - icon=ICONS.get(type, "mdi:trash-can"), + icon=ICON_MAP.get(type, "mdi:trash-can"), ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/guildford_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/guildford_gov_uk.py index da5aa643c..2dd6761d0 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/guildford_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/guildford_gov_uk.py @@ -4,9 +4,8 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "guildford.gov.uk" +TITLE = "Guildford Borough Council" DESCRIPTION = "Source for guildford.gov.uk services for Guildford, UK." -# Find the UPRN of your address using https://www.findmyaddress.co.uk/search URL = "https://guildford.gov.uk" TEST_CASES = { "GU12": {"uprn": "10007060305"}, @@ -14,7 +13,7 @@ "GU2": {"uprn": "100061391831"}, } -ICONS = { +ICON_MAP = { "Refuse": "mdi:trash-can", "Food": "mdi:food-apple", "Recycling": "mdi:recycle", @@ -74,7 +73,7 @@ def fetch(self): collection["NextDate"], "%Y-%m-%dT%H:%M:%S.000Z" ).date(), t=collection["FeatureName"], - icon=ICONS[collection["FeatureName"]], + icon=ICON_MAP[collection["FeatureName"]], ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/huntingdonshire_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/huntingdonshire_gov_uk.py index 9d37fbc31..e209a01e2 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/huntingdonshire_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/huntingdonshire_gov_uk.py @@ -4,7 +4,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Huntingdonshire.gov.uk" +TITLE = "Huntingdonshire District Council" DESCRIPTION = "Source for Huntingdonshire.gov.uk services for Huntingdonshire District Council." URL = "https://www.huntingdonshire.gov.uk" TEST_CASES = { @@ -12,7 +12,7 @@ "Inkerman Rise, St. Neots": {"uprn": "10000144271"}, } -ICONS = { +ICON_MAP = { "Refuse": "mdi:trash-can", "Recycling": "mdi:recycle", "Garden": "mdi:leaf", @@ -45,7 +45,7 @@ def fetch(self): collection["date"], "%Y-%m-%dT%H:%M:%SZ" ).date(), t=round_type.title(), - icon=ICONS.get(round_type), + icon=ICON_MAP.get(round_type), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/hvcgroep_nl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/hvcgroep_nl.py index d1b3aaa0d..5dd44dd02 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/hvcgroep_nl.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/hvcgroep_nl.py @@ -4,9 +4,11 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "HVCGroep" +TITLE = None DESCRIPTION = "Source for the Dutch HVCGroep waste management." -URL = "https://www.hvcgroep.nl/zelf-regelen/afvalkalender" +URL = "https://www.hvcgroep.nl" +def EXTRA_INFO(): + return [ { "title": s["title"], "url": get_main_url(s["api_url"])} for s in SERVICE_MAP ] TEST_CASES = { "Tollebeek": {"postal_code": "8309AV", "house_number": "1"}, "Hvgroep: Tollebeek": { @@ -15,39 +17,105 @@ "service": "hvcgroep", }, "Cyclus": {"postal_code": "2841ML", "house_number": "1090", "service": "cyclusnv"}, - "Mjinblink": { + "Mijnblink": { "postal_code": "5741BV", "house_number": "76", - "service": "mjinblink", + "service": "mijnblink", }, } _LOGGER = logging.getLogger(__name__) -SERVICE_MAP = { - "alphenaandenrijn": "https://afvalkalender.alphenaandenrijn.nl", - "cranendonck": "https://afvalkalender.cranendonck.nl", - "cyclusnv": "https://afvalkalender.cyclusnv.nl", - "dar": "https://afvalkalender.dar.nl", - "denhaag": "https://huisvuilkalender.denhaag.nl", - "gad": "https://inzamelkalender.gad.nl", - "gemeenteberkelland": "https://afvalkalender.gemeenteberkelland.nl", - "hvcgroep": "https://inzamelkalender.hvcgroep.nl", - "lingewaard": "https://afvalwijzer.lingewaard.nl", - "middelburgvlissingen": "https://afvalwijzer.middelburgvlissingen.nl", - "mijnblink": "https://mijnblink.nl", - "peelenmaas": "https://afvalkalender.peelenmaas.nl", - "prezero": "https://inzamelwijzer.prezero.nl", - "purmerend": "https://afvalkalender.purmerend.nl", - "rmn": "https://inzamelschema.rmn.nl", - "schouwen-duiveland": "https://afvalkalender.schouwen-duiveland.nl", - "spaarnelanden": "https://afvalwijzer.spaarnelanden.nl", - "stadswerk072": "https://www.stadswerk072.nl", - "sudwestfryslan": "https://afvalkalender.sudwestfryslan.nl", - "venray": "https://afvalkalender.venray.nl", - "voorschoten": "https://afvalkalender.voorschoten.nl", - "waalre": "https://afvalkalender.waalre.nl", - "zrd": "https://afvalkalender.zrd.nl", +SERVICE_MAP = [ + { "title": "Alpen an den Rijn", + "api_url": "https://afvalkalender.alphenaandenrijn.nl", + }, + { "title": "Gemeente Cranendonck", + "api_url": "https://afvalkalender.cranendonck.nl", + }, + { "title": "Cyclus NV", + "api_url": "https://afvalkalender.cyclusnv.nl", + }, + { "title": "Dar", + "api_url": "https://afvalkalender.dar.nl", + }, + { "title": "Den Haag", + "api_url": "https://huisvuilkalender.denhaag.nl", + }, + { "title": "GAD", + "api_url": "https://inzamelkalender.gad.nl", + }, + { "title": "Gemeente Berkelland", + "api_url": "https://afvalkalender.gemeenteberkelland.nl", + }, + { "title": "HVC Groep", + "api_url": "https://inzamelkalender.hvcgroep.nl", + }, + { "title": "Gemeente Lingewaard", + "api_url": "https://afvalwijzer.lingewaard.nl", + }, + { "title": "Gemeente Middelburg + Vlissingen", + "api_url": "https://afvalwijzer.middelburgvlissingen.nl", + }, + { "title": "Mijn Blink", + "api_url": "https://mijnblink.nl", + }, + { "title": "Gemeente Peel en Maas", + "api_url": "https://afvalkalender.peelenmaas.nl", + }, + { "title": "PreZero", + "api_url": "https://inzamelwijzer.prezero.nl", + }, + { "title": "Purmerend", + "api_url": "https://afvalkalender.purmerend.nl", + }, + { "title": "Reinigingsbedrijf Midden Nederland", + "api_url": "https://inzamelschema.rmn.nl", + }, + { "title": "Gemeente Schouwen-Duiveland", + "api_url": "https://afvalkalender.schouwen-duiveland.nl", + }, + { "title": "Spaarne Landen", + "api_url": "https://afvalwijzer.spaarnelanden.nl", + }, + { "title": "Stadswerk 072", + "api_url": "https://www.stadswerk072.nl", + }, + { "title": "Gemeente Sudwest-Fryslan", + "api_url": "https://afvalkalender.sudwestfryslan.nl", + }, + { "title": "Gemeente Venray", + "api_url": "https://afvalkalender.venray.nl", + }, + { "title": "Gemeente Voorschoten", + "api_url": "https://afvalkalender.voorschoten.nl", + }, + { "title": "Gemeente Wallre", + "api_url": "https://afvalkalender.waalre.nl", + }, + { "title": "ZRD", + "api_url": "https://afvalkalender.zrd.nl", + }, +] + +def get_service_name_map(): + def extract_service_name(api_url): + name = api_url.split(".")[-2] + name = name.split("/")[-1] + return name + + return { extract_service_name(s["api_url"]):s["api_url"] for s in SERVICE_MAP } + +def get_main_url(url): + x = url.split(".")[-2:] + x[0] = x[0].removeprefix("https://") + return "https://" + ".".join(x) + +ICON_MAP = { + "plastic-blik-drinkpak": "mdi:recycle", + "gft": "mdi:leaf", + "papier-en-karton": "mdi:archive", + "restafval": "mdi:trash-can", } @@ -55,13 +123,7 @@ class Source: def __init__(self, postal_code, house_number, service="hvcgroep"): self.postal_code = postal_code self.house_number = house_number - self.icons = { - "plastic-blik-drinkpak": "mdi:recycle", - "gft": "mdi:leaf", - "papier-en-karton": "mdi:archive", - "restafval": "mdi:trash-can", - } - self._url = SERVICE_MAP[service] + self._url = get_service_name_map()[service] def fetch(self): @@ -97,7 +159,7 @@ def fetch(self): Collection( date=datetime.strptime(item["ophaaldatum"], "%Y-%m-%d").date(), t=waste_details[0]["title"], - icon=self.icons.get(waste_details[0]["icon"], "mdi:trash-can"), + icon=ICON_MAP.get(waste_details[0]["icon"], "mdi:trash-can"), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/infeo_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/infeo_at.py index b9201e8f5..d69b27f65 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/infeo_at.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/infeo_at.py @@ -6,9 +6,16 @@ _LOGGER = logging.getLogger(__name__) -TITLE = "INFEO" +TITLE = "infeo" DESCRIPTION = "Source for INFEO waste collection." URL = "https://www.infeo.at/" +EXTRA_INFO = [ + { + "title": "Bogenschütz Entsorgung", + "url": "https://bogenschuetz-entsorgung.de", + "country": "de", + }, +] TEST_CASES = {"Bogenschütz": {"customer": "bogenschütz", "zone": "Dettenhausen"}} diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py index 46b99c110..cf3888ad2 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py @@ -6,7 +6,7 @@ TITLE = "Inner West Council (NSW)" DESCRIPTION = "Source for Inner West Council (NSW) rubbish collection." -URL = "https://www.innerwest.nsw.gov.au/live/waste-and-recycling/bins-and-clean-ups/waste-calendar" +URL = "https://www.innerwest.nsw.gov.au" TEST_CASES = { "Random address": { "suburb": "Tempe", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ipswich_qld_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ipswich_qld_gov_au.py index 591702fb5..46c4ce48a 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ipswich_qld_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ipswich_qld_gov_au.py @@ -7,14 +7,14 @@ TITLE = "Ipswich City Council" DESCRIPTION = "Source for Ipswich City Council rubbish collection." -URL = "https://www.ipswich.qld.gov.au/live/waste-and-recycling/bin-collection-calendar" +URL = "https://www.ipswich.qld.gov.au" TEST_CASES = { "Camira State School": {"street": "184-202 Old Logan Rd", "suburb": "Camira"}, "Random": {"street": "50 Brisbane Road", "suburb": "Redbank"}, } -ICONS = { +ICON_MAP = { "Waste Bin": "mdi:trash-can", "Recycle Bin": "mdi:recycle", "FOGO Bin": "mdi:leaf", @@ -91,7 +91,7 @@ def handle_data(self, data): self._entries.append( Collection( - self._loaded_date, data, icon=ICONS.get(data, "mdi:trash-can") + self._loaded_date, data, icon=ICON_MAP.get(data, "mdi:trash-can") ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kaev_niederlausitz.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kaev_niederlausitz.py index a9ac3429c..88f1ef040 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kaev_niederlausitz.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kaev_niederlausitz.py @@ -6,9 +6,9 @@ from waste_collection_schedule.service.ICS import ICS TITLE = "KAEV Niederlausitz" -DESCRIPTION = "Source for Kommunaler Abfallverband niederlausitz waste collection." +DESCRIPTION = "Source for Kommunaler Abfallverband Niederlausitz waste collection." URL = "https://www.kaev.de/" -URL_ADDRESS = 'https://www.kaev.de/Templates/Content/DetailTourenplanWebsite/ajax.aspx/getAddress' +COUNTRY = "de" TEST_CASES = { "Luckau / OT Zieckau": { "abf_suche": "Luckau / OT Zieckau", @@ -21,11 +21,13 @@ }, } +API_URL = 'https://www.kaev.de/Templates/Content/DetailTourenplanWebsite/ajax.aspx/getAddress' + def get_kalender_id(search): s=requests.Session() s.get('https://www.kaev.de/') payload={"query": search} - resp = s.post(URL_ADDRESS, json=payload).json() + resp = s.post(API_URL, json=payload).json() abf_cal = json.loads(resp["d"]) return abf_cal diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kingston_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kingston_gov_uk.py index 484b3b40e..e0aa859af 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kingston_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kingston_gov_uk.py @@ -5,11 +5,11 @@ import requests from waste_collection_schedule import Collection -TITLE = "www.kingston.gov.uk" +TITLE = "The Royal Borough of Kingston Council" DESCRIPTION = ( "Source for waste collection services for The Royal Borough of Kingston Council" ) -URL = "https://kingston-self.achieveservice.com/service/in_my_area?displaymode=collections" +URL = "kingston.gov.uk" HEADERS = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/korneuburg_stadtservice_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/korneuburg_stadtservice_at.py index ac0c48c8b..e53ef22d9 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/korneuburg_stadtservice_at.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/korneuburg_stadtservice_at.py @@ -6,9 +6,14 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS # type: ignore[attr-defined] -TITLE = 'Müllabfuhr Korneuburg' +TITLE = 'Stadtservice Korneuburg' DESCRIPTION = 'Source for Stadtservice Korneuburg' URL = 'https://www.korneuburg.gv.at' +TEST_CASES = { + "Rathaus": {"street_name": "Hauptplatz", "street_number": 39}, # Teilgebiet 4 + "Rathaus using Teilgebiet": {"street_name": "SomeStreet", "street_number": "1A", "teilgebiet": "4"}, # Teilgebiet 4 + "Werft": {"street_name": "Am Hafen", "street_number": 6} # Teilgebiet 2 +} # Mapping of teilgebiete to calendar urls WASTE_TYPE_URLS = { @@ -18,12 +23,6 @@ '4': ('Biomuell_2', 'Restmuell', 'Papier', 'Gelber_Sack_3') } -TEST_CASES = { - "Rathaus": {"street_name": "Hauptplatz", "street_number": 39}, # Teilgebiet 4 - "Rathaus using Teilgebiet": {"street_name": "SomeStreet", "street_number": "1A", "teilgebiet": "4"}, # Teilgebiet 4 - "Werft": {"street_name": "Am Hafen", "street_number": 6} # Teilgebiet 2 -} - class Source: def __init__(self, street_name, street_number, teilgebiet=-1): diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwb_goslar_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwb_goslar_de.py index 94a755da8..1f8f765af 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwb_goslar_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwb_goslar_de.py @@ -2,9 +2,9 @@ from waste_collection_schedule import Collection from waste_collection_schedule.service.ICS import ICS -TITLE = "KreisWirtschaftsBetriebe Goslar" +TITLE = "Kreiswirtschaftsbetriebe Goslar" DESCRIPTION = "Source for kwb-goslar.de waste collection." -URL = "https://www.kwb-goslar.de/Abfallwirtschaft/Abfuhr/" +URL = "https://www.kwb-goslar.de" TEST_CASES = { "Berliner Straße (Clausthal-Zellerfeld)": {"pois": "2523.602"}, "Braunschweiger Straße (Seesen)": {"pois": "2523.409"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwu_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwu_de.py index cf5b0e3fe..ad8ed4e1e 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwu_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/kwu_de.py @@ -7,13 +7,18 @@ TITLE = "KWU Entsorgung Landkreis Oder-Spree" DESCRIPTION = "Source for KWU Entsorgung, Germany" URL = "https://www.kwu-entsorgung.de/" - TEST_CASES = { "Erkner": {"city": "Erkner", "street": "Heinrich-Heine-Straße", "number": "11"}, "Bad Saarow": {"city": "Bad Saarow", "street": "Ahornallee", "number": "1"} } HEADERS = {"user-agent": "Mozilla/5.0 (xxxx Windows NT 10.0; Win64; x64)"} +ICON_MAP = { + "Restabfall": "mdi:trash-can-outline", + "Gelber Sack" : "mdi:recycle", + "Papiertonne" : "mdi:package-variant", + "Biotonne": "mdi:food-apple-outline", +} class Source: @@ -22,12 +27,6 @@ def __init__(self, city, street, number): self._street = street self._number = number self._ics = ICS() - self._iconMap = { - "Restabfall": "mdi:trash-can-outline", - "Gelber Sack" : "mdi:recycle", - "Papiertonne" : "mdi:package-variant", - "Biotonne": "mdi:food-apple-outline", - } def fetch(self): session = requests.Session() @@ -94,7 +93,7 @@ def fetch(self): waste_type = d[1].strip() next_pickup_date = d[0] - entries.append(Collection(date=next_pickup_date, t=waste_type, icon=self._iconMap.get(waste_type,"mdi:trash-can"))) + entries.append(Collection(date=next_pickup_date, t=waste_type, icon=ICON_MAP.get(waste_type,"mdi:trash-can"))) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_rhoen_grabfeld.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_rhoen_grabfeld.py index c1f16c053..430afe528 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_rhoen_grabfeld.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_rhoen_grabfeld.py @@ -3,18 +3,10 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Source for Rhön Grabfeld" +TITLE = "Landkreis Rhön Grabfeld" DESCRIPTION = "Source for Rhönn Grabfeld uses service by offizium." -URL = 'https://fs-api-rg.offizium.com/abfalltermine' -ICON_MAP = { - "Restmüll/Gelber Sack/Biotonne": "mdi:trash-can", - "Papiersammlung": "mdi:package-variant", - "Problemmüllsammlung": "mdi:biohazard" -} -EVENT_BLACKLIST = ['Wertstoffhof Mellrichstadt', - 'Wertstoffhof Bad Königshofen', 'Wertstoffzentrum Bad Neustadt', - 'Wertstoffsammelstelle Ostheim', - 'Wertstoffsammelstelle Bischofsheim'] +URL = "https://www.abfallinfo-rhoen-grabfeld.de/" +COUNTRY = "de" TEST_CASES = { "City only": {"city": "Ostheim"}, "City + District": {"city": "Ostheim", "district": "Oberwaldbehrungen"}, @@ -22,6 +14,19 @@ "empty": {} } +API_URL = 'https://fs-api-rg.offizium.com/abfalltermine' + +EVENT_BLACKLIST = ['Wertstoffhof Mellrichstadt', + 'Wertstoffhof Bad Königshofen', 'Wertstoffzentrum Bad Neustadt', + 'Wertstoffsammelstelle Ostheim', + 'Wertstoffsammelstelle Bischofsheim'] + +ICON_MAP = { + "Restmüll/Gelber Sack/Biotonne": "mdi:trash-can", + "Papiersammlung": "mdi:package-variant", + "Problemmüllsammlung": "mdi:biohazard" +} + class Source: def __init__(self, city: str = None, district: str = None): @@ -31,7 +36,7 @@ def __init__(self, city: str = None, district: str = None): def fetch(self): now = datetime.datetime.now().date() - r = requests.get(URL, params={ + r = requests.get(API_URL, params={ "stadt": self._city, "ortsteil": self._district }) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_wittmund_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_wittmund_de.py index df3a3f147..8ad0ab905 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_wittmund_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/landkreis_wittmund_de.py @@ -4,12 +4,9 @@ from waste_collection_schedule.service.ICS import ICS from bs4 import BeautifulSoup -TITLE = "Landkreis-Wittmund.de" +TITLE = "Landkreis Wittmund" DESCRIPTION = "Source for Landkreis Wittmund waste collection." -URL = "https://www.landkreis-wittmund.de/Leben-Wohnen/Wohnen/Abfall/Abfuhrkalender/" -AUTOCOMPLETE_URL = "https://www.landkreis-wittmund.de/output/autocomplete.php?out=json&type=abto&mode=&select=2&refid={}&term=" -DOWNLOAD_URL = "https://www.landkreis-wittmund.de/output/options.php?ModID=48&call=ical&ArtID%5B0%5D=3105.1&ArtID%5B1%5D=1.4&ArtID%5B2%5D=1.2&ArtID%5B3%5D=1.3&ArtID%5B4%5D=1.1&pois={}&alarm=0" - +URL = "https://www.landkreis-wittmund.de" TEST_CASES = { "CityWithoutStreet": { "city": "Werdum", @@ -20,6 +17,11 @@ }, } +API_URL = "https://www.landkreis-wittmund.de/Leben-Wohnen/Wohnen/Abfall/Abfuhrkalender/" +AUTOCOMPLETE_URL = "https://www.landkreis-wittmund.de/output/autocomplete.php?out=json&type=abto&mode=&select=2&refid={}&term=" +DOWNLOAD_URL = "https://www.landkreis-wittmund.de/output/options.php?ModID=48&call=ical&ArtID%5B0%5D=3105.1&ArtID%5B1%5D=1.4&ArtID%5B2%5D=1.2&ArtID%5B3%5D=1.3&ArtID%5B4%5D=1.1&pois={}&alarm=0" + + class Source: def __init__(self, city, street=None): self._city = city @@ -36,11 +38,11 @@ def is_city_selection(self, tag, cityName): return tag['value'] != "" and tag.string == self._city def fetch_city_id(self, cityName): - r = requests.get(URL) + r = requests.get(API_URL) if not r.ok: raise Exception( "Error: failed to fetch url: {}".format( - URL + API_URL ) ) @@ -64,7 +66,7 @@ def fetch_city_id(self, cityName): def fetch_street_id(self, cityId, streetName): r = requests.get(AUTOCOMPLETE_URL.format(cityId, streetName), headers={ - "Referer": URL + "Referer": API_URL }) if not r.ok: @@ -100,7 +102,7 @@ def fetch_street_id(self, cityId, streetName): def fetch_ics(self, url): r = requests.get(url, headers={ - "Referer": URL + "Referer": API_URL }) if not r.ok: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lerum_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lerum_se.py index f761e770c..6927a878f 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lerum_se.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lerum_se.py @@ -8,7 +8,7 @@ TITLE = "Lerum Vatten och Avlopp" DESCRIPTION = "Source for Lerum Vatten och Avlopp waste collection." -URL = "https://vatjanst.lerum.se/FutureWeb/SimpleWastePickup/SimpleWastePickup" +URL = "https://vatjanst.lerum.se" TEST_CASES = { "PRO": {"street_address": "Floda stationsväg 5, Floda"}, "Polisen": {"street_address": "Göteborgsvägen 16, Lerum"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lewisham_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lewisham_gov_uk.py index 4272d6a43..b0e031936 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lewisham_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lewisham_gov_uk.py @@ -9,8 +9,7 @@ DESCRIPTION = ( "Source for services from the London Borough of Lewisham" ) - -URL = "lewisham.gov.uk" +URL = "https://lewisham.gov.uk" TEST_CASES = { "houseNumber": {"post_code": "SE41LR", "number": 4}, "houseName": {"post_code": "SE233TE", "name": "The Haven"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lindau_ch.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lindau_ch.py index 8fd31cb5f..1efb835af 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lindau_ch.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lindau_ch.py @@ -5,16 +5,16 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Abfall Lindau" +TITLE = "Lindau" DESCRIPTION = "Source for Lindau waste collection." -URL = "https://www.lindau.ch/abfalldaten" +URL = "https://www.lindau.ch" TEST_CASES = { "Tagelswangen": {"city": "Tagelswangen"}, "Grafstal": {"city": "190"}, } -IconMap = { +ICON_MAP = { "kehricht": "mdi:trash-can", "grungut": "mdi:leaf", "hackseldienst": "mdi:leaf", @@ -51,7 +51,7 @@ def fetch(self): Collection( date=next_pickup_date, t=waste_type, - icon=IconMap.get(waste_type_sorted, "mdi:trash-can"), + icon=ICON_MAP.get(waste_type_sorted, "mdi:trash-can"), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lrasha_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lrasha_de.py index fe32359a7..f1d8f796b 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/lrasha_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/lrasha_de.py @@ -6,13 +6,12 @@ TITLE = "Landkreis Schwäbisch Hall" DESCRIPTION = "Source for lrasha.de - Landkreis Schwäbisch Hall" -URL = "http://exchange.cmcitymedia.de/landkreis-schwaebisch-hallt3/wasteCalendarExport.php?location=" -# https://www.lrasha.de/de/buergerservice/abfallwirtschaft/abfallkalender - +URL = "https://www.lrasha.de" TEST_CASES = { "Ilshofen": {"location": "114"} } +API_URL = "http://exchange.cmcitymedia.de/landkreis-schwaebisch-hallt3/wasteCalendarExport.php?location=" HEADERS = {"user-agent": "Mozilla/5.0 (xxxx Windows NT 10.0; Win64; x64)"} @@ -23,7 +22,7 @@ def __init__(self, location): def fetch(self): # get ics file - full_url = URL + str(self._location) + full_url = API_URL + str(self._location) r = requests.get(full_url, headers=HEADERS) r.raise_for_status() diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/manchester_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/manchester_uk.py index a6c935e6d..61f35482d 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/manchester_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/manchester_uk.py @@ -7,14 +7,15 @@ from urllib.parse import urlsplit, parse_qs import logging -TITLE = "manchester.gov.uk" +TITLE = "Manchester City Council" DESCRIPTION = "Source for bin collection services for Manchester City Council, UK." -URL = "https://www.manchester.gov.uk/bincollections/" +URL = "https://www.manchester.gov.uk" TEST_CASES = { "domestic": {'uprn': '000077065560'}, } -ICONS = { +API_URL = "https://www.manchester.gov.uk/bincollections/" +ICON_MAP = { "Black / Grey Bin": "mdi:trash-can", "Blue Bin": "mdi:recycle", "Brown Bin": "mdi:glass-fragile", @@ -39,7 +40,7 @@ def fetch(self): entries = [] r = requests.post( - URL, + API_URL, data={ "mcc_bin_dates_uprn": self._uprn, "mcc_bin_dates_submit": "Go" @@ -64,7 +65,7 @@ def fetch(self): Collection( date=date, t=collection_type, - icon=ICONS[collection_type], + icon=ICON_MAP[collection_type], ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/melton_vic_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/melton_vic_gov_au.py index f7ed62e73..8af37097d 100755 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/melton_vic_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/melton_vic_gov_au.py @@ -8,7 +8,7 @@ TITLE = "Melton City Council" DESCRIPTION = "Source for Melton City Council rubbish collection." -URL = "https://www.melton.vic.gov.au/My-Area" +URL = "https://www.melton.vic.gov.au" TEST_CASES = { "Tuesday A": {"street_address": "23 PILBARA AVENUE BURNSIDE 3023"}, "Tuesday B": {"street_address": "29 COROWA CRESCENT BURNSIDE 3023"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/middlesbrough_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/middlesbrough_gov_uk.py index 85930e841..1e55946be 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/middlesbrough_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/middlesbrough_gov_uk.py @@ -5,21 +5,9 @@ from datetime import datetime from waste_collection_schedule import Collection -TITLE = 'middlesbrough.gov.uk' -DESCRIPTION = ( - 'Source for waste collection services for Middlesbrough Council' -) -URL = 'https://www.middlesbrough.gov.uk/bin-collection-dates' - - -HEADERS = { - "user-agent": "Mozilla/5.0", -} - -COOKIES = { - -} - +TITLE = 'Middlesbrough Council' +DESCRIPTION = 'Source for waste collection services for Middlesbrough Council' +URL = 'https://www.middlesbrough.gov.uk' TEST_CASES = { "Tollesby Road - number" : {"uprn": 100110140843}, "Tollesby Road - string" : {"uprn": "100110140843"}, @@ -33,6 +21,13 @@ 'schedule': 'https://my.middlesbrough.gov.uk/apibroker/runLookup?id=5d78f40439054&repeat_against=&noRetry=true&getOnlyTokens=undefined&log_id=&app_name=AF-Renderer::Self&' } +HEADERS = { + "user-agent": "Mozilla/5.0", +} + +COOKIES = { +} + _LOGGER = logging.getLogger(__name__) class Source: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py index c1d6a0394..840b9ce7b 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py @@ -33,15 +33,15 @@ # those bins, only for the so called "Fyrfack" bins (meaning four slots). # -TITLE = "Ronneby Miljöteknik Sophämntning" +TITLE = "Ronneby Miljöteknik" DESCRIPTION = "Source for Ronneby Miljöteknik waste collection." -URL = ( - "http://www.fyrfackronneby.se/hamtningskalender/" -) +URL = "http://www.fyrfackronneby.se" TEST_CASES = { "Home": {"street_address": "Hjortsbergavägen 16, Johannishus"} } +API_URL = "http://www.fyrfackronneby.se/hamtningskalender/" + class Source: def __init__(self, street_address): diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/minrenovasjon_no.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/minrenovasjon_no.py index 9ddfbdef8..a66b4a2b4 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/minrenovasjon_no.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/minrenovasjon_no.py @@ -9,7 +9,7 @@ TITLE = "Min Renovasjon" DESCRIPTION = "Source for Norkart Komtek MinRenovasjon (Norway)." -URL = "https://www.norkart.no/komtek/renovasjon/" +URL = "https://www.norkart.no" # **street_code:** \ # **county_id:** \ @@ -29,8 +29,28 @@ } } -BASE_URL = "https://komteksky.norkart.no/komtek.renovasjonwebapi/api/" +API_URL = "https://komteksky.norkart.no/komtek.renovasjonwebapi/api/" APP_KEY = "AE13DEEC-804F-4615-A74E-B4FAC11F0A30" +ICON_MAP = { + "": "mdi:trash-can", + "brush": "mdi:trash-can", + "elektriskogelektronisk": "mdi:chip", + "farligavfall": "mdi:trash-can", + "glassogmetallemballasje": "mdi:trash-can", + "hageavfall": "mdi:leaf", + "klaerogsko": "mdi:hanger", + "matavfall": "mdi:trash-can", + "matrestavfall": "mdi:trash-can", + "matrestavfallplast": "mdi:trash-can", + "metall": "mdi:trash-can", + "papir": "mdi:newspaper-variant-multiple", + "pappogkartong": "mdi:archive", + "plastemballasje": "mdi:trash-can", + "restavfall": "mdi:trash-can", + "drikkekartong": "mdi:newspaper-variant-multiple", + "papppapirdrikkekartong": "mdi:newspaper-variant-multiple", + "trevirke": "mdi:trash-can", + } class Source: def __init__(self, street_name, house_number, street_code, county_id): @@ -38,28 +58,6 @@ def __init__(self, street_name, house_number, street_code, county_id): self._house_number = house_number self._street_code = street_code self._county_id = county_id - self._icon_map = { - "": "mdi:trash-can", - "brush": "mdi:trash-can", - "elektriskogelektronisk": "mdi:chip", - "farligavfall": "mdi:trash-can", - "glassogmetallemballasje": "mdi:trash-can", - "hageavfall": "mdi:leaf", - "klaerogsko": "mdi:hanger", - "matavfall": "mdi:trash-can", - "matrestavfall": "mdi:trash-can", - "matrestavfallplast": "mdi:trash-can", - "metall": "mdi:trash-can", - "papir": "mdi:newspaper-variant-multiple", - "pappogkartong": "mdi:archive", - "plastemballasje": "mdi:trash-can", - "restavfall": "mdi:trash-can", - "drikkekartong": "mdi:newspaper-variant-multiple", - "papppapirdrikkekartong": "mdi:newspaper-variant-multiple", - "trevirke": "mdi:trash-can" - - - } def fetch(self): headers = { @@ -69,15 +67,13 @@ def fetch(self): } args = {} - r = requests.get(BASE_URL + 'fraksjoner', params = args, headers = headers) + r = requests.get(API_URL + 'fraksjoner', params = args, headers = headers) type = {} for f in json.loads(r.content): # pprint(f) - icon = "mdi:trash-can" icon_name = re.sub(r"^.*?/(\w+)\.\w{3,4}$", "\\1", f['Ikon']) - if icon_name in self._icon_map: - icon = self._icon_map[icon_name] + icon = ICON_MAP.get(icon_name, "mdi:trash-can") type[f['Id']] = { 'name': f['Navn'], 'image': f['Ikon'], @@ -88,10 +84,9 @@ def fetch(self): 'gatenavn': self._street_name, 'husnr': self._house_number, 'gatekode': self._street_code, - } - r = requests.get(BASE_URL + 'tommekalender', params = args, headers = headers) + r = requests.get(API_URL + 'tommekalender', params = args, headers = headers) entries = [] for f in json.loads(r.content): diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/mrsc_vic_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/mrsc_vic_gov_au.py index f0dec0578..f0d42cdfa 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/mrsc_vic_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/mrsc_vic_gov_au.py @@ -8,7 +8,7 @@ TITLE = "Macedon Ranges Shire Council" DESCRIPTION = "Source for Macedon Ranges Shire Council rubbish collection." -URL = "https://www.mrsc.vic.gov.au/Live-Work/Bins-Rubbish-Recycling/Bins-and-collection-days/Bin-collection-days" +URL = "https://www.mrsc.vic.gov.au" TEST_CASES = { "Macedon IGA": {"street_address": "20 Victoria Street, Macedon"}, "ALDI Gisborne": {"street_address": "45 Aitken Street, Gisborne"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/newcastle_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/newcastle_gov_uk.py index 4e7a2b4eb..0542396f2 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/newcastle_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/newcastle_gov_uk.py @@ -14,25 +14,25 @@ _LOGGER = logging.getLogger(__name__) -TITLE = "newcastle.gov.uk" -DESCRIPTION = ( - """Source for waste collection services for Newcastle City Council""" -) -URL = "https://community.newcastle.gov.uk/my-neighbourhood/ajax/getBinsNew.php" +TITLE = "Newcastle City Council" +DESCRIPTION = "Source for waste collection services for Newcastle City Council" +URL = "https://community.newcastle.gov.uk" +TEST_CASES = { + "Test_001": {"uprn": "004510053797"}, + "Test_002": {"uprn": 4510053797} +} + + +API_URL = "https://community.newcastle.gov.uk/my-neighbourhood/ajax/getBinsNew.php" REGEX = "(Green|Blue|Brown) [bB]in \\((Domestic|Recycling|Garden)( Waste)?\\) details: <\\/strong>" \ "collection day : [a-zA-Z]*day" \ "Next collection : ([0-9]{2}-[A-Za-z]+-[0-9]{4})" -ICONS = { +ICON_MAP = { "DOMESTIC": "mdi:trash-can", "RECYCLING": "mdi:recycle", "GARDEN": "mdi:leaf", } -TEST_CASES = { - "Test_001": {"uprn": "004510053797"}, - "Test_002": {"uprn": 4510053797} -} - class Source: def __init__(self, uprn=None): @@ -56,7 +56,7 @@ def fetch(self): Collection( date=datetime.strptime(collection_date, '%d-%b-%Y').date(), t=collection_type, - icon=ICONS.get(collection_type.upper()), + icon=ICON_MAP.get(collection_type.upper()), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/nottingham_city_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/nottingham_city_gov_uk.py index 7c59774fb..7f60304b5 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/nottingham_city_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/nottingham_city_gov_uk.py @@ -5,7 +5,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "nottinghamcity.gov.uk" +TITLE = "Nottingham City Council" DESCRIPTION = "Source for nottinghamcity.gov.uk services for the city of Nottingham, UK." URL = "https://nottinghamcity.gov.uk" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/nsomerset_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/nsomerset_gov_uk.py index 74efd6a00..83b0b616a 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/nsomerset_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/nsomerset_gov_uk.py @@ -5,7 +5,7 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection -TITLE = "North Somerset.gov.uk" +TITLE = "North Somerset Council" DESCRIPTION = "Source for n-somerset.gov.uk services for North Somerset, UK." URL = "n-somerset.gov.uk" diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/oslokommune_no.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/oslokommune_no.py index 87a7d594b..064627e43 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/oslokommune_no.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/oslokommune_no.py @@ -9,7 +9,7 @@ TITLE = "Oslo Kommune" DESCRIPTION = "Oslo Kommune (Norway)." -URL = "https://www.oslo.kommune.no/avfall-og-gjenvinning/nar-hentes-avfallet/" +URL = "https://www.oslo.kommune.no" # **street_code:** \ # **county_id:** \ @@ -29,7 +29,12 @@ } } -BASE_URL = "https://www.oslo.kommune.no/xmlhttprequest.php" +API_URL = "https://www.oslo.kommune.no/xmlhttprequest.php" +ICON_MAP = { + "": "mdi:trash-can", + "restavfall": "mdi:trash-can", + "papir": "mdi:newspaper-variant-multiple" +} class Source: def __init__(self, street_name, house_number, house_letter, street_id): @@ -37,11 +42,6 @@ def __init__(self, street_name, house_number, house_letter, street_id): self._house_number = house_number self._house_letter = house_letter self._street_id = street_id - self._icon_map = { - "": "mdi:trash-can", - "restavfall": "mdi:trash-can", - "papir": "mdi:newspaper-variant-multiple" - } def fetch(self): headers = { @@ -56,7 +56,7 @@ def fetch(self): 'street_id': self._street_id, } - r = requests.get(BASE_URL, params = args, headers = headers) + r = requests.get(API_URL, params = args, headers = headers) entries = [] res = json.loads(r.content)['data']['result'][0]['HentePunkts'] @@ -70,7 +70,7 @@ def fetch(self): tjeneste['TommeDato'], "%d.%m.%Y" ).date(), t = tekst, - icon = self._icon_map[tekst.lower()] or "mdi:trash-can" + icon = ICON_MAP.get(tekst.lower(), "mdi:trash-can") ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/peterborough_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/peterborough_gov_uk.py index afa6ca0f6..f48596679 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/peterborough_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/peterborough_gov_uk.py @@ -4,11 +4,11 @@ import requests from waste_collection_schedule import Collection -TITLE = "Peterborough.gov.uk" +TITLE = "Peterborough City Council" DESCRIPTION = ( "Source for peterborough.gov.uk services for Peterborough" ) -URL = "peterborough.gov.uk" +URL = "https://peterborough.gov.uk" TEST_CASES = { "houseNumber": {"post_code": "PE57AX", "number": 1}, "houseName": {"post_code": "PE57AX", "name": "CASTOR HOUSE"}, @@ -20,7 +20,7 @@ "collection": "https://www.peterborough.gov.uk/api/jobs/{start}/{end}/{uprn}", } -ICONS = { +ICON_MAP = { "Empty Bin 240L Black": "mdi:trash-can", "Empty Bin 240L Green": "mdi:recycle", "Empty Bin 240L Brown": "mdi:leaf", @@ -74,7 +74,7 @@ def fetch(self): collection["nextDate"], "%Y-%m-%dT%H:%M:%S" ).date(), t=collection["jobDescription"], - icon=ICONS.get(collection["jobDescription"]), + icon=ICON_MAP.get(collection["jobDescription"]), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/pgh_st.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/pgh_st.py index 678f132e1..aebd8e741 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/pgh_st.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/pgh_st.py @@ -5,10 +5,10 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "PGH.ST" +TITLE = "City of Pittsburgh" DESCRIPTION = "Source for PGH.ST services for the city of Pittsburgh, PA, USA." -URL = "http://www.pgh.st" -TEST_CASES = {} +URL = "https://www.pgh.st" +COUNTRY = "us" TEST_CASES = { "Pittsburgh, Negley": { "house_number": 800, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/recyclesmart_com.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/recyclesmart_com.py index c9d280648..cbb3da6fd 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/recyclesmart_com.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/recyclesmart_com.py @@ -7,6 +7,7 @@ TITLE = "RecycleSmart" DESCRIPTION = "Source for RecycleSmart collection." URL = "https://www.recyclesmart.com/" +COUNTRY = "au" TEST_CASES = { "pickup": { "email": "!secret recyclesmart_email", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/regioentsorgung_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/regioentsorgung_de.py index 83c9909f8..7ae988bff 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/regioentsorgung_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/regioentsorgung_de.py @@ -2,15 +2,14 @@ from waste_collection_schedule import Collection from waste_collection_schedule.service.ICS import ICS -TITLE = "RegioEntsorgung" +TITLE = "RegioEntsorgung Städteregion Aachen" DESCRIPTION = "RegioEntsorgung Städteregion Aachen" -URL = "https://regioentsorgung.de/service/abfallkalender/" - +URL = "https://regioentsorgung.de" TEST_CASES = { "Merzbrück": {"city": "Würselen", "street": "Merzbrück", "house_number": 200 }, } -BASE_URL = "https://tonnen.regioentsorgung.de/WasteManagementRegioentsorgung/WasteManagementServlet" +API_URL = "https://tonnen.regioentsorgung.de/WasteManagementRegioentsorgung/WasteManagementServlet" HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)", @@ -31,7 +30,7 @@ def fetch(self): payload = { 'SubmitAction': 'wasteDisposalServices', } - r = session.get(BASE_URL, headers=HEADERS, params=payload) + r = session.get(API_URL, headers=HEADERS, params=payload) r.raise_for_status() payload = { @@ -41,7 +40,7 @@ def fetch(self): 'Strasse': '', 'Hausnummer': '', } - r = session.post(BASE_URL, headers=HEADERS, data=payload) + r = session.post(API_URL, headers=HEADERS, data=payload) r.raise_for_status() payload = { @@ -51,7 +50,7 @@ def fetch(self): 'Strasse': self.street, 'Hausnummer': '', } - r = session.post(BASE_URL, headers=HEADERS, data=payload) + r = session.post(API_URL, headers=HEADERS, data=payload) r.raise_for_status() payload = { @@ -61,14 +60,14 @@ def fetch(self): 'Strasse': self.street, 'Hausnummer': self.house_number, } - r = session.post(BASE_URL, headers=HEADERS, data=payload) + r = session.post(API_URL, headers=HEADERS, data=payload) r.raise_for_status() payload = { 'ApplicationName': 'com.athos.kd.regioentsorgung.AbfuhrTerminModel', 'SubmitAction': 'forward', } - r = session.post(BASE_URL, headers=HEADERS, data=payload) + r = session.post(API_URL, headers=HEADERS, data=payload) r.raise_for_status() payload = { @@ -86,7 +85,7 @@ def fetch(self): 'ICalZeit': '06:00 Uhr', 'SubmitAction': 'filedownload_ICAL', } - r = session.post(BASE_URL, headers=HEADERS, data=payload) + r = session.post(API_URL, headers=HEADERS, data=payload) r.raise_for_status() # Parse ics file diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/republicservices_com.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/republicservices_com.py index 4c4eddd49..d163c7665 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/republicservices_com.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/republicservices_com.py @@ -7,6 +7,7 @@ TITLE = "Republic Services" DESCRIPTION = "Source for Republic Services Collection." URL = "https://www.republicservices.com" +COUNTRY = "us" TEST_CASES = { "Scott Country Clerk": {"street_address": "101 E Main St, Georgetown, KY 40324"}, "Branch County Clerk": {"street_address": "31 Division St. Coldwater, MI 49036"} diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/rh_entsorgung_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/rh_entsorgung_de.py index a2225889f..d63d758ef 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/rh_entsorgung_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/rh_entsorgung_de.py @@ -4,7 +4,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "RH Entsorgung" +TITLE = "Rhein-Hunsrück Entsorgung (RHE)" DESCRIPTION = "Source for RHE (Rhein Hunsrück Entsorgung)." URL = "https://www.rh-entsorgung.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/richmondshire_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/richmondshire_gov_uk.py index e6349f676..119e74f19 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/richmondshire_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/richmondshire_gov_uk.py @@ -3,16 +3,16 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Richmondshire (North Yorkshire)" +TITLE = "Richmondshire District Council" DESCRIPTION = "To find your UPRN, visit the Richmondshire page and use the address search. Right-click your entry in the house dropdown, choose Inspect, and copy the UPRN from the value" -URL = "https://www.richmondshire.gov.uk/collectionCalendar" +URL = "https://www.richmondshire.gov.uk" TEST_CASES = { "test1": {"uprn": 200001767082}, "test2": {"uprn": 200001767078}, "test3": {"uprn": 200001767079}, } -ICONS = { +ICON_MAP = { "240L GREY RUBBISH BIN": "mdi:trash-can", "55L RECYCLING BOX": "mdi:recycle", "140L GARDEN BIN": "mdi:leaf", @@ -38,7 +38,7 @@ def fetch(self): Collection( date=datetime.strptime(id["start"], "%Y-%m-%dT%H:%M:%S").date(), t=id["title"], - icon=ICONS.get(id["title"]), + icon=ICON_MAP.get(id["title"]), ) ) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/rushmoor_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/rushmoor_gov_uk.py index 5ee7e3f59..af7461bfd 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/rushmoor_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/rushmoor_gov_uk.py @@ -2,9 +2,8 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "rushmoor.gov.uk" +TITLE = "Rushmoor Borough Council" DESCRIPTION = "Source for rushmoor.gov.uk services for Rushmoor, UK." -# Find the UPRN of your address using https://www.findmyaddress.co.uk/search URL = "https://rushmoor.gov.uk" TEST_CASES = { "GU14": {"uprn": "100060551749"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sbazv_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sbazv_de.py index dad2e2fbb..ee21b1d53 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sbazv_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sbazv_de.py @@ -5,9 +5,9 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "Abfall SBAZV" +TITLE = "Südbrandenburgischer Abfallzweckverband" DESCRIPTION = "SBAZV Brandenburg, Deutschland" -URL = "https://www.sbazv.de/entsorgungstermine/klein.ics" +URL = "https://www.sbazv.de" TEST_CASES = { "Wildau": { "city": "wildau", @@ -16,21 +16,23 @@ } } +ICON_MAP = { + "Restmülltonnen": "mdi:trash-can", + "Laubsäcke" : "mdi:leaf", + "Gelbe Säcke" : "mdi:sack", + "Papiertonnen" : "mdi:package-variant", + "Weihnachtsbäume": "mdi:pine-tree", +} + # _LOGGER = logging.getLogger(__name__) + class Source: def __init__(self, city, district, street=None): self._city = city self._district = district self._street = street self._ics = ICS() - self._iconMap = { - "Restmülltonnen": "mdi:trash-can", - "Laubsäcke" : "mdi:leaf", - "Gelbe Säcke" : "mdi:sack", - "Papiertonnen" : "mdi:package-variant", - "Weihnachtsbäume": "mdi:pine-tree", - } def fetch(self): now = datetime.now() @@ -68,6 +70,6 @@ def fetch_year(self, year, city, district, street): waste_type = d[1].strip() next_pickup_date = d[0] - entries.append(Collection(date=next_pickup_date, t=waste_type, icon=self._iconMap.get(waste_type,"mdi:trash-can"))) + entries.append(Collection(date=next_pickup_date, t=waste_type, icon=ICON_MAP.get(waste_type,"mdi:trash-can"))) return entries diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/scambs_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/scambs_gov_uk.py index 177b51650..56427d996 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/scambs_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/scambs_gov_uk.py @@ -4,20 +4,21 @@ import requests from waste_collection_schedule import Collection -TITLE = "Scambs.gov.uk" +TITLE = "South Cambridgeshire District Council" DESCRIPTION = ( "Source for scambs.gov.uk services for South Cambridgeshire District Council" ) -URL = "scambs.gov.uk" +URL = "https://scambs.gov.uk" TEST_CASES = { "houseNumber": {"post_code": "CB236GZ", "number": 53}, "houseName": {"post_code": "CB225HT", "number": "Rectory Farm Cottage"}, } + API_URLS = { "address_search": "https://servicelayer3c.azure-api.net/wastecalendar/address/search/", "collection": "https://servicelayer3c.azure-api.net/wastecalendar/collection/search/{}/", } -ICONS = { +ICON_MAP = { "DOMESTIC": "mdi:trash-can", "RECYCLE": "mdi:recycle", "ORGANIC": "mdi:leaf", @@ -68,7 +69,7 @@ def fetch(self): round_type, round_type.title() ), # returns concise values: Black Bin, Blue Bin, Green Bin # t = round_type.title(), # returns standard Scambs values: Black Bin Collection, Blue Bin Collection, Green Bin Collection - icon=ICONS.get(round_type), + icon=ICON_MAP.get(round_type), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/seattle_gov.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/seattle_gov.py index a03ce1e56..c831b27f5 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/seattle_gov.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/seattle_gov.py @@ -6,7 +6,8 @@ TITLE = "Seattle Public Utilities" DESCRIPTION = "Source for Seattle Public Utilities waste collection." -URL = "https://myutilities.seattle.gov/eportal/#/accountlookup/calendar" +URL = "https://myutilities.seattle.gov" +COUNTRY = "us" TEST_CASES = { "City Hall": {"street_address": "600 4th Ave"}, "Ballard Builders": {"street_address": "7022 12th Ave NW"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sector27_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sector27_de.py index 805ca2d1c..24c4a2f63 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sector27_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sector27_de.py @@ -6,7 +6,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Sector 27" +TITLE = "Sector 27 - Datteln, Marl, Oer-Erkenschwick" DESCRIPTION = "Source for Muellkalender in Kreis RE." URL = "https://muellkalender.sector27.de" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sheffield_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sheffield_gov_uk.py index bba1eb8db..2ff042c90 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sheffield_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sheffield_gov_uk.py @@ -4,20 +4,9 @@ import logging from waste_collection_schedule import Collection -TITLE = "Sheffield.gov.uk" - -DESCRIPTION = ( - "Source for waste collection services from Sheffield City Council (SCC)" -) - -# Base URL for waste collection services -URL = "https://wasteservices.sheffield.gov.uk/" - -# Headers to mimic the browser -HEADERS = { - "user-agent": "Mozilla/5.0", -} - +TITLE = "Sheffield City Council" +DESCRIPTION = "Source for waste collection services from Sheffield City Council (SCC)" +URL = "https://sheffield.gov.uk/" TEST_CASES = { # These are random addresses around Sheffield # If your property is listed here and you don't want it, please raise an issue and I'll amend @@ -26,8 +15,16 @@ "test003" : {"uprn": "100050920796"}, } + +API_URL = "https://wasteservices.sheffield.gov.uk/" + +# Headers to mimic the browser +HEADERS = { + "user-agent": "Mozilla/5.0", +} + # Icons for the different bin types -ICONS = { +ICON_MAP = { "BLACK": "mdi:delete-empty", # General Waste "BROWN": "mdi:glass-fragile", # Glass, Tins, Cans & Plastics "BLUE": "mdi:newspaper", # Paper & Cardboard @@ -44,7 +41,7 @@ def fetch(self): if self._uprn: # Get the page containing bin details # /calendar gives further future informaion over just the "Services" page - req = urllib.request.Request(f"{URL}/property/{self._uprn}/calendar",headers=HEADERS) + req = urllib.request.Request(f"{API_URL}/property/{self._uprn}/calendar",headers=HEADERS) with urllib.request.urlopen(req) as response: html_doc = response.read() @@ -65,7 +62,7 @@ def fetch(self): Collection( date = collection_date, t = collection_type, - icon = ICONS.get(collection_type.replace(" Bin","").upper()), + icon = ICON_MAP.get(collection_type.replace(" Bin","").upper()), ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/south_norfolk_and_broadland_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/south_norfolk_and_broadland_gov_uk.py index 7fdf5b127..056cfa9dd 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/south_norfolk_and_broadland_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/south_norfolk_and_broadland_gov_uk.py @@ -9,9 +9,8 @@ from bs4 import BeautifulSoup as soup from waste_collection_schedule import Collection -TITLE = "South Norfolk and Broadland Council UK" +TITLE = "South Norfolk and Broadland Council" DESCRIPTION = "Source for southnorfolkandbroadland.gov.uk services for South Norfolk and Broadland, UK" - URL = "https://area.southnorfolkandbroadland.gov.uk/" TEST_CASES = { "Random address": { @@ -42,7 +41,7 @@ } } -ICONS = { +ICON_MAP = { "Rubbish": "mdi:trash-can", "Recycling": "mdi:recycle", "Garden (if applicable)": "mdi:leaf" @@ -75,7 +74,7 @@ def fetch(self) -> List[Collection]: Collection( parse_date(tuple(bin_category.children)[3].strip()), tuple(bin_category.children)[1].text.strip(), - icon=ICONS.get(tuple(bin_category.children)[1].text.strip()) + icon=ICON_MAP.get(tuple(bin_category.children)[1].text.strip()) ) for bin_category in bin_categories diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/srvatervinning_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/srvatervinning_se.py index f82310487..2e8bc0972 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/srvatervinning_se.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/srvatervinning_se.py @@ -3,9 +3,9 @@ from datetime import datetime from waste_collection_schedule import Collection -TITLE = "SRV återvinning AB Sweden" +TITLE = "SRV Återvinning" DESCRIPTION = "Source for SRV återvinning AB, Sweden" -URL = "https://www.srvatervinning.se/sophamtning/privat/hamtinformation-och-driftstorningar" +URL = "https://www.srvatervinning.se" TEST_CASES = { "Skansvägen" : {"address":"Skansvägen" }, "TEST2" : {"address":"tun" } diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ssam_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ssam_se.py index 6dbf54698..5231537d0 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ssam_se.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ssam_se.py @@ -4,9 +4,9 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "SSAM Sophämntning" +TITLE = "SSAM" DESCRIPTION = "Source for SSAM waste collection." -URL = "https://edpfuture.ssam.se/FutureWeb/SimpleWastePickup/GetWastePickupSchedule" +URL = "https://ssam.se" TEST_CASES = { "Home": {"street_address": "Asteroidvägen 1, Växjö"}, "Bostadsrätt": {"street_address": "Långa Gatan 29 -81, Växjö"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadt_willich_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadt_willich_de.py index afbc7feea..dfa06595a 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadt_willich_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadt_willich_de.py @@ -6,17 +6,18 @@ TITLE = "Stadt Willich" DESCRIPTION = "Source for Stadt Willich waste collection." URL = "https://www.stadt-willich.de" -ICONS = { +TEST_CASES = { + "Altufer": {"street": "Altufer"}, + "Zum Schickerhof": {"street": "Zum Schickerhof"}, +} + +ICON_MAP = { "Graue Tonne": "mdi:trash-can", "Blaue Tonne": "mdi:newspaper-variant-multiple", "Gelbe Tonne": "mdi:recycle", "Bio Tonne": "mdi:bio", "Grünbündel": "mdi:tree", } -TEST_CASES = { - "Altufer": {"street": "Altufer"}, - "Zum Schickerhof": {"street": "Zum Schickerhof"}, -} class Source: @@ -59,7 +60,7 @@ def fetch(self): entries = [] for d in dates: - icon = ICONS.get(d[1], "mdi:trash-can") + icon = ICON_MAP.get(d[1], "mdi:trash-can") entries.append(Collection( date=d[0], t=d[1], diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtreinigung_dresden_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtreinigung_dresden_de.py index f389a43d5..78d71d55f 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtreinigung_dresden_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtreinigung_dresden_de.py @@ -6,7 +6,7 @@ TITLE = "Stadtreinigung Dresden" DESCRIPTION = "Source for Stadtreinigung Dresden waste collection." -URL = "https://www.dresden.de/apps_ext/AbfallApp/wastebins?0" +URL = "https://www.dresden.de" TEST_CASES = { "Neumarkt 6": {"standort": 80542}, } diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtservice_bruehl_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtservice_bruehl_de.py index 407cf79bd..3a334857f 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtservice_bruehl_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtservice_bruehl_de.py @@ -7,7 +7,7 @@ TITLE = "StadtService Brühl" DESCRIPTION = "Source für Abfallkalender StadtService Brühl" -URL = "https://services.stadtservice-bruehl.de/abfallkalender/" +URL = "https://stadtservice-bruehl.de" TEST_CASES = { "TEST1" : {"strasse":"Badorfer Straße","hnr":"1" } } diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/staedteservice_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/staedteservice_de.py index 83d527d93..89b2c586a 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/staedteservice_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/staedteservice_de.py @@ -4,10 +4,9 @@ from waste_collection_schedule import Collection from waste_collection_schedule.service.ICS import ICS -TITLE = "Städteservice" +TITLE = "Städteservice Raunheim Rüsselsheim" DESCRIPTION = "Städteservice Raunheim Rüsselsheim" URL = "https://www.staedteservice.de" - TEST_CASES = { "Rüsselsheim": { "city": "Rüsselsheim", @@ -19,7 +18,7 @@ }, } -BASE_URL = "https://www.staedteservice.de/abfallkalender" +API_URL = "https://www.staedteservice.de/abfallkalender" CITY_CODE_MAP = { "Rüsselsheim": 1, @@ -64,7 +63,7 @@ def get_dates(self, session: requests.Session, year: int, month: int) -> list: def get_calendar_from_site(self, session: requests.Session, year: int) -> str: # example format: https://www.staedteservice.de/abfallkalender_1_477_2023.ics - URL = f"{BASE_URL}_{self.city_code}_{self.street_number}_{str(year)}.ics" + URL = f"{API_URL}_{self.city_code}_{self.street_number}_{str(year)}.ics" r = session.get(URL) r.raise_for_status() diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stevenage_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stevenage_gov_uk.py index ef2931edf..a0037690b 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stevenage_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stevenage_gov_uk.py @@ -12,11 +12,12 @@ "Wansbeck Close schedule": {"road": "Wansbeck Close", "postcode": "SG1 6AA"}, "Chepstow Close schedule": {"road": "Chepstow Close", "postcode": "SG1 5TT"}, } + SEARCH_URLS = { "round_search": "https://services.stevenage.gov.uk/~?a=find&v=1&p=P1&c=P1_C33_&act=P1_A43_", "collection_search": "https://services.stevenage.gov.uk/~?a=find&v=1&p=P1&c=P1_C37_&act=P1_A64_", } -ICONS = { +ICON_MAP = { "REFUSE": "mdi:trash-can", "RECYCLING": "mdi:recycle", } @@ -83,7 +84,7 @@ def fetch(self): Collection( date=datetime.strptime(collection[1], "%d/%m/%Y").date(), t="Recycling", - icon=ICONS["RECYCLING"], + icon=ICON_MAP["RECYCLING"], ) ) elif collection[2] == "Refuse collection": @@ -91,7 +92,7 @@ def fetch(self): Collection( date=datetime.strptime(collection[1], "%d/%m/%Y").date(), t="Refuse", - icon=ICONS["REFUSE"], + icon=ICON_MAP["REFUSE"], ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stonnington_vic_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stonnington_vic_gov_au.py index aa79389e7..c7ba23a68 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stonnington_vic_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stonnington_vic_gov_au.py @@ -8,7 +8,7 @@ TITLE = "Stonnington City Council" DESCRIPTION = "Source for Stonnington City Council rubbish collection." -URL = "https://www.stonnington.vic.gov.au/Services/Waste-and-recycling" +URL = "https://www.stonnington.vic.gov.au" TEST_CASES = { "The Jam Factory": {"street_address": "500 Chapel Street, South Yarra"}, "Malvern Library": {"street_address": "1255 High Street, Malvern"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stuttgart_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stuttgart_de.py index 57ad6d10d..4d6926ce3 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stuttgart_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stuttgart_de.py @@ -6,7 +6,7 @@ TITLE = "Abfall Stuttgart" DESCRIPTION = "Source for waste collections for the city of Stuttgart, Germany." -URL = "https://service.stuttgart.de/lhs-services/aws/" +URL = "https://service.stuttgart.de" TEST_CASES = {"Im Steinengarten 7": {"street": "Im Steinengarten", "streetnr": 7}} diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sysav_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sysav_se.py index 9152c45f1..ecb6f2e6e 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sysav_se.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sysav_se.py @@ -6,7 +6,7 @@ TITLE = "Sysav Sophämntning" DESCRIPTION = "Source for Sysav waste collection." -URL = "https://www.sysav.se/Privat/min-sophamtning/" +URL = "https://www.sysav.se" TEST_CASES = { "Home": {"street_address": "Sommargatan 1, Svedala"}, "Polisen": {"street_address": "Stationsplan 1, Svedala"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/tewkesbury_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/tewkesbury_gov_uk.py index f6a11e107..a5ddc65e6 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/tewkesbury_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/tewkesbury_gov_uk.py @@ -4,9 +4,9 @@ import requests from waste_collection_schedule import Collection -TITLE = "Tewkesbury Borough Council Waste and Recycling" +TITLE = "Tewkesbury Borough Council" DESCRIPTION = "Home waste collection schedule for Tewkesbury Borough Council" -URL = "https://www.tewkesbury.gov.uk/waste-and-recycling" +URL = "https://www.tewkesbury.gov.uk" TEST_CASES = { "Council Office": {"postcode": "GL20 5TT"}, "Council Office No Spaces": {"postcode": "GL205TT"}, @@ -14,7 +14,7 @@ API_URL = "https://api-2.tewkesbury.gov.uk/general/rounds/%s/nextCollection" -ICONS = { +ICON_MAP = { "Refuse": "mdi:trash-can", "Recycling": "mdi:recycle", "Garden": "mdi:leaf", @@ -47,7 +47,7 @@ def fetch(self): date=datetime.strptime( schedule_entry["NextCollection"], "%Y-%m-%d").date(), t=schedule_entry["collectionType"], - icon=ICONS.get(schedule_entry["collectionType"]) + icon=ICON_MAP.get(schedule_entry["collectionType"]) ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/thehills_nsw_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/thehills_nsw_gov_au.py index 32468ab1f..a9a945637 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/thehills_nsw_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/thehills_nsw_gov_au.py @@ -5,7 +5,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "The Hills Shire Council" +TITLE = "The Hills Shire Council, Sydney" DESCRIPTION = "Source for Hills Shire Council, Sydney, Australia waste collection." URL = "https://www.thehills.nsw.gov.au/" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/toronto_ca.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/toronto_ca.py index 2f5b14c64..a38a984bf 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/toronto_ca.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/toronto_ca.py @@ -6,17 +6,15 @@ from datetime import datetime, timedelta -TITLE = 'Toronto' -DESCRIPTION = ( - 'Source for Toronto waste collection' -) +TITLE = 'City of Toronto' +DESCRIPTION = 'Source for Toronto waste collection' URL = 'https://www.toronto.ca' -CSV_URL = 'https://www.toronto.ca/ext/swms/collection_calendar.csv' TEST_CASES = { "224 Wallace Ave": {"street_address": "224 Wallace Ave"}, "324 Weston Rd": {"street_address": "324 Weston Rd"}, } +CSV_URL = 'https://www.toronto.ca/ext/swms/collection_calendar.csv' PROPERTY_LOOKUP_URL = 'https://map.toronto.ca/cotgeocoder/rest/geocoder/suggest' SCHEDULE_LOOKUP_URL = 'https://map.toronto.ca/cotgeocoder/rest/geocoder/findAddressCandidates' diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/vasyd_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/vasyd_se.py index 0111d2dd5..d9e4b9f56 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/vasyd_se.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/vasyd_se.py @@ -6,9 +6,7 @@ TITLE = "VA Syd Sophämntning" DESCRIPTION = "Source for VA Syd waste collection." -URL = ( - "https://www.vasyd.se/Artiklar/Avfall-och-soptomning-privat/sopt%C3%B6mning-schema/" -) +URL = "https://www.vasyd.se" TEST_CASES = { "Home": {"street_address": "Industrigatan 13, Malmö"}, "Polisen": {"street_address": "Drottninggatan 20, Malmö"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/waipa_nz.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/waipa_nz.py index 03c000100..9c9a67092 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/waipa_nz.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/waipa_nz.py @@ -9,8 +9,8 @@ DESCRIPTION = "Source for Waipa District Council. Finds both general and glass recycling dates." URL = "https://www.waipadc.govt.nz/" TEST_CASES = { - "10 Queen Street": {"address": "10 Queen Street"} #Monday - ,"1 Acacia Avenue": {"address": "1 Acacia Avenue"}#Wednesday + "10 Queen Street": {"address": "10 Queen Street"}, # Monday + "1 Acacia Avenue": {"address": "1 Acacia Avenue"}, # Wednesday } diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/walsall_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/walsall_gov_uk.py index d14ac65ca..a501c6812 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/walsall_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/walsall_gov_uk.py @@ -6,18 +6,9 @@ from waste_collection_schedule import Collection -TITLE = "walsall.gov.uk" - -DESCRIPTION = ( - "Source for waste collection services from Walsall Council" -) - -URL = "https://cag.walsall.gov.uk" - -HEADERS = { - "user-agent": "Mozilla/5.0", -} - +TITLE = "Walsall Council" +DESCRIPTION = "Source for waste collection services from Walsall Council" +URL = "https://www.walsall.gov.uk/" TEST_CASES = { "test001" : {"uprn": "100071103746"}, "test002" : {"uprn": 100071105627}, @@ -25,11 +16,15 @@ "test004" : {"uprn": 100071048794}, } -ICONS = { +API_URL = "https://cag.walsall.gov.uk" +ICON_MAP = { "GREY": "mdi:trash-can", "GREEN": "mdi:recycle", "BROWN": "mdi:leaf", } +HEADERS = { + "user-agent": "Mozilla/5.0", +} _LOGGER = logging.getLogger(__name__) @@ -55,7 +50,7 @@ def fetch(self): if "roundname" in item["href"]: #get bin colour bincolour = item["href"].split("=")[-1].split("%")[0].upper() - binURL = URL + item["href"] + binURL = API_URL + item["href"] r = s.get(binURL, headers=HEADERS) responseContent = r.text soup = BeautifulSoup(responseContent, "html.parser") @@ -67,7 +62,7 @@ def fetch(self): Collection( date = collection_date.date(), t = bincolour, - icon = ICONS.get(bincolour), + icon = ICON_MAP.get(bincolour), ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py index 51e2c0b56..593150a56 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py @@ -4,9 +4,9 @@ import requests from waste_collection_schedule import Collection -TITLE = "Warszawa19115.pl" +TITLE = "Warsaw" DESCRIPTION = "Source for Warsaw city garbage collection" -URL = "https://warszawa19115.pl/harmonogramy-wywozu-odpadow" +URL = "https://warszawa19115.pl" TEST_CASES = { "Street Name": {"street_address": "MARSZAŁKOWSKA 84/92, 00-514 Śródmieście"}, "Geolocation ID": {"geolocation_id": "76802934"}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wastenet_org_nz.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wastenet_org_nz.py index 425089fc2..5cc5dae8d 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wastenet_org_nz.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wastenet_org_nz.py @@ -5,7 +5,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "Wastenet" +TITLE = "Gore, Invercargill & Southland" DESCRIPTION = "Source for Wastenet.org.nz." URL = "http://www.wastenet.org.nz" TEST_CASES = { diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wermelskirchen_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wermelskirchen_de.py index 1f2b4b4b9..0336d9fb1 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wermelskirchen_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wermelskirchen_de.py @@ -4,17 +4,16 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "Abfallkalender Wermelskirchen" +TITLE = "Wermelskirchen" DESCRIPTION = "Source for Abfallabholung Wermelskirchen, Germany" -URL = "https://www.wermelskirchen.de/rathaus/buergerservice/formulare-a-z/abfallkalender-online/" - +URL = "https://www.wermelskirchen.de" TEST_CASES = { "Rathaus": {"street": "Telegrafenstraße", "house_number": "29"}, "Krankenhaus": {"street": "Königstraße", "house_number": "100"}, "Mehrzweckhalle": {"street": "An der Mehrzweckhalle", "house_number": "1"}, } -INFOS = { +ICON_MAP = { "Restabfall 2-woechentlich": { "icon": "mdi:trash-can", "image": "https://abfallkalender.citkomm.de/fileadmin/_processed_/1/b/csm_Restmuell_6b2b32c774.png", @@ -80,7 +79,7 @@ def fetch(self): entries = [] for d in dates: - info = INFOS.get(d[1], {"icon": "mdi:trash-can", "image": ""}) + info = ICON_MAP.get(d[1], {"icon": "mdi:trash-can", "image": ""}) entries.append( Collection(d[0], d[1], picture=info["image"], icon=info["icon"]) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/westberks_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/westberks_gov_uk.py index 9a24b47de..df98987b6 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/westberks_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/westberks_gov_uk.py @@ -6,10 +6,9 @@ from waste_collection_schedule import Collection -TITLE = "West Berkshire Council, UK" +TITLE = "West Berkshire Council" DESCRIPTION = "Source for westberks.gov.uk services for West Berkshire Council" -URL = "westberks.gov.uk" - +URL = "https://westberks.gov.uk" TEST_CASES = { "known_uprn": {"uprn": "100080241094"}, "unknown_uprn_by_name": {"postcode": "RG7 6NZ", "housenumberorname": "PARROG HOUSE"}, @@ -17,7 +16,7 @@ "unknown_uprn_business": {"postcode": "RG18 4GE", "housenumberorname": "3"} } -ICONS = { +ICON_MAP = { "RUBBISH": "mdi:trash-can", "RECYCLING": "mdi:recycle", } @@ -90,7 +89,7 @@ def fetch(self): Collection( date=dt_local.date(), t=waste_type, - icon=ICONS.get(waste_type.upper()), + icon=ICON_MAP.get(waste_type.upper()), ) ) @@ -106,7 +105,7 @@ def fetch(self): Collection( date=dt_local.date(), t=waste_type, - icon=ICONS.get(waste_type.upper()), + icon=ICON_MAP.get(waste_type.upper()), ) ) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wiltshire_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wiltshire_gov_uk.py index b4a6bc0e7..6c2d5ca1c 100755 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wiltshire_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wiltshire_gov_uk.py @@ -4,12 +4,13 @@ from bs4 import BeautifulSoup from waste_collection_schedule import Collection -TITLE = "Wiltshire Council, UK" +TITLE = "Wiltshire Council" DESCRIPTION = "Source for wiltshire.gov.uk services for Wiltshire Council" -URL = "wiltshire.gov.uk" +URL = "https://wiltshire.gov.uk" TEST_CASES = { "house_uprn": {"uprn": "100121085972", "postcode": "BA149QP"}, } + SEARCH_URLS = { "collection_search": "https://ilforms.wiltshire.gov.uk/wastecollectiondays/collectionlist" } diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wsz_moosburg_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wsz_moosburg_at.py index 5cf42e7cd..0334b7fb3 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wsz_moosburg_at.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wsz_moosburg_at.py @@ -8,7 +8,7 @@ DESCRIPTION = ( "Source for WSZ Moosburg/Kärnten, including Moosburg, Pörtschach, Techelsberg" ) -URL = "https://wsz-moosburg.at/calendar" +URL = "https://wsz-moosburg.at" TEST_CASES = { "Id: Moosburg, Obergöriach": {"address_id": 70265}, "Id: Moosburg, Pestalozzistr": {"address_id": 70082}, diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wuerzburg_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wuerzburg_de.py index 9d16dd84f..e06f31bca 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wuerzburg_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wuerzburg_de.py @@ -6,8 +6,7 @@ TITLE = "Abfallkalender Würzburg" DESCRIPTION = "Source for waste collection in the city of Würzburg, Germany." -URL = "https://www.wuerzburg.de/themen/umwelt-klima/vorsorge-entsorgung/abfallkalender/32208.Abfallkalender.html" -HEADERS = {"user-agent": "Mozilla/5.0 (xxxx Windows NT 10.0; Win64; x64)"} +URL = "https://www.wuerzburg.de" TEST_CASES = { "District only": {"district": "Altstadt"}, "Street only": {"street": "Juliuspromenade"}, @@ -15,6 +14,9 @@ "District + Street diff": {"district": "Altstadt", "street": "Oberer Burgweg"}, } +API_URL = "https://www.wuerzburg.de/themen/umwelt-klima/vorsorge-entsorgung/abfallkalender/32208.Abfallkalender.html" +HEADERS = {"user-agent": "Mozilla/5.0 (xxxx Windows NT 10.0; Win64; x64)"} + class Source: def __init__(self, district: str = None, street: str = None): @@ -31,7 +33,7 @@ def map_district_id(district: str = None, street: str = None): if not district and not street: raise ValueError("One of ['district', 'street'] is required.") - r = requests.get(URL, headers=HEADERS) + r = requests.get(API_URL, headers=HEADERS) r.raise_for_status() selects = BeautifulSoup(r.content, "html.parser").body.find_all("select") @@ -49,7 +51,7 @@ def map_district_id(district: str = None, street: str = None): return strdict[street] except KeyError: raise KeyError( - f"Unable to find street '{street}'. Please compare exact typing with {URL}" + f"Unable to find street '{street}'. Please compare exact typing with {API_URL}" ) if district: @@ -64,7 +66,7 @@ def map_district_id(district: str = None, street: str = None): return regdict[district] except KeyError: raise KeyError( - f"Unable to find district '{district}'. Please compare exact typing with {URL}" + f"Unable to find district '{district}'. Please compare exact typing with {API_URL}" ) def fetch(self): @@ -78,7 +80,7 @@ def fetch(self): now = datetime.datetime.now().date() r = requests.get( - URL, + API_URL, headers=HEADERS, params={ "_func": "evList", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wyndham_vic_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wyndham_vic_gov_au.py index 9c3d1c9c1..930c2683f 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wyndham_vic_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wyndham_vic_gov_au.py @@ -5,9 +5,9 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from datetime import datetime -TITLE = "Wyndham City Council" +TITLE = "Wyndham City Council, Melbourne" DESCRIPTION = "Source for Wyndham City Council rubbish collection." -URL = "https://digital.wyndham.vic.gov.au/myWyndham/" +URL = "https://wyndham.vic.gov.au" TEST_CASES = { "Truganina South Primary School": {"street_address": "3-19 Parkvista Drive TRUGANINA 3029"}, "Westbourne Grammar School": {"street_address": "300 Sayers Road TRUGANINA 3029"}, @@ -15,6 +15,7 @@ "Wyndham Park Primary School": {"street_address": "59-77 Kookaburra Avenue WERRIBEE 3030"}, } +API_URL = "https://digital.wyndham.vic.gov.au/myWyndham/" ICON_MAP = { "Green Waste": "mdi:leaf", "Garbage": "mdi:trash-can-outline", @@ -30,7 +31,7 @@ def __init__(self, street_address): def fetch(self): session = requests.Session() - response = session.get(URL) + response = session.get(API_URL) response.raise_for_status() response = session.get("https://digital.wyndham.vic.gov.au/myWyndham/ajax/address-search-suggestions.asp?", params=dict(ASEARCH=self._street_address), diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/york_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/york_gov_uk.py index 77c09fa5d..69d716542 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/york_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/york_gov_uk.py @@ -4,7 +4,7 @@ import requests from waste_collection_schedule import Collection # type: ignore[attr-defined] -TITLE = "York.gov.uk" +TITLE = "City of York Council" DESCRIPTION = "Source for York.gov.uk services for the city of York, UK." URL = "https://york.gov.uk" TEST_CASES = { @@ -12,7 +12,7 @@ "Granary Walk, York": {"uprn": "010093236548"}, } -ICONS = { +ICON_MAP = { "REFUSE": "mdi:trash-can", "RECYCLING": "mdi:recycle", "GARDEN": "mdi:leaf", @@ -42,7 +42,7 @@ def fetch(self): collection["date"], "%Y-%m-%dT%H:%M:%S" ).date(), t=collection["roundType"].title(), - icon=ICONS[collection["roundType"]], + icon=ICON_MAP[collection["roundType"]], ) ) except ValueError: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/zva_wmk_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/zva_wmk_de.py index 728eabb99..5eeb113de 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/zva_wmk_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/zva_wmk_de.py @@ -4,7 +4,7 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined] from waste_collection_schedule.service.ICS import ICS -TITLE = "Zweckverband Abfallwirtschaft Werra-Meißner-Kreis" +TITLE = "Abfallwirtschaft Werra-Meißner-Kreis" DESCRIPTION = "Source for Zweckverband Abfallwirtschaft Werra-Meißner-Kreis" URL = "https://www.zva-wmk.de/" TEST_CASES = { diff --git a/doc/source/abfall_neunkirchen_siegerland_de.md b/doc/source/abfall_neunkirchen_siegerland_de.md index 9c60b2cba..aaca8eace 100644 --- a/doc/source/abfall_neunkirchen_siegerland_de.md +++ b/doc/source/abfall_neunkirchen_siegerland_de.md @@ -14,7 +14,7 @@ waste_collection_schedule: ### Configuration Variables -**strasse**
+**strasse** *(string) (required)* ## Example diff --git a/doc/source/art_trier_de.md b/doc/source/art_trier_de.md index e32706cf1..abe706454 100644 --- a/doc/source/art_trier_de.md +++ b/doc/source/art_trier_de.md @@ -15,10 +15,10 @@ waste_collection_schedule: ### Configuration Variables -**district**
+**district** _(string) (required)_ -**zip_code**
+**zip_code** _(string) (required)_ ## Example diff --git a/doc/source/bracknell_forest_gov_uk.md b/doc/source/bracknell_forest_gov_uk.md index 49ab41429..aa41c9fe8 100644 --- a/doc/source/bracknell_forest_gov_uk.md +++ b/doc/source/bracknell_forest_gov_uk.md @@ -15,10 +15,10 @@ waste_collection_schedule: ### Configuration Variables -**post_code**
+**post_code** *(string) (required)* -**house_number**
+**house_number** *(string) (required)* ## Example diff --git a/doc/source/braintree_gov_uk.md b/doc/source/braintree_gov_uk.md index 8c9c8d232..6560384e9 100644 --- a/doc/source/braintree_gov_uk.md +++ b/doc/source/braintree_gov_uk.md @@ -15,10 +15,10 @@ waste_collection_schedule: ### Configuration Variables -**post_code**
+**post_code** *(string) (required)* -**house_number**
+**house_number** *(string) (required)* ## Example diff --git a/doc/source/korneuburg_stadtservice_at.md b/doc/source/korneuburg_stadtservice_at.md index 7c550765e..1f23d171a 100644 --- a/doc/source/korneuburg_stadtservice_at.md +++ b/doc/source/korneuburg_stadtservice_at.md @@ -16,27 +16,28 @@ waste_collection_schedule: ### Configuration Variables -**street_name**
+**street_name** *(string) (required)* -**street_number**
+**street_number** *(string) (required)* -**teilgebiet**
+**teilgebiet** *(string) (optional)* ### How to get the source arguments + The arguments can be found on [Stadtservice Korneuburg](https://www.korneuburg.gv.at/Rathaus/Buergerservice/Muellabfuhr). Check if your address details are available on the official site. If not use something that is close by or the same region. You can enter your region number (`teilgebiet`) directly to skip the step that determines your region based on your address. Still some values need to be set for `street_name` and `street_number` which are then not used. -
## Example **First Entry** + ```yaml waste_collection_schedule: sources: @@ -45,7 +46,9 @@ waste_collection_schedule: street_name: "Albrecht Dürer-Gasse" street_number: 2 ``` + **Rathaus** + ```yaml waste_collection_schedule: sources: @@ -54,7 +57,9 @@ waste_collection_schedule: street_name: Hauptplatz street_number: 39 ``` + **Rathaus using Teilgebiet** + ```yaml waste_collection_schedule: sources: diff --git a/doc/source/nillumbik_vic_gov_au.md b/doc/source/nillumbik_vic_gov_au.md index ca4228570..56876989b 100644 --- a/doc/source/nillumbik_vic_gov_au.md +++ b/doc/source/nillumbik_vic_gov_au.md @@ -14,7 +14,7 @@ waste_collection_schedule: ### Configuration Variables -**street_address**
+**street_address** *(string) (required)* ## Example diff --git a/doc/source/srvatervinning_se.md b/doc/source/srvatervinning_se.md index b9e77edd3..05c5c4766 100644 --- a/doc/source/srvatervinning_se.md +++ b/doc/source/srvatervinning_se.md @@ -1,4 +1,4 @@ -# SRV återvinning AB +# SRV Återvinning Support for schedules provided by [SRV återvinning AB](https://www.srvatervinning.se/), Sweden. @@ -14,7 +14,7 @@ waste_collection_schedule: ### Configuration Variables -**address**
+**address** *(string) (required)* ## Example diff --git a/doc/source/stadtservice_bruehl_de.md b/doc/source/stadtservice_bruehl_de.md index c3abeece4..a17c7b179 100644 --- a/doc/source/stadtservice_bruehl_de.md +++ b/doc/source/stadtservice_bruehl_de.md @@ -15,9 +15,10 @@ waste_collection_schedule: ### Configuration Variables -**strasse**
+**strasse** *(string) (required)* -**hnr**
+ +**hnr** *(string) (required)* ## Example diff --git a/doc/source/toronto_ca.md b/doc/source/toronto_ca.md index 97f57f4ee..7e4321b54 100644 --- a/doc/source/toronto_ca.md +++ b/doc/source/toronto_ca.md @@ -14,7 +14,7 @@ waste_collection_schedule: ### Configuration Variables -**street_address**
+**street_address** *(string) (required)* ## Example diff --git a/doc/source/zva_wmk_de.md b/doc/source/zva_wmk_de.md index afeed0908..1429c4e29 100644 --- a/doc/source/zva_wmk_de.md +++ b/doc/source/zva_wmk_de.md @@ -1,4 +1,5 @@ # Zweckverband Abfallwirtschaft Werra-Meißner-Kreis + Support für Werra-Meißner-Kreis located in Hesse, Germany ## Configuration via configuration.yaml @@ -14,10 +15,12 @@ waste_collection_schedule: ### Configuration Variables -**city**
+**city** *(string) (required)* -**street**
+**street** +*(street) (required)* + ### How to get the source arguments Visit [zva-wmk.de](https://www.zva-wmk.de/termine/schnellsuche-2023) and search for your locality. Use the value from the "Ort" dropdown as `city` argument and the one from "Ortsteil/Straße" as `street` as shown. diff --git a/make_docu.py b/make_docu.py new file mode 100755 index 000000000..0706194c4 --- /dev/null +++ b/make_docu.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 + +import argparse +import importlib +import re +import site +from pathlib import Path + +import yaml + +SECRET_FILENAME = "secrets.yaml" +SECRET_REGEX = re.compile(r"!secret\s(\w+)") + + +def main(): + parser = argparse.ArgumentParser(description="Test sources.") + args = parser.parse_args() + + # read secrets.yaml + secrets = {} + try: + with open(SECRET_FILENAME) as stream: + try: + secrets = yaml.safe_load(stream) + except yaml.YAMLError as exc: + print(exc) + except FileNotFoundError: + # ignore missing secrets.yaml + pass + + package_dir = Path(__file__).resolve().parents[0] / "custom_components" / "waste_collection_schedule" + source_dir = package_dir / "waste_collection_schedule" / "source" + print(source_dir) + + # add module directory to path + site.addsitedir(str(package_dir)) + + files = filter( + lambda x: x != "__init__", + map(lambda x: x.stem, source_dir.glob("*.py")), + ) + + sources = [] + + # retrieve all data from sources + for f in files: + # iterate through all *.py files in waste_collection_schedule/source + module = importlib.import_module(f"waste_collection_schedule.source.{f}") + + title = module.TITLE + url = module.URL + country = getattr(module, "COUNTRY", f.split("_")[-1]) + + if title is not None: + sources.append(SourceInfo(filename=f, title=title, url=url, country=country)) + + extra_info = getattr(module, "EXTRA_INFO", []) + if callable(extra_info): + extra_info = extra_info() + for e in extra_info: + sources.append(SourceInfo(filename=f, title=e.get("title", title), url=e.get("url", url), country=e.get("country", country))) + + # sort into countries + country_code_map = make_country_code_map() + countries = {} + zombies = [] + for s in sources: + # extract country code + code = s.country + if code in country_code_map: + countries.setdefault(country_code_map[code]["name"], []).append(s) + else: + zombies.append(s) + + for country in sorted(countries): + print(f"{country}") + for e in sorted(countries[country], key=lambda e: e.title): + print(f" {e.title} - {beautify_url(e.url)}") + + print("Zombies =========================") + for z in zombies: + print(z) + + +def beautify_url(url): + url = url.removesuffix("/") + url = url.removeprefix("https://") + url = url.removeprefix("www.") + return url + +class SourceInfo: + def __init__(self, filename, title, url, country): + self._filename = filename + self._title = title + self._url = url + self._country = country + + def __repr__(self): + return f"filename:{self._filename}, title:{self._title}, url:{self._url}, country:{self._country}" + + @property + def filename(self): + return self._filename + + @property + def title(self): + return self._title + + @property + def url(self): + return self._url + + @property + def country(self): + return self._country + + +def make_country_code_map(): + return { x["code"]:x for x in COUNTRYCODES } + +COUNTRYCODES = [ + { + "code": "au", + "name": "Australia", + }, + { + "code": "at", + "name": "Austria", + }, + { + "code": "be", + "name": "Belgium", + }, + { + "code": "ca", + "name": "Canada", + }, + { + "code": "de", + "name": "Germany", + }, + { + "code": "hamburg", + "name": "Germany", + }, + { + "code": "lt", + "name": "Lithuania", + }, + { + "code": "nl", + "name": "Netherlands", + }, + { + "code": "nz", + "name": "New Zealand", + }, + { + "code": "no", + "name": "Norway", + }, + { + "code": "pl", + "name": "Poland", + }, + { + "code": "se", + "name": "Sweden", + }, + { + "code": "ch", + "name": "Switzerland", + }, + { + "code": "us", + "name": "United States of America", + }, + { + "code": "uk", + "name": "United Kingdom", + }, +] + +if __name__ == "__main__": + main() \ No newline at end of file