New Source: UK Bin Collection Data Project (#1296)

* initial commit from off-line repo

* url added, update_docu_links run

* typo
This commit is contained in:
dt215git
2023-11-24 17:29:10 +00:00
committed by GitHub
parent ead4e3c29a
commit 33a199c747
6 changed files with 1275 additions and 1 deletions

View File

@@ -1113,6 +1113,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Tewkesbury Borough Council](/doc/source/tewkesbury_gov_uk.md) / tewkesbury.gov.uk
- [The Royal Borough of Kingston Council](/doc/source/kingston_gov_uk.md) / kingston.gov.uk
- [Tonbridge and Malling Borough Council](/doc/source/tmbc_gov_uk.md) / tmbc.gov.uk
- [UK Bin Collection Schedule (UKBCD) project](/doc/source/ukbcd.md) / github.com/robbrad/UKBinCollectionData
- [Uttlesford District Council](/doc/source/uttlesford_gov_uk.md) / uttlesford.gov.uk
- [Vale of White Horse District Council](/doc/source/binzone_uk.md) / whitehorsedc.gov.uk
- [Walsall Council](/doc/source/walsall_gov_uk.md) / walsall.gov.uk

View File

@@ -0,0 +1,31 @@
"""
Generates a new json source file for testing purposes.
Script can be used to generate a new ukbcd_test.json file if the dates in the current version elapse.
Randomly generates 4 waste collections per month for the next 5 years.
Before running, check they haven't changed the json structure: https://github.com/robbrad/UKBinCollectionData
"""
import datetime
import json
from pathlib import Path
from random import choice, randint
ROOT_DIR = Path(__file__).parents[1]
TEST_DIR = ROOT_DIR / "test"
FILENAME = "test_ukbcd.json"
WASTES = ["Refuse", "Recycling", "Garden", "Food", "Paper & Cardboard", "Batteries"]
data: dict = {"bins": []}
year = datetime.date.today().year
for year in range(year, year + 6):
for month in range(1, 13):
for days in range(0, 4):
day = randint(1, 28)
dt = f"{day:02d}" + "/" + f"{month:02d}" + "/" + f"{year:04d}"
dict_data = {"type": choice(WASTES), "collectionDate": dt}
data["bins"].append(dict_data)
json_object = json.dumps(data, ensure_ascii=False, indent=4)
with open(Path(TEST_DIR / FILENAME), "w") as outfile:
outfile.write(json_object)

View File

@@ -0,0 +1,49 @@
import json
from datetime import datetime
from pathlib import Path
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "UK Bin Collection Schedule (UKBCD) project"
DESCRIPTION = "Source for json-based schedules generated by UKBCD project scripts."
URL = "https://github.com/robbrad/UKBinCollectionData/"
COUNTRY = "uk"
ROOT_DIR = Path(__file__).parents[1]
TEST_FILE = ROOT_DIR / "test" / "test_ukbcd.json"
TEST_CASES = {
"Test_File": {
# Path is used here to allow the Source call from any location. It is not required in a yaml configuration.
"file": str(Path(TEST_FILE))
}
}
class Source:
def __init__(self, file=None):
self._file = file
def fetch(self):
if self._file is not None:
json_file = open(self._file)
schedule = json.load(json_file)["bins"]
entries = []
for item in schedule:
entries.append(
Collection(
date=datetime.strptime(
item["collectionDate"], "%d/%m/%Y"
).date(),
t=item["type"],
)
)
else:
raise RuntimeError("Unable to find file, check config path and file name")
return entries
"""
If the test case returns no entries, check dates in the source file are not all in the past.
If they are, a new test_ukbcd.json file with future dates can be generated using service script located at:
custom_components/waste_collection_schedule/waste_collection_schedule/service/generate_ukbcd_json.py
"""

37
doc/source/ukbcd.md Normal file
View File

@@ -0,0 +1,37 @@
# UK Bin Collection Data (UKBCD)
The [UK Bin Collection Data project](https://github.com/robbrad/UKBinCollectionData) provides waste collection schedules in a standardised json format for a number of UK councils.
There is significant overlap with the UK councils supported by HACS Waste Collection Schedule project.
If you're using UKBCD to generate a json file containing your collection schedule, that file can function as a HACS Waste Collection Schedule source.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: ukbcd
args:
file: FILE
```
### Configuration Variables
**file**
*(string) (optional)*
Local json file name. Care should be taken to ensure the correct path and filename is used.
## Example
```yaml
# file location: config/www/bin_schedule.json
waste_collection_schedule:
sources:
- name: ukbcd
args:
file: "www/bin_schedule.json"
```
### Notes
Usage questions and issues relating to [UKBCD](https://github.com/robbrad/UKBinCollectionData) should be directed to that project. The HACS Waste Collection Schedule simply parses json files generated by any UKBCD scripts you may be running.

View File

@@ -33,7 +33,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, Real Luzern, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
| United Kingdom | Aberdeenshire Council, Adur & Worthing Councils, Allerdale Borough Council, Amber Valley Borough Council, Anglesey, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Borough Council of King's Lynn & West Norfolk, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Broadland District Council, Broxtowe Borough Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Burnley Council, Cambridge City Council, Canterbury City Council, Cardiff Council, Central Bedfordshire Council, 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, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Derby City Council, Dudley Metropolitan Borough Council, Durham County Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Haringey Council, Harlow Council, Hart District Council, Herefordshire City Council, Highland, Horsham District Council, Huntingdonshire District Council, iTouchVision, Joint Waste Solutions, 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 Camden, London Borough of Lewisham, London Borough of Merton, Maidstone Borough Council, Maldon District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Somerset Council, North Yorkshire Council - Hambleton, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City 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 Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Surrey Heath Borough 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, Uttlesford District 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, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Wyre Forest District Council |
| United Kingdom | Aberdeenshire Council, Adur & Worthing Councils, Allerdale Borough Council, Amber Valley Borough Council, Anglesey, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Borough Council of King's Lynn & West Norfolk, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Broadland District Council, Broxtowe Borough Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Burnley Council, Cambridge City Council, Canterbury City Council, Cardiff Council, Central Bedfordshire Council, 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, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Derby City Council, Dudley Metropolitan Borough Council, Durham County Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Haringey Council, Harlow Council, Hart District Council, Herefordshire City Council, Highland, Horsham District Council, Huntingdonshire District Council, iTouchVision, Joint Waste Solutions, 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 Camden, London Borough of Lewisham, London Borough of Merton, Maidstone Borough Council, Maldon District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Somerset Council, North Yorkshire Council - Hambleton, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City 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 Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Surrey Heath Borough 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, UK Bin Collection Schedule (UKBCD) project, Uttlesford District 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, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Wyre Forest District Council |
| United States of America | Albuquerque, New Mexico, USA, City of Bloomington, City of Cambridge, City of Gastonia, NC, City of Georgetown, 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 |
<!--End of country section-->