diff --git a/README.md b/README.md index b1520342..a425cf10 100644 --- a/README.md +++ b/README.md @@ -740,6 +740,7 @@ Waste collection schedules in the following formats and countries are supported. - [West Dunbartonshire Council](/doc/source/west_dunbartonshire_gov_uk.md) / west-dunbarton.gov.uk - [Wigan Council](/doc/source/wigan_gov_uk.md) / wigan.gov.uk - [Wiltshire Council](/doc/source/wiltshire_gov_uk.md) / wiltshire.gov.uk +- [Wirral Council](/doc/source/wirral_gov_uk.md) / wirral.gov.uk - [Wyre Forest District Council](/doc/source/wyreforestdc_gov_uk.md) / wyreforestdc.gov.uk diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/wirral_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wirral_gov_uk.py new file mode 100644 index 00000000..fe75018e --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/wirral_gov_uk.py @@ -0,0 +1,55 @@ +import requests + +from bs4 import BeautifulSoup +from datetime import datetime +from waste_collection_schedule import Collection # type: ignore[attr-defined] + +TITLE = "Wirral Council" +DESCRIPTION = "Source for wirral.gov.uk services for Wirral Council, UK." +URL = "https://wirral.gov.uk" +TEST_CASES = { + "Test_001": {"street": "Vernon Avenue", "suburb": "Poulton"}, + "Test_002": {"street": "Vernon Avenue", "suburb": "Seacombe"}, + "Test_003": {"street": "Claremont Road", "suburb": "West Kirby"}, + "Test_004": {"street": "Beckenham Road", "suburb": "New Brighton"}, +} +ICON_MAP = { + "NON RECYCLEABLE (GREEN BIN)": "mdi:trash-can", + "PAPER AND PACKAGING (GREY BIN)": "mdi:newspaper", + "GARDEN WASTE (BROWN BIN)": "mdi:leaf", +} +WASTES = { + "Non recycleable (green bin)", + "Garden waste (brown bin)", + "Paper and packaging (grey bin)", +} + + +class Source: + def __init__(self, street, suburb): + self._street = street + self._suburb = suburb + + def fetch(self): + s = requests.Session() + #Loop through waste types + entries = [] + for waste in WASTES: + r = s.get( + f"https://ww3.wirral.gov.uk//recycling/detailContentDru7.asp?s={self._street}&t={self._suburb}&c={waste}" + ) + # extract dates + soup = BeautifulSoup(r.text, "html.parser") + dates = soup.findAll("li") + if dates != 0: + for item in dates: + entries.append( + Collection( + date=datetime.strptime(item.text, "%d %B %Y").date(), + t=waste, + icon=ICON_MAP.get(waste.upper()), + ) + ) + + return entries + \ No newline at end of file diff --git a/doc/source/wirral_gov_uk.md b/doc/source/wirral_gov_uk.md new file mode 100644 index 00000000..94d26a46 --- /dev/null +++ b/doc/source/wirral_gov_uk.md @@ -0,0 +1,35 @@ +# Wirral Council + +Support for schedules provided by [Wirral Council](https://wirral.gov.uk/), UK. + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: wirral_gov_uk + args: + street: STREET + suburb: SUBURB +``` + +### Configuration Variables + +**street** +*(string) (required)* + +**suburb** +*(string) (required)* + +Both the street and suburb are should be supplied in the arguments, as they appear on the web site when viewing your schedule. + +## Examples + +```yaml +waste_collection_schedule: + sources: + - name: wirral_gov_uk + args: + street: "Beckenham Road" + suburb: "New Brighton" +``` \ No newline at end of file diff --git a/info.md b/info.md index 35a5bd0b..99e31850 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, 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, Wyre Forest District Council | +| 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, 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 |