mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 06:05:57 +01:00
Adding Fenland_gov_uk
This commit is contained in:
@@ -197,8 +197,8 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Landkreis Rotenburg (Wümme)](/doc/source/abfall_io.md) / lk-awr.de
|
||||
- [Landkreis Roth](/doc/source/c_trace_de.md) / landratsamt-roth.de
|
||||
- [Landkreis Schweinfurt](/doc/source/awido_de.md) / landkreis-schweinfurt.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
|
||||
- [Landkreis Sigmaringen](/doc/source/abfall_io.md) / landkreis-sigmaringen.de
|
||||
- [Landkreis Südliche Weinstraße](/doc/source/awido_de.md) / suedliche-weinstrasse.de
|
||||
- [Landkreis Tirschenreuth](/doc/source/awido_de.md) / kreis-tir.de
|
||||
@@ -440,6 +440,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Elmbridge Borough Council](/doc/source/elmbridge_gov_uk.md) / elmbridge.gov.uk
|
||||
- [Environment First](/doc/source/environmentfirst_co_uk.md) / environmentfirst.co.uk
|
||||
- [FCC Environment](/doc/source/fccenvironment_co_uk.md) / fccenvironment.co.uk
|
||||
- [Fenland District Council](/doc/source/fenland_gov_uk.md) / fenland.gov.uk
|
||||
- [Glasgow City Council](/doc/source/glasgow_gov_uk.md) / glasgow.gov.uk
|
||||
- [Guildford Borough Council](/doc/source/guildford_gov_uk.md) / guildford.gov.uk
|
||||
- [Harborough District Council](/doc/source/fccenvironment_co_uk.md) / harborough.gov.uk
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
from datetime import datetime
|
||||
import requests
|
||||
import re
|
||||
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "Fenland District Council"
|
||||
DESCRIPTION = "Source script for fenland.gov.uk services for Fenland"
|
||||
URL = "https://www.fenland.gov.uk/"
|
||||
TEST_CASES = {
|
||||
"Address1": {"post_code": "PE13 1JR", "house_number": "Flat 1"},
|
||||
"Address2": {"post_code": "PE15 0SD", "house_number": 1}
|
||||
}
|
||||
|
||||
API_URLS = {
|
||||
"address_search": "https://www.fenland.gov.uk/find?type=postcodesearch&postcode={}",
|
||||
"collection": "https://www.fenland.gov.uk/find?type=loadlayer&layerId=2&uprn={uprn}&lat={lat}&lng={lng}",
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"Empty Bin GREEN 240": "mdi:trash-can",
|
||||
"Empty Bin REFUSE SACK": "mdi:trash-can",
|
||||
"Empty Bin BLUE 240": "mdi:recycle",
|
||||
"Empty Bin RECYCLING SACK": "mdi:recycle",
|
||||
"Empty Bin BROWN 240": "mdi:leaf",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, post_code: str, house_number: str):
|
||||
self._post_code = post_code
|
||||
self._house_number = house_number
|
||||
|
||||
def fetch(self):
|
||||
|
||||
r = requests.get(
|
||||
API_URLS["address_search"].format(self._post_code), headers={"Accept":"application/json"}
|
||||
)
|
||||
r.raise_for_status()
|
||||
addresses = r.json()
|
||||
|
||||
address_ids = [
|
||||
address for address in addresses if re.search(f"^{self._house_number} ", address["line1"]) # House numbers are not separated from address line
|
||||
]
|
||||
|
||||
if len(address_ids) == 0:
|
||||
print(addresses)
|
||||
raise Exception(f"Could not find address :: Post Code: {self._post_code} House Number: {self._house_number}")
|
||||
|
||||
r = requests.get(
|
||||
API_URLS["collection"].format(uprn = address_ids[0]["udprn"], lat = address_ids[0]["latitude"], lng = address_ids[0]["longitude"]), headers={"Accept":"application/json"}
|
||||
)
|
||||
r.raise_for_status()
|
||||
collections = r.json()["features"][0]["properties"]["upcoming"]
|
||||
|
||||
entries = []
|
||||
|
||||
for collectionDate in collections:
|
||||
for collection in collectionDate["collections"]:
|
||||
entries.append(
|
||||
Collection(
|
||||
date = datetime.strptime(
|
||||
collectionDate["date"], "%Y-%m-%dT%H:%M:%SZ"
|
||||
).date(),
|
||||
t = collection["desc"],
|
||||
icon = ICON_MAP.get(collection["name"]),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
33
doc/source/fenland_gov_uk
Normal file
33
doc/source/fenland_gov_uk
Normal file
@@ -0,0 +1,33 @@
|
||||
# Fenland District Council
|
||||
|
||||
Support for schedules provided by [Fenland District Council](https://www.fenland.gov.uk/find), serving Fenland.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: fenland_gov_uk
|
||||
args:
|
||||
post_code: POST_CODE
|
||||
house_number: NUMBER
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**POST_CODE**
|
||||
*(string) (required)*
|
||||
|
||||
**HOUSE_NUMBER**
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: fenland_gov_uk
|
||||
args:
|
||||
post_code: "PE15 0SD"
|
||||
house_number: "1"
|
||||
```
|
||||
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, Fenland District 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 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 States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
<!--End of country section-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user