mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Add source for Ashfield District Council, UK
This commit is contained in:
@@ -254,6 +254,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
<details>
|
||||
<summary>United Kingdom</summary>
|
||||
|
||||
- [Ashfield District Council](/doc/source/ashfield_gov_uk.md) / ashfield.gov.uk
|
||||
- [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
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import json
|
||||
import datetime
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "Ashfield.gov.uk"
|
||||
DESCRIPTION = "Source for ashfield.gov.uk, Ashfield District Council, UK"
|
||||
URL = "https://www.ashfield.gov.uk"
|
||||
TEST_CASES = {
|
||||
"11 Maun View Gardens, Sutton-in-Ashfield": {"uprn": 10001336299},
|
||||
"4A Station Street, Kirkby-in-Ashfield": {"post_code": "NG177AR", "number": "4A"},
|
||||
"Ashfield District Council": {"post_code": "NG17 8DA", "name": "Ashfield District Council"}
|
||||
}
|
||||
|
||||
API_URLS = {
|
||||
"address_search": "https://www.ashfield.gov.uk/api/powersuite/getaddresses/{postcode}",
|
||||
"collection": "https://www.ashfield.gov.uk/api/powersuite/GetCollectionByUprnAndDate/{uprn}",
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"Residual Waste Collection Service": "mdi:trash-can",
|
||||
"Domestic Recycling Collection Service": "mdi:recycle",
|
||||
"Domestic Glass Collection Service": "mdi:glass-fragile",
|
||||
"Garden Waste Collection Service": "mdi:leaf"
|
||||
}
|
||||
|
||||
NAMES = {
|
||||
"Residual Waste Collection Service": "Red (rubbish)",
|
||||
"Domestic Recycling Collection Service": "Green (recycling)",
|
||||
"Domestic Glass Collection Service": "Blue (glass)",
|
||||
"Garden Waste Collection Service": "Brown (garden)"
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, post_code=None, number=None, name=None, uprn=None):
|
||||
self._post_code = post_code
|
||||
self._number = number
|
||||
self._name = name
|
||||
self._uprn = uprn
|
||||
|
||||
def fetch(self):
|
||||
if not self._uprn:
|
||||
# look up the UPRN for the address
|
||||
q = str(API_URLS["address_search"]).format(
|
||||
postcode=self._post_code)
|
||||
r = requests.get(q)
|
||||
r.raise_for_status()
|
||||
addresses = r.json()["data"]
|
||||
|
||||
if self._name:
|
||||
self._uprn = [
|
||||
int(x["AccountSiteUprn"]) for x in addresses if x["SiteAddressName"].capitalize() == self._name.capitalize()
|
||||
][0]
|
||||
elif self._number:
|
||||
self._uprn = [
|
||||
int(x["AccountSiteUprn"]) for x in addresses if x["SiteAddressNumber"] == self._number
|
||||
][0]
|
||||
|
||||
if not self._uprn:
|
||||
raise Exception(
|
||||
f"Could not find address {self._post_code} {self._number}{self._name}")
|
||||
|
||||
q = str(API_URLS["collection"]).format(
|
||||
uprn=self._uprn
|
||||
)
|
||||
|
||||
r = requests.get(q)
|
||||
r.raise_for_status()
|
||||
|
||||
collections = r.json()["data"]
|
||||
entries = []
|
||||
|
||||
if collections:
|
||||
for collection in collections:
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.datetime.strptime(
|
||||
collection["Date"], "%d/%m/%Y %H:%M:%S"
|
||||
).date(),
|
||||
t=NAMES.get(collection["Service"])['name'],
|
||||
icon=ICON_MAP.get(collection["Service"])['icon']
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
63
doc/source/ashfield_gov_uk.md
Normal file
63
doc/source/ashfield_gov_uk.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Ashfield District Council
|
||||
|
||||
Support for schedules provided by [Ashfield District Council](https://www.ashfield.gov.uk/), serving Ashfield district in Nottinghshire, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: ashfield_gov_uk
|
||||
args:
|
||||
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER
|
||||
post_code: POST_CODE
|
||||
name: HOUSE_NAME
|
||||
number: HOUSE_NUMBER
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**<br>
|
||||
*(string) (optional)*
|
||||
|
||||
This is required if you do not supply any other options. (Using this removes the need to do an address look up web request)
|
||||
|
||||
**name**<br>
|
||||
*(string) (optional)*
|
||||
|
||||
This is required if you supply a Postcode and do not have a house number.
|
||||
|
||||
**number**<br>
|
||||
*(string) (optional)*
|
||||
|
||||
This is required if you supply a Postcode and have a house number.
|
||||
|
||||
**post_code**<br>
|
||||
*(string) (optional)*
|
||||
|
||||
This is required if you do not supply a UPRN. Single space between 1st and 2nd part of postcode is optional.
|
||||
|
||||
#### How to find your `UPRN`
|
||||
An easy way to discover your Unique Property Reference Number (UPRN) is by going to https://www.findmyaddress.co.uk/ and entering in your address details.
|
||||
Otherwise you can inspect the web requests the Ashfield District Council website makes when entering in your postcode and then selecting your address.
|
||||
|
||||
## Example using UPRN
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: ashfield_gov_uk
|
||||
args:
|
||||
uprn: 100032105121
|
||||
```
|
||||
|
||||
## Example using Address lookup
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: ashfield_gov_uk
|
||||
args:
|
||||
post_code: "NG17 8DA"
|
||||
name: "Ashfield District Council"
|
||||
```
|
||||
2
info.md
2
info.md
@@ -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, 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 Kingdom | Ashfield District Council, 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-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user