From a85c8199d46ce0eb82ab9bfdfd502d786e8c115d Mon Sep 17 00:00:00 2001 From: 5ila5 <5ila5@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:52:18 +0200 Subject: [PATCH] add Dover District Council --- README.md | 1 + .../waste_collection_schedule/sources.json | 5 ++ .../source/dover_gov_uk.py | 68 +++++++++++++++++++ doc/source/dover_gov_uk.md | 37 ++++++++++ info.md | 2 +- 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 custom_components/waste_collection_schedule/waste_collection_schedule/source/dover_gov_uk.py create mode 100644 doc/source/dover_gov_uk.md diff --git a/README.md b/README.md index 378aeee3..3cff31b2 100644 --- a/README.md +++ b/README.md @@ -1502,6 +1502,7 @@ If your service provider is not listed, feel free to open a [source request issu - [Denbighshire County Council](/doc/source/denbighshire_gov_uk.md) / denbighshire.gov.uk - [Deprecated: Buckinghamshire](/doc/source/chiltern_gov_uk.md) / chiltern.gov.uk - [Derby City Council](/doc/source/derby_gov_uk.md) / derby.gov.uk +- [Dover District Council](/doc/source/dover_gov_uk.md) / dover.gov.uk - [Dudley Metropolitan Borough Council](/doc/source/dudley_gov_uk.md) / dudley.gov.uk - [Durham County Council](/doc/source/durham_gov_uk.md) / durham.gov.uk - [East Ayrshire Council](/doc/source/east_ayrshire_gov_uk.md) / east-ayrshire.gov.uk diff --git a/custom_components/waste_collection_schedule/sources.json b/custom_components/waste_collection_schedule/sources.json index 2ced8bfa..51f59c30 100644 --- a/custom_components/waste_collection_schedule/sources.json +++ b/custom_components/waste_collection_schedule/sources.json @@ -8107,6 +8107,11 @@ "module": "derby_gov_uk", "default_params": {} }, + { + "title": "Dover District Council", + "module": "dover_gov_uk", + "default_params": {} + }, { "title": "Dudley Metropolitan Borough Council", "module": "dudley_gov_uk", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/dover_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/dover_gov_uk.py new file mode 100644 index 00000000..1c41821c --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/dover_gov_uk.py @@ -0,0 +1,68 @@ +from datetime import datetime + +import requests +from bs4 import BeautifulSoup +from waste_collection_schedule import Collection # type: ignore[attr-defined] + +TITLE = "Dover District Council" +DESCRIPTION = "Source for Dover District Council." +URL = "https://www.dover.gov.uk" +TEST_CASES = { + "200002423404": {"uprn": 200002423404}, + "100060905828": {"uprn": "100060905828"}, +} + + +ICON_MAP = { + "Garden Waste Collection": "mdi:leaf", + "Food Collection": "mdi:food-apple", + "Refuse Collection": "mdi:trash-can", + "Paper/Card Collection": "mdi:package-variant", + "Recycling Collection": "mdi:recycle", +} + + +API_URL = "https://collections.dover.gov.uk/" + + +class Source: + def __init__(self, uprn: str | int): + self._uprn: str | int = uprn + + def fetch(self) -> list[Collection]: + # copy of haringey_gov_uk.py just some minor changes + api_url = f"https://collections.dover.gov.uk/property/{self._uprn}" + response = requests.get(api_url) + + soup = BeautifulSoup(response.text, features="html.parser") + soup.prettify() + + entries = [] + + service_elements = soup.select(".service-wrapper") + + for service_element in service_elements: + service_name = service_element.select(".service-name")[0].text.strip() + + next_service_dates = service_element.select( + "td.next-service" + ) + service_element.select("td.last-service") + if len(next_service_dates) == 0: + continue + for next_service_date in next_service_dates: + next_service_date.span.extract() + + if next_service_date.text.strip().strip("-") == "": + continue + + entries.append( + Collection( + date=datetime.strptime( + next_service_date.text.strip(), "%d/%m/%Y" + ).date(), + t=service_name, + icon=ICON_MAP.get(service_name), + ) + ) + + return entries diff --git a/doc/source/dover_gov_uk.md b/doc/source/dover_gov_uk.md new file mode 100644 index 00000000..a6107227 --- /dev/null +++ b/doc/source/dover_gov_uk.md @@ -0,0 +1,37 @@ +# Dover District Council + +Support for schedules provided by [Dover District Council](https://www.dover.gov.uk), serving Dover, UK. + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: dover_gov_uk + args: + uprn: "UPRN" + +``` + +### Configuration Variables + +**uprn** +*(String | Integer) (required)* + +## Example + +```yaml +waste_collection_schedule: + sources: + - name: dover_gov_uk + args: + uprn: "200002423404" +``` + +## How to get the source argument + +You can find your UPRN when visiting the website and searching for your address. You can now see your UPRN in the address bar of your browser. e.g. `https://collections.dover.gov.uk/property/200002423404`, where `200002423404` is the UPRN. + +### Getting your UPRN with an external service + +An easy way to discover your Unique Property Reference Number (UPRN) is by going to and entering in your address details. diff --git a/info.md b/info.md index 109b5f23..97b75cc1 100644 --- a/info.md +++ b/info.md @@ -36,7 +36,7 @@ Waste collection schedules from service provider web sites are updated daily, de | Slovenia | Moji odpadki, Ljubljana | | Sweden | Affärsverken, Boden, Borås Energi och Miljö, EDPEvent - Multi Source, Gästrike Återvinnare, Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Luleå, Lund Waste Collection, Mölndal, Norrtalje Vatten & Avfall, North / Middle Bohuslän - Rambo AB, Region Gotland, Ronneby Miljöteknik, Roslagsvatten, Samverkan Återvinning Miljö (SÅM), Skellefteå, SRV Återvinning, SSAM (Deprecated), SSAM Södra Smalånds Avfall & Miljö, Sysav Sophämntning, Uppsala Vatten, Uppsala Vatten och Avfall AB (Deprecated), VA Syd Sophämntning, VIVAB Sophämtning, Västervik Miljö & Energi | | Switzerland | A-Region, Alchenstorf, Andwil, Appenzell, Berg, Bühler, Canton of Zürich, Eggersriet, Gais, Gaiserwald, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Münchenstein, Münsingen BE, Switzerland, Real Luzern, Real Luzern, Rehetobel, Rorschach, Rorschacherberg, Sammelkalender.ch, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Winterthur, Wittenbach, Wolfhalden, ZAKU Entsorgung, Zeba, ZKRI | -| United Kingdom | Aberdeenshire Council, Adur & Worthing Councils, Allerdale Borough Council, Amber Valley Borough Council, Anglesey, Antrim and Newtownabbey, Apps by imactivate, Ards and North Down Borough Council, Arun District Council, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Barnsley Metropolitan Borough Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, BCP Council, Bedford Borough Council, Binzone, Birmingham City Council, Blackburn with Darwen Borough Council, Blackpool Council, Borough Council of King's Lynn & West Norfolk, Borough of Broxbourne Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Brent Council, Bristol City Council, Broadland District Council, Bromsgrove City Council, Broxtowe Borough Council, Buckinghamshire: Former (Chiltern, South Bucks, Wycombe), Burnley Council, Bury Council, Cambridge City Council, Canterbury City Council, Cardiff Council, Central Bedfordshire Council, Charnwood, 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, Conwy County Borough Council, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Darlington Borough Council, Denbighshire County Council, Deprecated: Buckinghamshire, Derby City Council, Dudley Metropolitan Borough Council, Durham County Council, East Ayrshire Council, East Cambridgeshire District Council, East Devon District Council, East Herts Council, East Lothian, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Eastleigh Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Borough Council, FCC Environment, Fenland, Fenland District Council, Fife Council, Flintshire, Fylde Council, Gateshead Council, Gedling Borough Council (unofficial), Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Haringey Council, Harlow Council, Hart District Council, Herefordshire City Council, High Peak Borough Council, Highland, Horsham District Council, Hull City Council, Huntingdonshire District Council, iTouchVision, Itouchvision Source using the encrypted API, Joint Waste Solutions, Kirklees Council, Lancaster City Council, Leeds, Leicester City Council, Lewes District Council, Lichfield District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Barking and Dagenham, London Borough of Bexley, London Borough of Bromley, London Borough of Camden, London Borough of Harrow, London Borough of Hounslow, London Borough of Lewisham, London Borough of Merton, London Borough of Newham, Luton, Maidstone Borough Council, Maldon District Council, Malvern Hills, Malvern Hills District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Moray Council, Newark & Sherwood District Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, Newport City Council, North Ayrshire Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Northamptonshire council, North Somerset Council, North West Leicestershire District Council, North Yorkshire Council - Hambleton, North Yorkshire Council - Harrogate, North Yorkshire Council - Scarborough, North Yorkshire Council - Selby, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Renfrewshire Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City Council, Shropshire Council, Solihull 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 Kesteven District Council, South Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, St Albans City & District Council, Stafford Borough Council, Stevenage Borough Council, Stirling.gov.uk, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Stroud District Council, Surrey Heath Borough Council, Sutton Council, London, Swansea 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, Tunbridge Wells, UK Bin Collection Schedule (UKBCD) project, Uttlesford District Council, Vale of Glamorgan 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, West Northamptonshire council, West Oxfordshire District Council, West Suffolk Council, Westmorland & Furness Council, Barrow area, Westmorland & Furness Council, South Lakeland area, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Worcester City, Wychavon, Wychavon District Council (Deprecated), Wyre Forest District Council | +| United Kingdom | Aberdeenshire Council, Adur & Worthing Councils, Allerdale Borough Council, Amber Valley Borough Council, Anglesey, Antrim and Newtownabbey, Apps by imactivate, Ards and North Down Borough Council, Arun District Council, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Barnsley Metropolitan Borough Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, BCP Council, Bedford Borough Council, Binzone, Birmingham City Council, Blackburn with Darwen Borough Council, Blackpool Council, Borough Council of King's Lynn & West Norfolk, Borough of Broxbourne Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Brent Council, Bristol City Council, Broadland District Council, Bromsgrove City Council, Broxtowe Borough Council, Buckinghamshire: Former (Chiltern, South Bucks, Wycombe), Burnley Council, Bury Council, Cambridge City Council, Canterbury City Council, Cardiff Council, Central Bedfordshire Council, Charnwood, 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, Conwy County Borough Council, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Darlington Borough Council, Denbighshire County Council, Deprecated: Buckinghamshire, Derby City Council, Dover District Council, Dudley Metropolitan Borough Council, Durham County Council, East Ayrshire Council, East Cambridgeshire District Council, East Devon District Council, East Herts Council, East Lothian, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Eastleigh Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Borough Council, FCC Environment, Fenland, Fenland District Council, Fife Council, Flintshire, Fylde Council, Gateshead Council, Gedling Borough Council (unofficial), Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Haringey Council, Harlow Council, Hart District Council, Herefordshire City Council, High Peak Borough Council, Highland, Horsham District Council, Hull City Council, Huntingdonshire District Council, iTouchVision, Itouchvision Source using the encrypted API, Joint Waste Solutions, Kirklees Council, Lancaster City Council, Leeds, Leicester City Council, Lewes District Council, Lichfield District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Barking and Dagenham, London Borough of Bexley, London Borough of Bromley, London Borough of Camden, London Borough of Harrow, London Borough of Hounslow, London Borough of Lewisham, London Borough of Merton, London Borough of Newham, Luton, Maidstone Borough Council, Maldon District Council, Malvern Hills, Malvern Hills District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Moray Council, Newark & Sherwood District Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, Newport City Council, North Ayrshire Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Northamptonshire council, North Somerset Council, North West Leicestershire District Council, North Yorkshire Council - Hambleton, North Yorkshire Council - Harrogate, North Yorkshire Council - Scarborough, North Yorkshire Council - Selby, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Renfrewshire Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City Council, Shropshire Council, Solihull 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 Kesteven District Council, South Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, St Albans City & District Council, Stafford Borough Council, Stevenage Borough Council, Stirling.gov.uk, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Stroud District Council, Surrey Heath Borough Council, Sutton Council, London, Swansea 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, Tunbridge Wells, UK Bin Collection Schedule (UKBCD) project, Uttlesford District Council, Vale of Glamorgan 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, West Northamptonshire council, West Oxfordshire District Council, West Suffolk Council, Westmorland & Furness Council, Barrow area, Westmorland & Furness Council, South Lakeland area, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Worcester City, Wychavon, Wychavon District Council (Deprecated), Wyre Forest District Council | | United States of America | Albuquerque, New Mexico, USA, City of Austin, TX, City of Bloomington, City of Cambridge, City of Gastonia, NC, City of Georgetown, TX, City of McKinney, 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, Waste Connections |