diff --git a/README.md b/README.md index 5dd72844..ef07aafe 100644 --- a/README.md +++ b/README.md @@ -677,6 +677,7 @@ Waste collection schedules in the following formats and countries are supported.
United Kingdom +- [Aberdeenshire Council](/doc/source/aberdeenshire_gov_uk.md) / aberdeenshire.gov.uk - [Amber Valley Borough Council](/doc/source/ambervalley_gov_uk.md) / ambervalley.gov.uk - [Ashfield District Council](/doc/source/ashfield_gov_uk.md) / ashfield.gov.uk - [Basildon Council](/doc/source/basildon_gov_uk.md) / basildon.gov.uk diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/aberdeenshire_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/aberdeenshire_gov_uk.py new file mode 100644 index 00000000..2abb23f9 --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/aberdeenshire_gov_uk.py @@ -0,0 +1,46 @@ +import requests + +from bs4 import BeautifulSoup +from datetime import datetime +from waste_collection_schedule import Collection # type: ignore[attr-defined] + +# Include work around for SSL UNSAFE_LEGACY_RENEGOTIATION_DISABLED error +from waste_collection_schedule.service.SSLError import get_legacy_session + +TITLE = "Aberdeenshire Council" +DESCRIPTION = "Source for Aberdeenshire Council, UK." +URL = "https://aberdeenshire.gov.uk" +TEST_CASES = { + "Test_001": {"uprn": "000151124612"}, + "Test_002": {"uprn": "000151004105"}, + "Test_003": {"uprn": "0151035884"}, + "Test_004": {"uprn": 151170625} +} +ICON_MAP = { + "Mixed Recycling + Food Waste": "mdi:recycle", + "Refuse + Food Waste": "mdi:trash-can", +} + +class Source: + def __init__(self, uprn): + self._uprn = str(uprn).zfill(12) + + def fetch(self): + + response = get_legacy_session().get(f"https://online.aberdeenshire.gov.uk/Apps/Waste-Collections/Routes.aspx?uprn={self._uprn}") + soup = BeautifulSoup(response.text, "html.parser") + + entries = [] + + tr = soup.findAll("tr") + for item in tr[1:]: # Ignore table header row + td = item.findAll("td") + entries.append( + Collection( + date=datetime.strptime(td[5].text, "%d/%m/%Y").date(), + t=td[2].text, + icon=ICON_MAP.get(td[2].text), + ) + ) + + return entries diff --git a/doc/source/aberdeenshire_gov_uk.md b/doc/source/aberdeenshire_gov_uk.md new file mode 100644 index 00000000..816641cf --- /dev/null +++ b/doc/source/aberdeenshire_gov_uk.md @@ -0,0 +1,39 @@ +# Aberdeenshire Council + +Support for schedules provided by [Aberdeenshire Council](https://www.aberdeenshire.gov.uk/), serving Aberdeenshire, UK. + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: aberdeenshire_gov_uk + args: + uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER +``` + +### Configuration Variables + +**uprn**
+*(string) (required)* + + +## Example using UPRN +```yaml +waste_collection_schedule: + sources: + - name: aberdeenshire_gov_uk + args: + uprn: "000151650618" +``` + + +#### How to find your `UPRN` +Your uprn is the collection of numbers at the end of the url when viewing your collection schedule on the Aberdeenshire Councile web site. + +For example: _online.aberdeenshire.gov.uk/Apps/Waste-Collections/Routes.aspx?uprn=`000151650618`_ + +Alternatively, 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 49114de7..dc02f6a1 100644 --- a/info.md +++ b/info.md @@ -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, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden | -| United Kingdom | 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, 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 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, 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, 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 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, 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 |