mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Add dorset_gov_uk (#2659)
* Create dorset_gov_uk.md * Create dorset_gov_uk.py * Added Dorset Council * Fixed data colleection Date format was wrong + JSON data was embedded more * Fixed no data returned when specific bin not used * refromatting * ./update_docu_links.py --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
@@ -1630,6 +1630,7 @@ If your service provider is not listed, feel free to open a [source request issu
|
|||||||
- [Denbighshire County Council](/doc/source/denbighshire_gov_uk.md) / denbighshire.gov.uk
|
- [Denbighshire County Council](/doc/source/denbighshire_gov_uk.md) / denbighshire.gov.uk
|
||||||
- [Deprecated: Buckinghamshire](/doc/source/chiltern_gov_uk.md) / chiltern.gov.uk
|
- [Deprecated: Buckinghamshire](/doc/source/chiltern_gov_uk.md) / chiltern.gov.uk
|
||||||
- [Derby City Council](/doc/source/derby_gov_uk.md) / derby.gov.uk
|
- [Derby City Council](/doc/source/derby_gov_uk.md) / derby.gov.uk
|
||||||
|
- [Dorset Council](/doc/source/dorset_gov_uk.md) / dorsetcouncil.gov.uk
|
||||||
- [Dover District Council](/doc/source/dover_gov_uk.md) / dover.gov.uk
|
- [Dover District Council](/doc/source/dover_gov_uk.md) / dover.gov.uk
|
||||||
- [Dudley Metropolitan Borough Council](/doc/source/dudley_gov_uk.md) / dudley.gov.uk
|
- [Dudley Metropolitan Borough Council](/doc/source/dudley_gov_uk.md) / dudley.gov.uk
|
||||||
- [Durham County Council](/doc/source/durham_gov_uk.md) / durham.gov.uk
|
- [Durham County Council](/doc/source/durham_gov_uk.md) / durham.gov.uk
|
||||||
|
|||||||
@@ -10438,6 +10438,12 @@
|
|||||||
"default_params": {},
|
"default_params": {},
|
||||||
"id": "derby_gov_uk"
|
"id": "derby_gov_uk"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "Dorset Council",
|
||||||
|
"module": "dorset_gov_uk",
|
||||||
|
"default_params": {},
|
||||||
|
"id": "dorset_gov_uk"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Dover District Council",
|
"title": "Dover District Council",
|
||||||
"module": "dover_gov_uk",
|
"module": "dover_gov_uk",
|
||||||
|
|||||||
@@ -15308,6 +15308,29 @@
|
|||||||
"data_description": {
|
"data_description": {
|
||||||
"calendar_title": "Ein lesbarerer oder benutzerfreundlicherer Name für den Müllkalender. Wenn nichts angegeben wird, wird der Name der Quelle verwendet."
|
"calendar_title": "Ein lesbarerer oder benutzerfreundlicherer Name für den Müllkalender. Wenn nichts angegeben wird, wird der Name der Quelle verwendet."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"args_dorset_gov_uk": {
|
||||||
|
"title": "Quelle konfigurieren",
|
||||||
|
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/dorset_gov_uk.md",
|
||||||
|
"data": {
|
||||||
|
"calendar_title": "Kalender Titel",
|
||||||
|
"uprn": "UPRN"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"calendar_title": "Ein lesbarerer oder benutzerfreundlicherer Name für den Müllkalender. Wenn nichts angegeben wird, wird der Name der Quelle verwendet.",
|
||||||
|
"uprn": "Eine einfache Möglichkeit, Ihre Unique Property Reference Number (UPRN) zu finden, besteht darin, auf https://www.findmyaddress.co.uk/ zu gehen und Ihre Adressdaten einzugeben."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"reconfigure_dorset_gov_uk": {
|
||||||
|
"title": "Quelle Neu Konfigurieren",
|
||||||
|
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/dorset_gov_uk.md",
|
||||||
|
"data": {
|
||||||
|
"calendar_title": "Kalender Titel",
|
||||||
|
"uprn": "UPRN"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"uprn": "Eine einfache Möglichkeit, Ihre Unique Property Reference Number (UPRN) zu finden, besteht darin, auf https://www.findmyaddress.co.uk/ zu gehen und Ihre Adressdaten einzugeben."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
|
|||||||
@@ -15308,6 +15308,29 @@
|
|||||||
"data_description": {
|
"data_description": {
|
||||||
"calendar_title": "A more readable, or user-friendly, name for the waste calendar. If nothing is provided, the name returned by the source will be used."
|
"calendar_title": "A more readable, or user-friendly, name for the waste calendar. If nothing is provided, the name returned by the source will be used."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"args_dorset_gov_uk": {
|
||||||
|
"title": "Configure Source",
|
||||||
|
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/dorset_gov_uk.md.",
|
||||||
|
"data": {
|
||||||
|
"calendar_title": "Calendar Title",
|
||||||
|
"uprn": "UPRN"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"calendar_title": "A more readable, or user-friendly, name for the waste calendar. If nothing is provided, the name returned by the source will be used.",
|
||||||
|
"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."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"reconfigure_dorset_gov_uk": {
|
||||||
|
"title": "Reconfigure Source",
|
||||||
|
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/dorset_gov_uk.md.",
|
||||||
|
"data": {
|
||||||
|
"calendar_title": "Calendar Title",
|
||||||
|
"uprn": "UPRN"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"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."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
|
|||||||
@@ -15294,6 +15294,29 @@
|
|||||||
"address": "Address"
|
"address": "Address"
|
||||||
},
|
},
|
||||||
"data_description": {}
|
"data_description": {}
|
||||||
|
},
|
||||||
|
"args_dorset_gov_uk": {
|
||||||
|
"title": "Configurazione Sorgente",
|
||||||
|
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/dorset_gov_uk.md.",
|
||||||
|
"data": {
|
||||||
|
"calendar_title": "Nome Calendario",
|
||||||
|
"uprn": "UPRN"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"calendar_title": "Puoi cambiare il nome del calendario della raccolta dei rifiuti, altrimenti di default verra' utilizzato il nome del tuo fornitore di servizi.",
|
||||||
|
"uprn": "Un modo facile per scoprire il tuo Numero di Riferimento Proprietà Unica (UPRN) è andare su https://www.findmyaddress.co.uk/ e inserire i dettagli del tuo indirizzo."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"reconfigure_dorset_gov_uk": {
|
||||||
|
"title": "Riconfigurazione Sorgente",
|
||||||
|
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Per maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/dorset_gov_uk.md.",
|
||||||
|
"data": {
|
||||||
|
"calendar_title": "Nome Calendario",
|
||||||
|
"uprn": "UPRN"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"uprn": "Un modo facile per scoprire il tuo Numero di Riferimento Proprietà Unica (UPRN) è andare su https://www.findmyaddress.co.uk/ e inserire i dettagli del tuo indirizzo."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
TITLE = "Dorset Council"
|
||||||
|
DESCRIPTION = "The local authority for the non-metropolitan county of Dorset in England"
|
||||||
|
URL = "https://www.dorsetcouncil.gov.uk/"
|
||||||
|
TEST_CASES = {
|
||||||
|
"Test_001": {"uprn": 100040606062},
|
||||||
|
"Test_002": {"uprn": 100040606087},
|
||||||
|
"Test_003": {"uprn": "100040606071"},
|
||||||
|
}
|
||||||
|
ICON_MAP = {
|
||||||
|
"Recycling": "mdi:recycle",
|
||||||
|
"Rubbish": "mdi:trash-can",
|
||||||
|
"Garden Waste": "mdi:leaf",
|
||||||
|
"Food Waste": "mdi:food",
|
||||||
|
}
|
||||||
|
|
||||||
|
API_URLS = {
|
||||||
|
"Recycling": "https://geoapi.dorsetcouncil.gov.uk/v1/Services/recyclingday/{uprn}",
|
||||||
|
"Rubbish": "https://geoapi.dorsetcouncil.gov.uk/v1/Services/refuseday/{uprn}",
|
||||||
|
"Garden Waste": "https://geoapi.dorsetcouncil.gov.uk/v1/Services/gardenwasteday/{uprn}",
|
||||||
|
"Food Waste": "https://geoapi.dorsetcouncil.gov.uk/v1/Services/foodwasteday/{uprn}",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Source:
|
||||||
|
def __init__(self, uprn: str | int):
|
||||||
|
self._uprn: str = str(uprn)
|
||||||
|
|
||||||
|
def fetch(self):
|
||||||
|
entries = []
|
||||||
|
for bin, url in API_URLS.items():
|
||||||
|
r = requests.get(url.format(uprn=self._uprn))
|
||||||
|
json_data = json.loads(r.content)
|
||||||
|
try:
|
||||||
|
date = datetime.strptime(
|
||||||
|
json_data["values"][0]["dateNextVisit"], "%Y-%m-%d"
|
||||||
|
).date()
|
||||||
|
|
||||||
|
entries.append(
|
||||||
|
Collection(
|
||||||
|
date=date,
|
||||||
|
t=bin,
|
||||||
|
icon=ICON_MAP.get(bin),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except (
|
||||||
|
IndexError
|
||||||
|
): # If a specific bin is not used at address (e.g. Garden waste)
|
||||||
|
pass
|
||||||
|
|
||||||
|
return entries
|
||||||
32
doc/source/dorset_gov_uk.md
Normal file
32
doc/source/dorset_gov_uk.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Dorset Council
|
||||||
|
|
||||||
|
Support for schedules provided by [Dorset Council](https://www.dorsetcouncil.gov.uk), The local authority for the non-metropolitan county of Dorset in England.
|
||||||
|
|
||||||
|
## Configuration via configuration.yaml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waste_collection_schedule:
|
||||||
|
sources:
|
||||||
|
- name: dorset_gov_uk
|
||||||
|
args:
|
||||||
|
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Variables
|
||||||
|
|
||||||
|
**uprn**
|
||||||
|
*(string) (required)*
|
||||||
|
|
||||||
|
## Example using UPRN
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waste_collection_schedule:
|
||||||
|
sources:
|
||||||
|
- name: dorset_gov_uk
|
||||||
|
args:
|
||||||
|
uprn: "100040606062"
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to get the source argument
|
||||||
|
|
||||||
|
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.
|
||||||
Reference in New Issue
Block a user