Add source for Breckland Council, UK

Add source for Breckland Council, UK
This commit is contained in:
bbr111
2022-12-29 18:47:23 +01:00
parent b6515aac40
commit d30b9148f8
4 changed files with 119 additions and 1 deletions

View File

@@ -257,6 +257,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Bracknell Forest Council](/doc/source/bracknell_forest_gov_uk.md) / selfservice.mybfc.bracknell-forest.gov.uk
- [Bradford Metropolitan District Council](/doc/source/bradford_gov_uk.md) / bradford.gov.uk
- [Braintree District Council](/doc/source/braintree_gov_uk.md) / braintree.gov.uk
- [Breckland Council](/doc/source/breckland_gov_uk.md) / breckland.gov.uk
- [Cambridge City Council](/doc/source/cambridge_gov_uk.md) / cambridge.gov.uk
- [Canterbury City Council](/doc/source/canterbury_gov_uk.md) / canterbury.gov.uk
- [Cheshire East Council](/doc/source/cheshire_east_gov_uk.md) / cheshireeast.gov.uk

View File

@@ -0,0 +1,77 @@
import logging
import requests
from datetime import datetime
from waste_collection_schedule import Collection
TITLE = "Breckland Council, UK"
DESCRIPTION = "Source for breckland.gov.uk"
URL = "https://www.breckland.gov.uk/mybreckland"
TEST_CASES = {
"test1" : {"postcode":"IP22 2LJ","address":"glen travis" },
}
_LOGGER = logging.getLogger(__name__)
class Source:
def __init__(self,postcode,address):
self._postcode = postcode
self._address = address
def fetch(self):
json_data = {
"jsonrpc":"2.0",
"id":"",
"method":"Breckland.Whitespace.JointWasteAPI.GetSiteIDsByPostcode",
"params":{
"postcode":self._postcode,
"environment":"live"
}
}
headers = {'referer': 'https://www.breckland.gov.uk/mybreckland'}
url = 'https://www.breckland.gov.uk/apiserver/ajaxlibrary'
r = requests.post(url, json=json_data,headers=headers)
if r.status_code != 200:
_LOGGER.error("Error querying calender data")
return []
json_response = r.json()
uprn = ""
for key in json_response['result']:
if self._address.lower() in key['name'].lower():
uprn = (key['uprn'])
if uprn == "":
_LOGGER.error("Error querying calender data")
return []
json_data = {
"jsonrpc":"2.0",
"id":"",
"method":"Breckland.Whitespace.JointWasteAPI.GetBinCollectionsByUprn",
"params":{
"uprn":uprn,
"environment":"live"
}
}
r = requests.post(url, json=json_data,headers=headers)
if r.status_code != 200:
_LOGGER.error("Error querying calender data")
return []
waste = r.json()
waste = waste['result']
entries = []
for data in waste:
print(data['collectiontype'])
print(data['nextcollection'])
entries.append(Collection(datetime.strptime(data['nextcollection'],'%d/%m/%Y %H:%M:%S').date(),data['collectiontype']))
return entries

View File

@@ -0,0 +1,40 @@
# Breckland Council
Support for schedules provided by [Breckland Council](https://www.breckland.gov.uk/mybreckland)
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: breckland_gov_uk
args:
postcode: POSTCODE
address: ADDRESS
```
### Configuration Variables
**POSTCODE**
*(string) (required)*
**ADDRESS**
*(string) (required)*
## Examples
```yaml
waste_collection_schedule:
sources:
- name: breckland_gov_uk
args:
postcode: "IP22 2LJ"
address: "glen travis"
```
You can find all relevant informations at [Breckland Council](https://www.breckland.gov.uk/mybreckland) homepage
use the POSTCODE -> click find address.
Choose your address. Please only use the first part of your address. If you got an error, use less charecters from address.

View File

@@ -28,7 +28,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| Poland | Ecoharmonogram, Warsaw |
| Sweden | Lerum Vatten och Avlopp, Ronneby Miljöteknik, SRV Återvinning, SSAM, Sysav Sophämntning, VA Syd Sophämntning |
| Switzerland | A-Region, Andwil, Appenzell, Berg, Bühler, Eggersriet, Gais, Gaiserwald, Goldach, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
| United Kingdom | Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Cambridge City Council, Canterbury City Council, Cheshire East Council, Chesterfield Borough Council, City of York Council, Colchester Borough Council, Cornwall Council, Derby City Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Guildford Borough Council, Harborough District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Manchester City Council, Middlesbrough Council, Newcastle City Council, North Somerset Council, Nottingham City Council, Peterborough City Council, Richmondshire District Council, Rushmoor Borough Council, Sheffield City Council, South Cambridgeshire District Council, South Hams District Council, South Norfolk and Broadland Council, Stevenage Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council |
| United Kingdom | Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Cheshire East Council, Chesterfield Borough Council, City of York Council, Colchester Borough Council, Cornwall Council, Derby City Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Guildford Borough Council, Harborough District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Manchester City Council, Middlesbrough Council, Newcastle City Council, North Somerset Council, Nottingham City Council, Peterborough City Council, Richmondshire District Council, Rushmoor Borough Council, Sheffield City Council, South Cambridgeshire District Council, South Hams District Council, South Norfolk and Broadland Council, Stevenage Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council |
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
<!--End of country section-->