Add Huntingdonshire District Council

Signed-off-by: Johnnie Blows <johnnie.blows@gmail.com>
This commit is contained in:
Johnnie Blows
2022-07-02 22:32:33 +01:00
parent 4c91bd94be
commit 5421b0f5ba
2 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import json
from datetime import datetime
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "York.gov.uk"
DESCRIPTION = "Source for Huntingdonshire.gov.uk services for Huntingdonshire District Council."
URL = "https://york.gov.uk"
TEST_CASES = {
"Wells Close, Brampton": {"uprn": "100090123510"},
"Inkerman Rise, St. Neots": {"uprn": "10000144271"},
}
ICONS = {
"Refuse": "mdi:trash-can",
"Recycling": "mdi:recycle",
"Garden": "mdi:leaf",
}
class Source:
def __init__(self, uprn):
self._uprn = uprn
def fetch(self):
# get json file
r = requests.get(
f"https://servicelayer3c.azure-api.net/wastecalendar/collection/search/{self._uprn}?authority=HDC&take=20"
)
# extract data from json
data = json.loads(r.text)
entries = []
collections = r.json()["collections"]
entries = []
for collection in collections:
for round_type in collection["roundTypes"]:
entries.append(
Collection(
date=datetime.strptime(
collection["date"], "%Y-%m-%dT%H:%M:%SZ"
).date(),
t=round_type.title(),
icon=ICONS.get(round_type),
)
)
return entries

View File

@@ -0,0 +1,32 @@
# Huntingdonshire District Council
Support for schedules provided by [Huntingdonshire District Council](https://www.huntingdonshire.gov.uk/refuse-calendar), serving Huntingdonshire, UK.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: huntingdonshire_gov_uk
args:
uprn: UPRN_CODE
```
### Configuration Variables
**uprn**<br>
*(string) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: huntingdonshire_gov_uk
args:
uprn: "100050580641"
```
## How to get the source argument
The UPRN code can be found in the network request when entering your postcode and selecting your address on the [Huntingdonshire Waste Collection Calendar page](https://www.huntingdonshire.gov.uk/refuse-calendar/). You should look for a request like `https://www.huntingdonshire.gov.uk/refuse-calendar/100090123510` the last segment is your UPRN code.