mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
adding fife_gov_uk
This commit is contained in:
@@ -450,6 +450,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [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
|
||||
- [Fife Council](/doc/source/fife_gov_uk.md) / fife.gov.uk
|
||||
- [Gateshead Council](/doc/source/gateshead_gov_uk.md) / gateshead.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
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from datetime import datetime
|
||||
|
||||
TITLE = "Fife Council"
|
||||
DESCRIPTION = "Source for Fife Council."
|
||||
URL = "https://www.fife.gov.uk"
|
||||
TEST_CASES = {
|
||||
"SANDYHILL ROAD, ST ANDREWS": {"uprn": 320069186},
|
||||
"CERES ROAD, PITSCOTTIE" : {"uprn": 320063641},
|
||||
"SHORE ROAD, BALMALCOLM": {"uprn": "320083539"},
|
||||
"CANMORE STREET, DUNFERMLINE": {"uprn": "320101510"},
|
||||
}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"Blue": "mdi:trash-can",
|
||||
"Glass": "mdi:bottle-soda",
|
||||
"Brown": "mdi:leaf",
|
||||
"Grey": "mdi:package-variant",
|
||||
"Green": "mdi:recycle",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://www.fife.gov.uk/api/custom"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn: str | int):
|
||||
self._uprn: str | int = str(uprn)
|
||||
|
||||
def fetch(self):
|
||||
session = requests.Session()
|
||||
auth = session.get("https://www.fife.gov.uk/api/citizen?preview=false&locale=en").headers["Authorization"]
|
||||
session.headers.update({"Authorization": auth})
|
||||
|
||||
args = {
|
||||
"name": "bin_calendar",
|
||||
"data": {"uprn": self._uprn},
|
||||
}
|
||||
|
||||
params = {
|
||||
"action": "powersuite_bin_calendar_collections",
|
||||
"actionedby": "bin_calendar",
|
||||
"loadform": True,
|
||||
"access": "citizen",
|
||||
"locale": "en",
|
||||
}
|
||||
|
||||
# get json file
|
||||
r = session.post(API_URL, params=params, json=args)
|
||||
r.raise_for_status()
|
||||
|
||||
data = r.json()["data"]
|
||||
if data["results_returned"] == "false":
|
||||
raise Exception("No results returned")
|
||||
|
||||
entries = []
|
||||
for d in data["tab_collections"]:
|
||||
date = datetime.strptime(d["date"], "%A, %B %d, %Y").date()
|
||||
icon = ICON_MAP.get(d["colour"]) # Collection icon
|
||||
type = d["type"]
|
||||
entries.append(Collection(date=date, t=type, icon=icon))
|
||||
|
||||
return entries
|
||||
35
doc/source/fife_gov_uk.md
Normal file
35
doc/source/fife_gov_uk.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Fife Council
|
||||
|
||||
Support for schedules provided by [Fife Council](https://www.fife.gov.uk), serving Fife Council, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: fife_gov_uk
|
||||
args:
|
||||
uprn: "UPRN"
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**
|
||||
*(String | Integer) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: fife_gov_uk
|
||||
args:
|
||||
uprn: "320069189"
|
||||
|
||||
```
|
||||
|
||||
### 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 Fife Council website makes when entering in your postcode and then selecting your address.
|
||||
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, 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, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire 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, FCC Environment, Fenland District 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 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, 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, 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, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire 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, 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 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, 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, 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 Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
<!--End of country section-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user