mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 00:04:11 +01:00
Add Reading Council (reading.gov.uk) source (#901)
* Add Reading Council (reading.gov.uk) source * s/hournameornumber/housenameornumber/ * Rename housenumberorname to housenameornumber in source reading_gov_uk * Fix doc arg name for cornwall and westberks
This commit is contained in:
@@ -703,6 +703,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Nottingham City Council](/doc/source/nottingham_city_gov_uk.md) / nottinghamcity.gov.uk
|
||||
- [Oxford City Council](/doc/source/oxford_gov_uk.md) / oxford.gov.uk
|
||||
- [Peterborough City Council](/doc/source/peterborough_gov_uk.md) / peterborough.gov.uk
|
||||
- [Reading Council](/doc/source/reading_gov_uk.md) / reading.gov.uk
|
||||
- [Reigate & Banstead Borough Council](/doc/source/reigatebanstead_gov_uk.md) / reigate-banstead.gov.uk
|
||||
- [Richmondshire District Council](/doc/source/richmondshire_gov_uk.md) / richmondshire.gov.uk
|
||||
- [Rotherham Metropolitan Borough Council](/doc/source/rotherham_gov_uk.md) / rotherham.gov.uk
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
from datetime import date, datetime
|
||||
from typing import List
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "Reading Council"
|
||||
DESCRIPTION = "Source for reading.gov.uk services for Reading Council"
|
||||
URL = "https://reading.gov.uk"
|
||||
TEST_CASES = {
|
||||
"known_uprn": {"uprn": "310027679"},
|
||||
"known_uprn as number": {"uprn": 310027679},
|
||||
"unknown_uprn_by_number": {"postcode": "RG31 5PN", "housenameornumber": "65"},
|
||||
"unknown_uprn_by_number as number": {"postcode": "RG31 5PN", "housenameornumber": 65}
|
||||
}
|
||||
|
||||
ICONS = {
|
||||
"Rubbish": "mdi:trash-can",
|
||||
"Recycling": "mdi:recycle",
|
||||
"Food Waste": "mdi:food",
|
||||
"Garden Waste": "mdi:tree"
|
||||
}
|
||||
|
||||
COLLECTIONS = {
|
||||
"Domestic Waste Collection Service": "Rubbish",
|
||||
"Recycling Collection Service": "Recycling",
|
||||
"Food Waste Collection Service": "Food Waste",
|
||||
"Garden Waste Collection Service": "Garden Waste"
|
||||
}
|
||||
|
||||
SEARCH_URLS = {
|
||||
"UPRN": "https://api.reading.gov.uk/rbc/getaddresses",
|
||||
"COLLECTION": "https://api.reading.gov.uk/api/collections"
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(
|
||||
self, uprn=None, postcode=None, housenameornumber=None
|
||||
):
|
||||
self._postcode = postcode
|
||||
self._housenameornumber = str(housenameornumber)
|
||||
self._uprn = uprn
|
||||
|
||||
def fetch(self) -> List[Collection]:
|
||||
if self._uprn is None:
|
||||
self._uprn = self.get_uprn()
|
||||
resp = requests.get(f"{SEARCH_URLS['COLLECTION']}/{self._uprn}")
|
||||
breakpoint()
|
||||
return [self.parse_collection(col) for col in resp.json()["collections"]]
|
||||
|
||||
def get_uprn(self) -> str:
|
||||
resp = requests.get(f"{SEARCH_URLS['UPRN']}/{self._postcode}")
|
||||
addresses = resp.json()["Addresses"]
|
||||
address = next(filter(self.filter_addresses, addresses), None)
|
||||
if address is None:
|
||||
raise Exception(f"House {self._housenameornumber} not found for postcode {self._postcode}")
|
||||
return address["AccountSiteUprn"]
|
||||
|
||||
def filter_addresses(self, address) -> bool:
|
||||
nameornum, _ = address["SiteShortAddress"].split(f", {address['SiteAddress2']}, ")
|
||||
return self._housenameornumber == nameornum
|
||||
|
||||
def parse_collection(self, col) -> Collection:
|
||||
dt = datetime.strptime(col["date"], "%d/%m/%Y %H:%M:%S").date()
|
||||
waste_type = COLLECTIONS[col["service"]]
|
||||
icon = ICONS[waste_type]
|
||||
|
||||
return Collection(date=dt, t=waste_type, icon=icon)
|
||||
@@ -17,16 +17,16 @@ waste_collection_schedule:
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**postcode**
|
||||
**postcode**
|
||||
*(string) (optional)*
|
||||
|
||||
**hournameornumber**
|
||||
**housenumberorname**
|
||||
*(string) (optional)*
|
||||
|
||||
**uprn**
|
||||
**uprn**
|
||||
*(string) (optional)*
|
||||
|
||||
Either the postcode and housenameornumber or the UPRN should be supplied in the arguments
|
||||
Either the postcode and housenumberorname or the UPRN should be supplied in the arguments
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -36,7 +36,7 @@ waste_collection_schedule:
|
||||
- name: cornwall_gov_uk
|
||||
args:
|
||||
postcode: TR261SP
|
||||
housenameornumber: 7
|
||||
housenumberorname: 7
|
||||
uprn: 100040118005
|
||||
```
|
||||
|
||||
|
||||
51
doc/source/reading_gov_uk.md
Normal file
51
doc/source/reading_gov_uk.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Reading Council
|
||||
|
||||
Support for schedules provided by [Reading Council](https://www.reading.gov.uk/).
|
||||
|
||||
If collection data is available for the address provided, it will return rubbish and recycling waste collection dates.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: reading_gov_uk
|
||||
args:
|
||||
uprn: UPRN
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**postcode**
|
||||
_(string) (optional)_
|
||||
|
||||
**housenameornumber**
|
||||
_(string|int) (optional)_
|
||||
|
||||
**uprn**
|
||||
_(string) (optional)_
|
||||
|
||||
Either the postcode _and_ housenameornumber or the UPRN should be supplied in the arguments
|
||||
|
||||
## Examples
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: reading_gov_uk
|
||||
args:
|
||||
uprn: "100080241094"
|
||||
```
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: westberks_gov_uk
|
||||
args:
|
||||
postcode: "RG18 4QU"
|
||||
housenameornumber: "6"
|
||||
```
|
||||
|
||||
## How to find your UPRN
|
||||
|
||||
An easy way to discover your Unique Property Reference Number (UPRN) is by going to [Find My Address](https://www.findmyaddress.co.uk/) and providing your address details.
|
||||
@@ -17,16 +17,16 @@ waste_collection_schedule:
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**postcode**
|
||||
**postcode**
|
||||
_(string) (optional)_
|
||||
|
||||
**hournameornumber**
|
||||
**housenumberorname**
|
||||
_(string) (optional)_
|
||||
|
||||
**uprn**
|
||||
**uprn**
|
||||
_(string) (optional)_
|
||||
|
||||
Either the postcode _and_ housenameornumber or the UPRN should be supplied in the arguments
|
||||
Either the postcode _and_ housenumberorname or the UPRN should be supplied in the arguments
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -44,7 +44,7 @@ waste_collection_schedule:
|
||||
- name: westberks_gov_uk
|
||||
args:
|
||||
postcode: "RG18 4QU"
|
||||
housenameornumber: "6"
|
||||
housenumberorname: "6"
|
||||
```
|
||||
|
||||
## How to find your UPRN
|
||||
|
||||
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 | 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, 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, 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, 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 Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District 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, 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, 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, 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 Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District 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 States of America | City of Oklahoma City, City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
<!--End of country section-->
|
||||
|
||||
|
||||
@@ -217,6 +217,7 @@ Currently the following service providers are supported:
|
||||
- [North Somerset Council - n-somerset.gov.uk](./doc/source/nsomerset_gov_uk.md)
|
||||
- [Nottingham City Council - nottinghamcity.gov.uk](./doc/source/nottingham_city_gov_uk.md)
|
||||
- [Peterborough City Council - peterborough.gov.uk](./doc/source/peterborough_gov_uk.md)
|
||||
- [Reading Council - reading.gov.uk](./doc/source/reading_gov_uk.md)
|
||||
- [Richmondshire District Council - richmondshire.gov.uk](./doc/source/richmondshire_gov_uk.md)
|
||||
- [Rushmoor Borough Council - rushmoor.gov.uk](./doc/source/rushmoor_gov_uk.md)
|
||||
- [Sheffield City Council - sheffield.gov.uk](./doc/source/sheffield_gov_uk.md)
|
||||
|
||||
@@ -202,6 +202,7 @@ Currently the following service providers are supported:
|
||||
- [North Somerset Council - n-somerset.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/nsomerset_gov_uk.md)
|
||||
- [Nottingham City Council - nottinghamcity.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/nottingham_city_gov_uk.md)
|
||||
- [Peterborough City Council - peterborough.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/peterborough_gov_uk.md)
|
||||
- [Reading Council - reading.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/reading_gov_uk.md)
|
||||
- [Richmondshire District Council - richmondshire.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/richmondshire_gov_uk.md)
|
||||
- [Rushmoor Borough Council - rushmoor.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/rushmoor_gov_uk.md)
|
||||
- [Sheffield City Council - Sheffield.gov.uk]((https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/sheffield_gov_uk.md)
|
||||
|
||||
Reference in New Issue
Block a user