From fc4b6fbb83b3b7687a5295d2e322ca6fadb4d932 Mon Sep 17 00:00:00 2001 From: dt215git <86194065+dt215git@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:40:07 +0100 Subject: [PATCH 1/4] Calculate Refuse collection dates from day name --- .../source/dudley_gov_uk.py | 44 +++++++++++-------- tests/bandit.yaml | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/dudley_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/dudley_gov_uk.py index f8f399499..d20780b0a 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/dudley_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/dudley_gov_uk.py @@ -15,7 +15,19 @@ "Test_004": {"uprn": 90092621}, } ICON_MAP = {"RECYCLING": "mdi:recycle", "GARDEN": "mdi:leaf", "REFUSE": "mdi:trash-can"} -REGEX = r"(\d+ \w{3})" +REGEX = { + "DATES": r"(\d+ \w{3})", + "DAYS": r"every: (Monday|Tuesday|Wednesday|Thursday|Friday)", +} +DAYS = { + "Monday": 0, + "Tuesday": 1, + "Wednesday": 2, + "Thursday": 3, + "Friday": 4, + "Saturday": 5, + "Sunday": 6, +} class Source: @@ -35,12 +47,6 @@ def check_date(self, d: str, t: datetime, y: int): return date.date() def append_entries(self, d: datetime, w: str, e: list) -> list: - """ - Append provided entry and Refuse entry for the same day. - - Refuse is collected on the same dates as alternating Recycling/Garden collections, - so create two entries for each date Refuse & Recycling, or Refuse & Garden - """ e.append( Collection( date=d, @@ -48,17 +54,9 @@ def append_entries(self, d: datetime, w: str, e: list) -> list: icon=ICON_MAP.get(w.upper()), ) ) - e.append( - Collection( - date=d, - t="Refuse", - icon=ICON_MAP.get("REFUSE"), - ) - ) return e def fetch(self): - today = datetime.now() today = today.replace(hour=0, minute=0, second=0, microsecond=0) yr = int(today.year) @@ -71,22 +69,30 @@ def fetch(self): panel = soup.find("div", {"aria-label": "Refuse and Recycling Collection"}) panel_data = panel.find("div", {"class": "atPanelData"}) - panel_data = panel_data.text.split("Next")[ + waste_data = panel_data.text.split("Next")[ 1: ] # remove first element it just contains general info entries = [] - for item in panel_data: + # Deal with Recycling and Garden collections + for item in waste_data: text = item.replace("\r\n", "").strip() if "recycling" in text: - dates = re.findall(REGEX, text) + dates = re.findall(REGEX["DATES"], text) for dt in dates: dt = self.check_date(dt, today, yr) self.append_entries(dt, "Recycling", entries) elif "garden" in text: - dates = re.findall(REGEX, text) + dates = re.findall(REGEX["DATES"], text) for dt in dates: dt = self.check_date(dt, today, yr) self.append_entries(dt, "Garden", entries) + # Refuse collections only have a DAY not a date, so work out dates for the next few collections + refuse_day = re.findall(REGEX["DAYS"], panel_data.text)[0] + refuse_date = today + timedelta((int(DAYS[refuse_day]) - today.weekday()) % 7) + for i in range(0, 4): + temp_date = refuse_date + timedelta(days=7 * i) + self.append_entries(temp_date.date(), "Refuse", entries) + return entries diff --git a/tests/bandit.yaml b/tests/bandit.yaml index ebd284eaa..50adb7744 100644 --- a/tests/bandit.yaml +++ b/tests/bandit.yaml @@ -12,6 +12,6 @@ tests: - B318 - B319 - B320 - - B325 +# - B325 - B602 - B604 From 572e08c66c1581162141644f81bd8679d7caae6b Mon Sep 17 00:00:00 2001 From: dt215git <86194065+dt215git@users.noreply.github.com> Date: Sun, 22 Oct 2023 14:19:21 +0100 Subject: [PATCH 2/4] New Source: Warwick District Council, UK (#1343) * warwick source, initial commit * .md added * update_docu_links run --- .pre-commit-config.yaml | 2 +- README.md | 1 + .../source/warwickdc_gov_uk.py | 52 +++++++++++++++++++ doc/source/warwickdc_gov_uk.md | 35 +++++++++++++ info.md | 2 +- tests/bandit.yaml | 2 +- 6 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 custom_components/waste_collection_schedule/waste_collection_schedule/source/warwickdc_gov_uk.py create mode 100644 doc/source/warwickdc_gov_uk.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a9078619..6098eeb6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: hooks: - id: codespell args: - - --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,Adresse,termine,adresse,oder,alle,assistent,hart + - --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,Adresse,termine,adresse,oder,alle,assistent,hart,marz - --skip="./.*,*.csv,*.json" - --quiet-level=2 exclude_types: [csv, json] diff --git a/README.md b/README.md index 10f4432a8..ed0eca9bd 100644 --- a/README.md +++ b/README.md @@ -1102,6 +1102,7 @@ Waste collection schedules in the following formats and countries are supported. - [Vale of White Horse District Council](/doc/source/binzone_uk.md) / whitehorsedc.gov.uk - [Walsall Council](/doc/source/walsall_gov_uk.md) / walsall.gov.uk - [Warrington Borough Council](/doc/source/warrington_gov_uk.md) / warrington.gov.uk +- [Warwick District Council](/doc/source/warwickdc_gov_uk.md) / warwickdc.gov.uk - [Waverley Borough Council](/doc/source/waverley_gov_uk.md) / waverley.gov.uk - [Wealden District Council](/doc/source/wealden_gov_uk.md) / wealden.gov.uk - [Welwyn Hatfield Borough Council](/doc/source/welhat_gov_uk.md) / welhat.gov.uk diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warwickdc_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warwickdc_gov_uk.py new file mode 100644 index 000000000..e2e53503a --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warwickdc_gov_uk.py @@ -0,0 +1,52 @@ +from datetime import datetime + +import requests +from bs4 import BeautifulSoup +from waste_collection_schedule import Collection # type: ignore[attr-defined] + +TITLE = "Warwick District Council" +DESCRIPTION = "Source for Warwick District Council rubbish collection." +URL = "https://www.warwickdc.gov.uk" +TEST_CASES = { + "Test_001": {"uprn": "100070260258"}, + "Test_002": {"uprn": "100070258568"}, + "Test_003": {"uprn": 100070263501}, +} +ICON_MAP = { + "FOOD": "mdi:food", + "GARDEN": "mdi:leaf", + "RECYCLING": "mdi:recycle", + "REFUSE": "mdi:trash-can", +} + + +class Source: + def __init__(self, uprn): + self._uprn = str(uprn) + + def fetch(self): + s = requests.Session() + r = s.get( + f"https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/{self._uprn}" + ) + soup = BeautifulSoup(r.text, "html.parser") + + infoboxes = soup.findAll( + "div", {"class": "col-xs-12 text-center waste-dates margin-bottom-15"} + ) + + entries = [] + for box in infoboxes: + items = box.findAll("p") + waste_type = items[0].text.strip().split(" ")[0].strip() + dates = [datetime.strptime(d.text, "%d/%m/%Y").date() for d in items[1:]] + for date in dates: + entries.append( + Collection( + date=date, + t=waste_type, + icon=ICON_MAP.get(waste_type.upper()), + ) + ) + + return entries diff --git a/doc/source/warwickdc_gov_uk.md b/doc/source/warwickdc_gov_uk.md new file mode 100644 index 000000000..dccec4c1f --- /dev/null +++ b/doc/source/warwickdc_gov_uk.md @@ -0,0 +1,35 @@ +# Warwick District Council + +Support for schedules provided by [Warwick District Council](https://www.warwickdc.gov.uk/info/20465/rubbish_waste_and_recycling). + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: warwickdc_gov_uk + args: + uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER +``` + +### Configuration Variables + +**uprn** +*(string) (required)* + + +## Example using UPRN + +```yaml +waste_collection_schedule: + sources: + - name: warwickdc_gov_uk + args: + uprn: "100070263501" +``` + +## How to find your `UPRN` + +An easy way to find your Unique Property Reference Number (UPRN) is by going to and entering in your address details. + +Alternatively you can inspect the URL on [Warwick District Council](https://www.warwickdc.gov.uk/info/20465/rubbish_waste_and_recycling). Having searched for your collection schedule, your UPRN is the collection of digits at the end of the URL, for example: _https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/`100070260258`_ diff --git a/info.md b/info.md index f1e2fbc48..004aae6e9 100644 --- a/info.md +++ b/info.md @@ -33,7 +33,7 @@ Waste collection schedules from service provider web sites are updated daily, de | Slovenia | Moji odpadki, Ljubljana | | Sweden | Affärsverken, Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Region Gotland, Ronneby Miljöteknik, Samverkan Återvinning Miljö (SÅM), SRV Återvinning, SSAM, Sysav Sophämntning, Uppsala Vatten och Avfall AB, VA Syd Sophämntning | | Switzerland | A-Region, Andwil, Appenzell, Berg, Bühler, Eggersriet, Gais, Gaiserwald, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Münchenstein, Real Luzern, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden | -| United Kingdom | Aberdeenshire Council, Allerdale Borough Council, Amber Valley Borough Council, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Borough Council of King's Lynn & West Norfolk, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Broadland District Council, Broxtowe Borough Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Burnley Council, Cambridge City Council, Canterbury City Council, Cardiff Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Cheshire West and Chester Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City Of Lincoln Council, City of York Council, Colchester City Council, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Derby City Council, Dudley Metropolitan Borough Council, Durham County Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Harlow Council, Hart District Council, Herefordshire City Council, Highland, Horsham District Council, Huntingdonshire District Council, iTouchVision, Joint Waste Solutions, Kirklees Council, Leicester City Council, Lewes District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Bexley, London Borough of Bromley, London Borough of Camden, London Borough of Lewisham, London Borough of Merton, Maidstone Borough Council, Maldon District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Somerset Council, North Yorkshire Council - Hambleton, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City Council, Somerset Council, Somerset County Council, Somerset West & Taunton District Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Holland District Council, South Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Surrey Heath Borough Council, Swindon Borough Council, Tameside Metropolitan Borough Council, Telford and Wrekin Council, Test Valley Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Warrington Borough Council, Waverley Borough Council, Wealden District Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Wyre Forest District Council | +| United Kingdom | Aberdeenshire Council, Allerdale Borough Council, Amber Valley Borough Council, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Borough Council of King's Lynn & West Norfolk, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Broadland District Council, Broxtowe Borough Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Burnley Council, Cambridge City Council, Canterbury City Council, Cardiff Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Cheshire West and Chester Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City Of Lincoln Council, City of York Council, Colchester City Council, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Derby City Council, Dudley Metropolitan Borough Council, Durham County Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Harlow Council, Hart District Council, Herefordshire City Council, Highland, Horsham District Council, Huntingdonshire District Council, iTouchVision, Joint Waste Solutions, Kirklees Council, Leicester City Council, Lewes District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Bexley, London Borough of Bromley, London Borough of Camden, London Borough of Lewisham, London Borough of Merton, Maidstone Borough Council, Maldon District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Somerset Council, North Yorkshire Council - Hambleton, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City Council, Somerset Council, Somerset County Council, Somerset West & Taunton District Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Holland District Council, South Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Surrey Heath Borough Council, Swindon Borough Council, Tameside Metropolitan Borough Council, Telford and Wrekin Council, Test Valley Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Warrington Borough Council, Warwick District Council, Waverley Borough Council, Wealden District Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Wyre Forest District Council | | United States of America | Albuquerque, New Mexico, USA, City of Bloomington, City of Cambridge, City of Gastonia, NC, City of Georgetown, TX, City of Oklahoma City, City of Pittsburgh, Louisville, Kentucky, USA, Newark, Delaware, USA, Olympia, Washington, USA, ReCollect, Recycle Coach, Republic Services, Seattle Public Utilities, Tucson, Arizona, USA | diff --git a/tests/bandit.yaml b/tests/bandit.yaml index 50adb7744..a2394e171 100644 --- a/tests/bandit.yaml +++ b/tests/bandit.yaml @@ -12,6 +12,6 @@ tests: - B318 - B319 - B320 -# - B325 + #- B325 - B602 - B604 From 491a309cff961438613375f60ba4a3b3652774bc Mon Sep 17 00:00:00 2001 From: TMShader Date: Sun, 22 Oct 2023 15:27:06 +0200 Subject: [PATCH 3/4] add source eth_erd_hu (#1344) --- README.md | 1 + .../source/eth_erd_hu.py | 120 ++++++++++++++++++ doc/source/eth_erd_hu.md | 41 ++++++ info.md | 2 +- 4 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py create mode 100644 doc/source/eth_erd_hu.md diff --git a/README.md b/README.md index ed0eca9bd..1a8e7dfdd 100644 --- a/README.md +++ b/README.md @@ -798,6 +798,7 @@ Waste collection schedules in the following formats and countries are supported. - [FKF Budapest](/doc/source/fkf_bp_hu.md) / fkf.hu - [FKF Budaörs](/doc/source/fkf_bo_hu.md) / fkf.hu +- [ÉTH (Érd, Diósd, Nagytarcsa, Sóskút, Tárnok)](/doc/source/eth_erd_hu.md) / eth-erd.hu
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py new file mode 100644 index 000000000..18ea94b17 --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py @@ -0,0 +1,120 @@ +import json +import requests +import datetime + +from bs4 import BeautifulSoup +from waste_collection_schedule import Collection + +TITLE = "ÉTH (Érd, Diósd, Nagytarcsa, Sóskút, Tárnok)" +DESCRIPTION = "Source script for www.eth-erd.hu" +URL = "https://www.eth-erd.hu" +COUNTRY = "hu" +TEST_CASES = { + "Test_1": { + "city": "Diósd", + "street": "Diófasor", + "house_number": 10 + }, + "Test_2": { + "city": "Érd", + "street": "Hordó", + "house_number": 3 + }, + "Test_3": { + "city": "Sóskút" + } +} + +API_URL = "https://www.eth-erd.hu/trashcalendarget" + +ICON_MAP = { + "Kommunális": "mdi:trash-can", + "Szelektív": "mdi:recycle", + "Zöldhulladék": "mdi:leaf", + "Papír": "mdi:newspaper", + "Fenyőfa": "mdi:pine-tree", + "Üveg": "mdi:glass-fragile", +} + +NAME_MAP = { + "Kommunális": "Communal", + "Szelektív": "Selective", + "Zöldhulladék": "Green", + "Papír": "Paper", + "Fenyőfa": "Pine Tree", + "Üveg": "Glass", +} + +CITY_MAP = { + "diósd": 1, + "érd": 2, + "nagytarcsa": 822, + "sóskút": 3, + "tárnok": 4, +} + + +class Source: + def __init__(self, city: str, street: str = "", house_number: int = 1) -> None: + self._city = city + self._street = street + self._house_number = house_number + + def fetch(self): + session = requests.Session() + + city_id = CITY_MAP.get(self._city.lower()) + if city_id == None: raise Exception("City not found") + has_streets = city_id != CITY_MAP["sóskút"] + + if has_streets: + r = session.post( + API_URL + "streets", + data={ + "sid": city_id + }, + headers={ + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + "X-Requested-With": "XMLHttpRequest", + } + ) + r.raise_for_status() + streets = json.loads(r.text)["results"] + available_streets = [item["text"] for item in streets] + try: street_id = [item for item in streets if item.get('text') == self._street][0]["id"] + except IndexError: raise Exception("Street not found, available streets: " + ", ".join(available_streets)) + + r = session.post( + API_URL, + data={ + "wctown": city_id, + "wcstreet": street_id, + "wchousenumber": self._house_number, + } if has_streets else { + "wctown": city_id, + }, + headers={ + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + "X-Requested-With": "XMLHttpRequest", + } + ) + r.raise_for_status() + result: dict = json.loads(r.text) + + entries = [] + + for trash_type_id in result["types"]: + trash_type = result["types"][trash_type_id] + trash_icon = ICON_MAP[trash_type["name"]] + trash_name = NAME_MAP[trash_type["name"]] + + for element in result["routelist"][trash_type_id]: + entries.append( + Collection( + date = datetime.datetime.strptime(element, "%Y-%m-%d").date(), + t = trash_name, + icon = trash_icon, + ) + ) + + return entries diff --git a/doc/source/eth_erd_hu.md b/doc/source/eth_erd_hu.md new file mode 100644 index 000000000..4e46248d5 --- /dev/null +++ b/doc/source/eth_erd_hu.md @@ -0,0 +1,41 @@ +# ÉTH (Érd, Diósd, Nagytarcsa, Sóskút, Tárnok) + +Support for schedules provided by [ÉTH](https://www.eth-erd.hu/hulladeknaptar), serving Diósd, Érd, Nagytarcsa, Sóskút, Tárnok, HU. + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: eth_erd_hu + args: + city: CITY_NAME + street: FULL_STREET_NAME + house_number: HOUSE_NUMBER +``` + +### Configuration Variables + +**CITY** +*(string) (required)* + +**STREET** +*(string) (required)* +without "utca", "út", etc. +not required in Sóskút + +**HOUSE_NUMBER** +*(number) (required)* +not required in Sóskút + +## Example + +```yaml +waste_collection_schedule: + sources: + - name: eth_erd_hu + args: + city: Diósd + street: Diófasor + house_number: 10 +``` \ No newline at end of file diff --git a/info.md b/info.md index 004aae6e9..34bdc2599 100644 --- a/info.md +++ b/info.md @@ -23,7 +23,7 @@ Waste collection schedules from service provider web sites are updated daily, de | Denmark | Renosyd | | France | Mairie de Mamirolle | | Germany | Abfall App, Abfall Stuttgart, Abfall-Wirtschafts-Verband Nordschwaben, Abfall.IO / AbfallPlus, Abfallbehandlungsgesellschaft Havelland mbH (abh), Abfallbewirtschaftung Ostalbkreis, Abfallentsorgung Kreis Kassel, Abfallkalender Offenbach am Main, Abfallkalender Würzburg, AbfallNavi (RegioIT.de), Abfalltermine Forchheim, Abfallwirtschaft Alb-Donau-Kreis, Abfallwirtschaft Altkreis Göttingen, Abfallwirtschaft Altkreis Osterode am Harz, Abfallwirtschaft Enzkreis, Abfallwirtschaft Freiburg, Abfallwirtschaft Germersheim, Abfallwirtschaft Isar-Inn, Abfallwirtschaft Lahn-Dill-Kreises, Abfallwirtschaft Landkreis Böblingen, Abfallwirtschaft Landkreis Freudenstadt, Abfallwirtschaft Landkreis Harburg, Abfallwirtschaft Landkreis Haßberg, Abfallwirtschaft Landkreis Kitzingen, Abfallwirtschaft Landkreis Landsberg am Lech, Abfallwirtschaft Landkreis Wolfenbüttel, Abfallwirtschaft Neckar-Odenwald-Kreis, Abfallwirtschaft Nürnberger Land, Abfallwirtschaft Ortenaukreis, Abfallwirtschaft Pforzheim, Abfallwirtschaft Potsdam-Mittelmark (APM), Abfallwirtschaft Rems-Murr, Abfallwirtschaft Rendsburg, Abfallwirtschaft Rheingau-Taunus-Kreis, Abfallwirtschaft Stadt Fürth, Abfallwirtschaft Stadt Nürnberg, Abfallwirtschaft Stadt Schweinfurt, Abfallwirtschaft Südholstein, Abfallwirtschaft Werra-Meißner-Kreis, Abfallwirtschaft Zollernalbkreis, Abfallwirtschafts-Zweckverband des Landkreises Hersfeld-Rotenburg, Abfallwirtschaftsbetrieb Bergisch Gladbach, Abfallwirtschaftsbetrieb Emsland, Abfallwirtschaftsbetrieb Esslingen, Abfallwirtschaftsbetrieb Ilm-Kreis, Abfallwirtschaftsbetrieb Kiel (ABK), Abfallwirtschaftsbetrieb Landkreis Ahrweiler, Abfallwirtschaftsbetrieb Landkreis Altenkirchen, Abfallwirtschaftsbetrieb Landkreis Augsburg, Abfallwirtschaftsbetrieb Landkreis Aurich, Abfallwirtschaftsbetrieb Landkreis Karlsruhe, Abfallwirtschaftsbetrieb LK Mainz-Bingen, Abfallwirtschaftsbetrieb München, Abfallwirtschaftsbetriebe Münster, Abfallwirtschaftsgesellschaft Landkreis Schaumburg, Abfallwirtschaftsverband Kreis Groß-Gerau, Abfallwirtschaftsverbandes Lippe, Abfallwirtschaftszweckverband Wartburgkreis (AZV), Abfallzweckverband Rhein-Mosel-Eifel (Landkreis Mayen-Koblenz), AHE Ennepe-Ruhr-Kreis, ALBA Berlin, ALBA Braunschweig, ALF Lahn-Fulda, Altmarkkreis Salzwedel, Altötting (LK), Apps by Abfall+, ART Trier, Aschaffenburg (MyMuell App), ASG Wesel, ASO Abfall-Service Osterholz, ASR Stadt Chemnitz, ATHOS GmbH, Augsburg, Aurich (MKW), AVL - Abfallverwertungsgesellschaft des Landkreises Ludwigsburg mbH, AWA Entsorgungs GmbH, AWB Abfallwirtschaft Vechta, AWB Bad Kreuznach, AWB Köln, AWB Landkreis Bad Dürkheim, AWB Landkreis Fürstenfeldbruck, AWB Landkreis Göppingen, AWB Oldenburg, AWB Westerwaldkreis, AWG Donau-Wald, AWG Kreis Warendorf, AWIDO Online, AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH, AWISTA Düsseldorf, Awista Starnberg, Bad Arolsen (MyMuell App), Bad Homburg vdH, Bad Kissingen, Barnim, Bau & Service Oberursel, Bergischer Abfallwirtschaftverbund, Berlin, Berlin Recycling, Berliner Stadtreinigungsbetriebe, Beverungen (MyMuell App), Bielefeld, Blaue Tonne - Schlaue Tonne, Bogenschütz Entsorgung, Bonn, Braunschweig, Bremer Stadtreinigung, Burgenland (Landkreis), Bürgerportal, C-Trace, Cham Landkreis, Chemnitz (ASR), Chiemgau Recycling - Landkreis Rosenheim, City of Karlsruhe, CM City Media - Müllkalender, Darmstadt (MyMuell App), Darmstadt-Dieburg (ZAW), Dillingen Saar, Dinslaken, Drekopf, Duisburg, EAD Darmstadt, EDG Entsorgung Dortmund, EGN Abfallkalender, EGST Steinfurt, EGW Westmünsterland, Eichsfeldwerke GmbH, Eigenbetrieb Kommunalwirtschaftliche Dienstleistungen Suhl, Entsorgungs- und Wirtschaftsbetrieb Landau in der Pfalz, Entsorgungsbetrieb Märkisch-Oderland, Entsorgungsbetrieb Stadt Mainz, Entsorgungsbetriebe Essen, Entsorgungsgesellschaft Görlitz-Löbau-Zittau, Esens (MyMuell App), Essen, EVA Abfallentsorgung, EVS Entsorgungsverband Saar, FES Frankfurter Entsorgungs- und Service GmbH, Flensburg (MyMuell App), Frankfurt (Oder), Freiburg im Breisgau, Gelsendienste Gelsenkirchen, Gemeinde Aschheim, Gemeinde Blankenheim, Gemeinde Bühlerzell, Gemeinde Deggenhausertal, Gemeinde Kalletal, Gemeinde Kappelrodeck, Gemeinde Lindlar, Gemeinde Mittelbiberach, Gemeinde Oberstadion, Gemeinde Roetgen, Gemeinde Schutterwald, Gemeinde Senden (Westfalen), Gemeinde Unterhaching, Großkrotzenburg (MyMuell App), Göttinger Entsorgungsbetriebe, Gütersloh, Hagen, Hainburg (MyMuell App), Hallesche Wasser und Stadtwirtschaft GmbH, Halver, Hattersheim am Main, hausmüll.info, Havelland, Heilbronn Entsorgungsbetriebe, Hohenlohekreis, Hohenlohekreis, Holtgast (MyMuell App), Ilm-Kreis, Ingolstadt, Jumomind, KAEV Niederlausitz, Kamp-Lintfort (MyMuell App), Kirchdorf (MyMuell App), Kommunalservice Landkreis Börde AöR, Kreis Augsburg, Kreis Bad Kissingen, Kreis Bautzen, Kreis Bayreuth, Kreis Bergstraße, Kreis Breisgau-Hochschwarzwald, Kreis Calw, Kreis Cloppenburg, Kreis Coesfeld, Kreis Cuxhaven, Kreis Diepholz, Kreis Emmendingen, Kreis Emsland, Kreis Freudenstadt, Kreis Fürth, Kreis Garmisch-Partenkirchen, Kreis Göppingen, Kreis Heilbronn, Kreis Heinsberg, Kreis Karlsruhe, Kreis Kitzingen, Kreis Landsberg am Lech, Kreis Landshut, Kreis Limburg-Weilburg, Kreis Ludwigsburg, Kreis Lörrach, Kreis Mayen-Koblenz, Kreis Miesbach, Kreis Miltenberg, Kreis Märkisch-Oderland, Kreis Neustadt/Aisch-Bad Windsheim, Kreis Neuwied, Kreis Nienburg / Weser, Kreis Nordfriesland, Kreis Ostallgäu, Kreis Osterholz, Kreis Pinneberg, Kreis Rastatt, Kreis Ravensburg, Kreis Reutlingen, Kreis Rotenburg (Wümme), Kreis Schaumburg, Kreis Sigmaringen, Kreis Starnberg, Kreis Steinfurt, Kreis Südwestpfalz, Kreis Traunstein, Kreis Trier-Saarburg, Kreis Uelzen, Kreis Vechta, Kreis Viersen, Kreis Vorpommern-Rügen, Kreis Weißenburg-Gunzenhausen, Kreis Wesermarsch, Kreis Würzburg, Kreisstadt Dietzenbach, Kreisstadt Friedberg, Kreisstadt Groß-Gerau, Kreisstadt St. Wendel, Kreiswerke Schmalkalden-Meiningen GmbH, Kreiswirtschaftsbetriebe Goslar, Kronberg im Taunus, KV Cochem-Zell, KWU Entsorgung Landkreis Oder-Spree, Landkreis Ansbach, Landkreis Aschaffenburg, Landkreis Aschaffenburg (MyMuell App), Landkreis Bayreuth, Landkreis Berchtesgadener Land, Landkreis Biberach (MyMuell App), Landkreis Böblingen, Landkreis Böblingen, Landkreis Börde AöR (KsB), Landkreis Calw, Landkreis Coburg, Landkreis Eichstätt (MyMuell App), Landkreis Erding, Landkreis Erlangen-Höchstadt, Landkreis Esslingen, Landkreis Friesland (MyMuell App), Landkreis Fulda, Landkreis Gießen, Landkreis Gotha, Landkreis Görlitz, Landkreis Günzburg, Landkreis Hameln-Pyrmont, Landkreis Heilbronn, Landkreis Kelheim, Landkreis Kronach, Landkreis Kulmbach, Landkreis Kusel, Landkreis Leer (MyMuell App), Landkreis Leipzig, Landkreis Limburg-Weilburg, Landkreis Lüchow-Dannenberg, Landkreis Main-Spessart, Landkreis Mettmann (MyMuell App), Landkreis Mühldorf a. Inn, Landkreis Nordwestmecklenburg, Landkreis Northeim (unofficial), Landkreis Ostallgäu, Landkreis Paderborn (MyMuell App), Landkreis Ravensburg, Landkreis Rhön Grabfeld, Landkreis Rosenheim, Landkreis Rotenburg (Wümme), Landkreis Roth, Landkreis Roth, Landkreis Schweinfurt, Landkreis Schwäbisch Hall, Landkreis Schwäbisch Hall, Landkreis Sigmaringen, Landkreis soest, Landkreis Stade, Landkreis Stendal, Landkreis Südliche Weinstraße, Landkreis Tirschenreuth, Landkreis Tübingen, Landkreis Weißenburg-Gunzenhausen, Landkreis Wittmund, Landkreis Wittmund (MyMuell App), Landkreis Wittmund (MyMuell App), Landkreis Wunsiedel im Fichtelgebirge, Landkreisbetriebe Neuburg-Schrobenhausen, Landratsamt Aichach-Friedberg, Landratsamt Bodenseekreis, Landratsamt Dachau, Landratsamt Main-Tauber-Kreis, Landratsamt Traunstein, Landratsamt Unterallgäu, Landshut, Lebacher Abfallzweckverband (LAZ), Leverkusen, Ludwigshafen, Ludwigshafen am Rhein, Lübbecke (Jumomind), Lübeck Entsorgungsbetriebe, mags Mönchengladbacher Abfall-, Grün- und Straßenbetriebe AöR, Main-Kinzig-Kreis (MyMuell App), Mannheim, Mechernich und Kommunen, Mein-Abfallkalender.de, Metzingen, Minden, MZV Biedenkopf, Mühlheim am Main (MyMuell App), Müllabfuhr Deutschland, MüllALARM / Schönmackers, Müllmax, München Landkreis, Neckar-Odenwald-Kreis, Nenndorf (MyMuell App), Neumünster (MyMuell App), Neunkirchen Siegerland, Neustadt a.d. Waldnaab, Neustadt an der Weinstraße, Nordsachsen, Oberhavel, Oberhavel AWU, Oldenburg, Ortenaukreis, Ostprignitz-Ruppin, Potsdam, Prignitz, Prignitz, Pullach im Isartal, Recklinghausen, RegioEntsorgung AöR, RegioEntsorgung Städteregion Aachen, Rhein-Hunsrück (Jumomind), Rhein-Hunsrück Entsorgung (RHE), Rhein-Neckar-Kreis, Rhein-Neckar-Kreis, Rhein-Pfalz-Kreis, Rottweil, Rottweil, RSAG Rhein-Sieg-Kreis, Salzgitter (MyMuell App), Salzlandkreis, Schmitten im Taunus (MyMuell App), Schwarze Elster, Schwarzwald-Baar-Kreis, Schöneck (MyMuell App), Schönmackers, Sector 27 - Datteln, Marl, Oer-Erkenschwick, Seligenstadt (MyMuell App), Stadt Aachen, Stadt Arnsberg, Stadt Bayreuth, Stadt Cottbus, Stadt Darmstadt, Stadt Detmold, Stadt Dorsten, Stadt Ehingen, Stadt Emden, Stadt Emmendingen, Stadt Fulda, Stadt Haltern am See, Stadt Hamm, Stadt Hanau, Stadt Kaufbeuren, Stadt Koblenz, Stadt Kraichtal, Stadt Landshut, Stadt Maintal, Stadt Memmingen, Stadt Messstetten, Stadt Norderstedt, Stadt Osnabrück, Stadt Overath, Stadt Regensburg, Stadt Solingen, Stadt Unterschleißheim, Stadtbildpflege Kaiserslautern, Stadtentsorgung Rostock, Stadtreinigung Dresden, Stadtreinigung Hamburg, Stadtreinigung Leipzig, Stadtreinigung Leipzig, StadtService Brühl, Stadtwerke Erfurt, SWE, STL Lüdenscheid, Städteservice Raunheim Rüsselsheim, Südbrandenburgischer Abfallzweckverband, TBR Remscheid, Technischer Betriebsdienst Reutlingen, Tuttlingen, Tuttlingen, Tübingen, Uckermark, Ulm (MyMuell App), USB Bochum, Usingen (MyMuell App), VIVO Landkreis Miesbach, Volkmarsen (MyMuell App), Vöhringen (MyMuell App), Waldshut, Waldshut, WBO Wirtschaftsbetriebe Oberhausen, Wegberg (MyMuell App), Wermelskirchen, Westerholt (MyMuell App), Westerwaldkreis, WGV Recycling GmbH, Wilhelmshaven (MyMuell App), Wolfsburger Abfallwirtschaft und Straßenreinigung, WZV Kreis Segeberg, Würzburg, ZAH Hildesheim, ZAK Kempten, ZAW-SR Straubing, ZEW Zweckverband Entsorgungsregion West, ZfA Iserlohn, Zollernalbkreis, Zweckverband Abfallwirtschaft Kreis Bergstraße, Zweckverband Abfallwirtschaft Oberes Elbtal, Zweckverband Abfallwirtschaft Region Hannover, Zweckverband Abfallwirtschaft Region Trier (A.R.T.), Zweckverband Abfallwirtschaft Saale-Orla, Zweckverband Abfallwirtschaft Schwalm-Eder-Kreis, Zweckverband Abfallwirtschaft Südwestsachsen (ZAS), Zweckverband München-Südost | -| Hungary | FKF Budapest, FKF Budaörs | +| Hungary | FKF Budapest, FKF Budaörs, ÉTH (Érd, Diósd, Nagytarcsa, Sóskút, Tárnok) | | Lithuania | Kauno švara | | Luxembourg | Esch-sur-Alzette | | Netherlands | ACV Group, Alpen an den Rijn, Area Afval, Avalex, Avri, Bar Afvalbeheer, Circulus, Cyclus NV, Dar, Den Haag, GAD, Gemeente Almere, Gemeente Berkelland, Gemeente Cranendonck, Gemeente Hellendoorn, Gemeente Lingewaard, Gemeente Meppel, Gemeente Middelburg + Vlissingen, Gemeente Peel en Maas, Gemeente Schouwen-Duiveland, Gemeente Sudwest-Fryslan, Gemeente Venray, Gemeente Voorschoten, Gemeente Waalre, Gemeente Westland, HVC Groep, Meerlanden, Mijn Blink, PreZero, Purmerend, RAD BV, Reinis, Spaarnelanden, Twente Milieu, Waardlanden, Ximmio, ZRD | From 13c5679727cb19affa565ca036a3c7dbbfe466e9 Mon Sep 17 00:00:00 2001 From: 5ila5 <38183212+5ila5@users.noreply.github.com> Date: Sun, 22 Oct 2023 15:33:30 +0200 Subject: [PATCH 4/4] reformatting eth_erd_hu (#1349) Co-authored-by: 5ila5 <5ila5@users.noreply.github.com> --- .../source/eth_erd_hu.py | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py index 18ea94b17..3b07e51e8 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/eth_erd_hu.py @@ -1,28 +1,17 @@ -import json -import requests import datetime +import json -from bs4 import BeautifulSoup -from waste_collection_schedule import Collection +import requests +from waste_collection_schedule import Collection # type: ignore[attr-defined] TITLE = "ÉTH (Érd, Diósd, Nagytarcsa, Sóskút, Tárnok)" DESCRIPTION = "Source script for www.eth-erd.hu" URL = "https://www.eth-erd.hu" COUNTRY = "hu" TEST_CASES = { - "Test_1": { - "city": "Diósd", - "street": "Diófasor", - "house_number": 10 - }, - "Test_2": { - "city": "Érd", - "street": "Hordó", - "house_number": 3 - }, - "Test_3": { - "city": "Sóskút" - } + "Test_1": {"city": "Diósd", "street": "Diófasor", "house_number": 10}, + "Test_2": {"city": "Érd", "street": "Hordó", "house_number": 3}, + "Test_3": {"city": "Sóskút"}, } API_URL = "https://www.eth-erd.hu/trashcalendarget" @@ -64,25 +53,31 @@ def fetch(self): session = requests.Session() city_id = CITY_MAP.get(self._city.lower()) - if city_id == None: raise Exception("City not found") + if city_id is None: + raise Exception("City not found") has_streets = city_id != CITY_MAP["sóskút"] if has_streets: r = session.post( API_URL + "streets", - data={ - "sid": city_id - }, + data={"sid": city_id}, headers={ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "X-Requested-With": "XMLHttpRequest", - } + }, ) r.raise_for_status() streets = json.loads(r.text)["results"] available_streets = [item["text"] for item in streets] - try: street_id = [item for item in streets if item.get('text') == self._street][0]["id"] - except IndexError: raise Exception("Street not found, available streets: " + ", ".join(available_streets)) + try: + street_id = [ + item for item in streets if item.get("text") == self._street + ][0]["id"] + except IndexError: + raise Exception( + "Street not found, available streets: " + + ", ".join(available_streets) + ) r = session.post( API_URL, @@ -90,13 +85,15 @@ def fetch(self): "wctown": city_id, "wcstreet": street_id, "wchousenumber": self._house_number, - } if has_streets else { + } + if has_streets + else { "wctown": city_id, }, headers={ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "X-Requested-With": "XMLHttpRequest", - } + }, ) r.raise_for_status() result: dict = json.loads(r.text) @@ -111,9 +108,9 @@ def fetch(self): for element in result["routelist"][trash_type_id]: entries.append( Collection( - date = datetime.datetime.strptime(element, "%Y-%m-%d").date(), - t = trash_name, - icon = trash_icon, + date=datetime.datetime.strptime(element, "%Y-%m-%d").date(), + t=trash_name, + icon=trash_icon, ) )