mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
Add support for Merton, UK
This commit is contained in:
@@ -452,6 +452,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Liverpool City Council](/doc/source/liverpool_gov_uk.md) / liverpool.gov.uk
|
||||
- [London Borough of Bromley](/doc/source/bromley_gov_uk.md) / bromley.gov.uk
|
||||
- [London Borough of Lewisham](/doc/source/lewisham_gov_uk.md) / lewisham.gov.uk
|
||||
- [London Borough of Merton](/doc/source/merton_gov_uk.md) / merton.gov.uk
|
||||
- [Maldon District Council](/doc/source/maldon_gov_uk.md) / maldon.gov.uk
|
||||
- [Manchester City Council](/doc/source/manchester_uk.md) / manchester.gov.uk
|
||||
- [Mid-Sussex District Council](/doc/source/midsussex_gov_uk.md) / midsussex.gov.uk
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "London Borough of Merton"
|
||||
|
||||
DESCRIPTION = ("Source for www.merton.gov.uk services for London Borough of Merton, UK")
|
||||
|
||||
URL = "https://www.merton.gov.uk/"
|
||||
|
||||
TEST_CASES = {
|
||||
"test 1": {"ID": "28186366"},
|
||||
"test 2": {"ID": "28166100"},
|
||||
}
|
||||
|
||||
API_URL = "https://myneighbourhood.merton.gov.uk/Wasteservices/WasteServices.aspx?ID="
|
||||
|
||||
ICON_MAP = {
|
||||
"Food waste": "mdi:food",
|
||||
"Paper and card": "mdi:newspaper",
|
||||
"Plastics, glass, cans and cartons": "mdi:glass-fragile",
|
||||
"Rubbish": "mdi:trash-can",
|
||||
"Textiles": "mdi:hanger",
|
||||
"Household batteries": "mdi:battery",
|
||||
}
|
||||
|
||||
class Source:
|
||||
def __init__(self, ID: str):
|
||||
self._ID = ID
|
||||
|
||||
def fetch(self):
|
||||
entries = []
|
||||
session = requests.Session()
|
||||
r = session.get(f"{API_URL}{self._ID}")
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
soup.prettify()
|
||||
|
||||
# Search for the specific bin in the table using BS4
|
||||
collections = soup.find("table", class_=("collectiondays")).find_all(
|
||||
"tr",
|
||||
class_=(
|
||||
"food-caddy",
|
||||
"papercard-wheelie",
|
||||
"plastics-boxes",
|
||||
"rubbish-wheelie",
|
||||
"textiles",
|
||||
"batteries",
|
||||
),
|
||||
)
|
||||
if not collections:
|
||||
raise Exception("No collections found for given UPRN")
|
||||
# Loop the collections
|
||||
for collection in collections:
|
||||
# Get all the cells
|
||||
cells = collection.find_all("td")
|
||||
# First cell is the bin_type
|
||||
title = cells[0].get_text().strip()
|
||||
# Date is on the second cell, second paragraph, wrapped in p
|
||||
collectionDate = cells[1].select("p > b")[2].get_text(strip=True)
|
||||
# Add data to the main JSON Wrapper
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.strptime(collectionDate, "%d %B %Y").date(),
|
||||
t=title,
|
||||
icon=ICON_MAP.get(title),
|
||||
)
|
||||
)
|
||||
return entries
|
||||
38
doc/source/merton_gov_uk.md
Normal file
38
doc/source/merton_gov_uk.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# London Borough of Merton
|
||||
|
||||
Support for schedules provided by the [London Borough of Merton](https://merton.gov.uk), serving Merton, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: merton_gov_uk
|
||||
args:
|
||||
property: PROPERTY_ID
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**property**<br>
|
||||
_(string) (required)_
|
||||
|
||||
Unique number the London Borough of Merton uses to identify your property.
|
||||
|
||||
#### How to find your `PROPERTY_ID`
|
||||
|
||||
Serach for your waste collection schedule at (https://myneighbourhood.merton.gov.uk/Wasteservices/WasteServicesSearch.aspx). Your `PROPERTY_ID` is the set of numbers at the end of the url when your schedule is being displayed.
|
||||
|
||||
For example: myneighbourhood.merton.gov.uk/Wasteservices/WasteServices.aspx?ID=`28166109`
|
||||
|
||||
_Note:_ You can ignore the `Address` parameter, it's optional.
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: merton_gov_uk
|
||||
args:
|
||||
property: 28166109
|
||||
```
|
||||
2
info.md
2
info.md
@@ -30,7 +30,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
||||
| Slovenia | Moji odpadki, Ljubljana |
|
||||
| Sweden | 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, 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, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, 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, Liverpool City Council, London Borough of Bromley, London Borough of Lewisham, 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, Richmondshire District Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
|
||||
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, 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, Liverpool City Council, 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, Richmondshire District Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
|
||||
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
<!--End of country section-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user