From c3b097e16fd86bb17609c8af9545fb41c3419b8a Mon Sep 17 00:00:00 2001 From: dt215git <86194065+dt215git@users.noreply.github.com> Date: Fri, 2 Jun 2023 12:23:20 +0100 Subject: [PATCH] New Source: East Riding, UK (#1016) * initial commit * test cases added * typos corrected * eastriding .md added * update_docu_link run --- README.md | 1 + .../source/eastriding_gov_uk.py | 57 +++++++++++++++++++ doc/source/eastriding_gov_uk.md | 39 +++++++++++++ info.md | 4 +- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 custom_components/waste_collection_schedule/waste_collection_schedule/source/eastriding_gov_uk.py create mode 100644 doc/source/eastriding_gov_uk.md diff --git a/README.md b/README.md index 29b62ecd..f78fa8a0 100644 --- a/README.md +++ b/README.md @@ -723,6 +723,7 @@ Waste collection schedules in the following formats and countries are supported. - [East Cambridgeshire District Council](/doc/source/eastcambs_gov_uk.md) / eastcambs.gov.uk - [East Herts Council](/doc/source/eastherts_gov_uk.md) / eastherts.gov.uk - [East Northamptonshire and Wellingborough](/doc/source/east_northamptonshire_gov_uk.md) / east-northamptonshire.gov.uk +- [East Riding of Yorkshire Council](/doc/source/eastriding_gov_uk.md) / eastriding.gov.uk - [Eastbourne Borough Council](/doc/source/environmentfirst_co_uk.md) / lewes-eastbourne.gov.uk - [Elmbridge Borough Council](/doc/source/elmbridge_gov_uk.md) / elmbridge.gov.uk - [Environment First](/doc/source/environmentfirst_co_uk.md) / environmentfirst.co.uk diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/eastriding_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/eastriding_gov_uk.py new file mode 100644 index 00000000..6fd830a9 --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/eastriding_gov_uk.py @@ -0,0 +1,57 @@ +import json +import re +import requests + +from datetime import datetime +from waste_collection_schedule import Collection # type: ignore[attr-defined] + +TITLE = "East Riding of Yorkshire Council" +DESCRIPTION = "Source for East Riding of Yorkshire Council, UK." +URL = "https://eastriding.gov.uk" +TEST_CASES = { + "Test_001": {"uprn": "010002364380", "postcode": "DN14 6BJ"}, + "Test_002": {"uprn": "100050020969", "postcode": "YO16 4HF"}, + "Test_003": {"uprn": "100050099708", "postcode": "HU12 0PE"}, + "Test_004": {"uprn": 10002364380, "postcode": " DN146BJ "} +} +ICON_MAP = { + "BlueDate": "mdi:recycle", + "GreenDate": "mdi:trash-can", + "BrownDate": "mdi:leaf", +} +REGEX = { + "API_KEY": r"APIKey=(.+)&L", + "LICENSEE": r"Licensee=(.+)&", +} + +class Source: + def __init__(self, uprn, postcode): + self._uprn = str(uprn).zfill(12) + self._postcode = str(postcode).strip().replace(" ", "") + + def fetch(self): + s = requests.Session() + + # get api_key and licensee + r1 = s.get("https://www.eastriding.gov.uk/environment/bins-rubbish-recycling/bins-and-collections/bin-collection-dates/") + api_key = re.findall(REGEX["API_KEY"], r1.text)[0] + licensee = re.findall(REGEX["LICENSEE"], r1.text)[0] + + # retrieve schedule + r2 = s.get(f"https://wasterecyclingapi.eastriding.gov.uk/api/RecyclingData/CollectionsData?APIKey={api_key}&Licensee={licensee}&Postcode={self._postcode}") + r2_json = json.loads(r2.text)["dataReturned"] + + entries = [] + + for item in r2_json: + if item["UPRN"] == self._uprn: + for key in ICON_MAP: + entries.append( + Collection( + date=datetime.strptime(item[key], "%Y-%m-%dT00:00:00").date(), + t=key.replace("Date", " Bin"), # api doesn't return a waste type, so make one up + icon=ICON_MAP.get(key), + ) + ) + + return entries diff --git a/doc/source/eastriding_gov_uk.md b/doc/source/eastriding_gov_uk.md new file mode 100644 index 00000000..c74e457f --- /dev/null +++ b/doc/source/eastriding_gov_uk.md @@ -0,0 +1,39 @@ +# East Riding of Yorkshire Council + +Support for schedules provided by [East Riding of Yorkshire Council](https://eastriding.gov.uk), UK. + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: eastriding_gov_uk + args: + postcode: POSTCODE + uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER +``` + +### Configuration Variables + +**postcode**
+*(string) (required)* + +**uprn**
+*(string) (required)* + + +## Example +```yaml +waste_collection_schedule: + sources: + - name: eastriding_gov_uk + args: + postcode: "DN14 6BJ" + uprn: "010002364380" +``` + +#### How to find your `UPRN` +You can discover your Unique Property Reference Number (UPRN) is by going to https://www.findmyaddress.co.uk/ and entering in your address details. + + + diff --git a/info.md b/info.md index 0f5efdb3..94c62c6e 100644 --- a/info.md +++ b/info.md @@ -16,7 +16,7 @@ Waste collection schedules from service provider web sites are updated daily, de |--|--| | Generic | ICS / iCal files | | Static | User-defined dates or repeating date patterns | -| Australia | Banyule City Council, Belmont City Council, Brisbane City Council, Campbelltown City Council (NSW), Cardinia Shire Council, City of Canada Bay Council, City of Kingston, City of Onkaparinga Council, Cumberland Council, Gold Coast City Council, Hume City Council, Inner West Council (NSW), Ipswich City Council, Ku-ring-gai Council, Lake Macquarie City Council, Macedon Ranges Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Nillumbik Shire Council, North Adelaide Waste Management Authority, Port Adelaide Enfield (SA), RecycleSmart, Stonnington City Council, The Hills Shire Council, Sydney, Unley City Council (SA), Whittlesea City Council, Wollongong City Council, Wyndham City Council, Melbourne | +| Australia | Banyule City Council, Belmont City Council, Brisbane City Council, Campbelltown City Council (NSW), Cardinia Shire Council, City of Canada Bay Council, City of Kingston, City of Onkaparinga Council, Cumberland Council (NSW), Gold Coast City Council, Hume City Council, Inner West Council (NSW), Ipswich City Council, Ku-ring-gai Council, Lake Macquarie City Council, Macedon Ranges Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Nillumbik Shire Council, North Adelaide Waste Management Authority, Port Adelaide Enfield, South Australia, RecycleSmart, Stonnington City Council, The Hills Shire Council, Sydney, Unley City Council (SA), Whittlesea City Council, Wollongong City Council, Wyndham City Council, Melbourne | | Austria | Andau, Apetlon, App CITIES, Bad Blumau, Bad Gleichenberg, Bad Loipersdorf, Bad Radkersburg, Bad Tatzmannsdorf, Bildein, Breitenbrunn am Neusiedler See, Breitenstein, Bruckneudorf, Buch - St. Magdalena, Burgau, Burgenländischer Müllverband, Dechantskirchen, Deutsch Goritz, Deutsch Jahrndorf, Deutsch Kaltenbrunn, Deutschkreutz, Dobl-Zwaring, Draßmarkt, Eberau, Eberndorf, Eberstein, Edelsbach bei Feldbach, Eggersdorf bei Graz, Eisenstadt, Fehring, Feistritz ob Bleiburg, Feldbach, Frankenau-Unterpullendorf, Frauenkirchen, Freistadt, Friedberg, Fürstenfeld, Gabersdorf, Gattendorf, Gols, Grafendorf bei Hartberg, Grafenstein, Gratkorn, Großwarasdorf, Großwilfersdorf, Gutenberg-Stenzengreith, Güssing, Hartberg, Heiligenkreuz am Waasen, Hofstätten an der Raab, Horitschon, Hornstein, Hüttenberg, Ilz, infeo, Innsbrucker Kommunalbetriebe, Jabing, Jagerberg, Kaindorf, Kaisersdorf, Kalsdorf bei Graz, Kapfenstein, Kirchberg an der Raab, Kleinmürbisch, Klingenbach, Klöch, Kohfidisch, Korneuburg, Laa an der Thaya, Leithaprodersdorf, Lieboch, Litzelsdorf, Loipersbach im Burgenland, Mariasdorf, Markt Hartmannsdorf, Markt Neuhodis, Marz, Mattersburg, Melk, Mettersdorf am Saßbach, Mischendorf, Mistelbach, Mitterdorf an der Raab, Mureck, Mörbisch am See, Neudorf bei Parndorf, Neufeld an der Leitha, Neusiedl am See, Nickelsdorf, Oberpullendorf, Oberwart, Oslip, Ottendorf an der Rittschein, Paldau, Pamhagen, Parndorf, Peggau, Pernegg an der Mur, Pilgersdorf, Pinggau, Pinkafeld, Podersdorf am See, Poggersdorf, Potzneusiedl, Poysdorf, Pöchlarn, Radmer, Ragnitz, Raiding, Rudersdorf, Rust, Saalfelden am Steinernen Meer, Sankt Oswald bei Plankenwarth, Schäffern, Schützen am Gebirge, Seiersberg-Pirka, Sigleß, Sinabelkirchen, St. Andrä, St. Anna am Aigen, St. Johann in der Haide, St. Lorenzen am Wechsel, St. Margarethen an der Raab, St. Margarethen im Burgenland, St. Peter - Freienstein, St. Peter am Ottersbach, St. Ruprecht an der Raab, St. Veit in der Südsteiermark, Stadt Salzburg, Stadtservice Korneuburg, Stegersbach, Steinbrunn, Steuerberg, Stinatz, Stiwoll, Stockerau, Söchau, Thal, Tieschen, Tulln an der Donau, Umweltprofis, Unterfrauenhaid, Unterkohlstätten, Unterlamm, Vasoldsberg, Vordernberg, Völkermarkt, Weiz, Werfenweng, Wies, Wiesen, Wiesfleck, Wimpassing an der Leitha, Winden am See, Wolfsberg, Wolkersdorf im Weinviertel, WSZ Moosburg, Zagersdorf, Zillingtal, Zurndorf, Übelbach | | Belgium | Hygea, Limburg.net, Recycle! | | Canada | City of Toronto | @@ -30,7 +30,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, Amber Valley Borough Council, Ashfield District Council, Basildon Council, Basingstoke and Deane Borough Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Croydon Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, 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 Lewisham, London Borough of Merton, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough 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, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Reigate & Banstead Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin 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, Waverley Borough Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wirral Council, Wyre Forest District Council | +| United Kingdom | Aberdeenshire Council, Amber Valley Borough Council, Ashfield District Council, Basildon Council, Basingstoke and Deane Borough Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Croydon Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, 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 Lewisham, London Borough of Merton, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough 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, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Reigate & Banstead Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin 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, Waverley Borough Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wirral Council, Wyre Forest District Council | | United States of America | City of Oklahoma City, City of Pittsburgh, Republic Services, Seattle Public Utilities |