Skip to content

Commit

Permalink
New Source: Oldham, UK (#3314)
Browse files Browse the repository at this point in the history
* initial commit

* .md added

* GUI details added

* update_docu_links

---------

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
  • Loading branch information
dt215git and 5ila5 authored Dec 28, 2024
1 parent 03ec1a9 commit 7f7b359
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [North Yorkshire Council - Selby](/doc/source/northyorks_selby_gov_uk.md) / northyorks.gov.uk
- [Nottingham City Council](/doc/source/nottingham_city_gov_uk.md) / nottinghamcity.gov.uk
- [Oadby and Wigston Council](/doc/source/oadby_wigston_gov_uk.md) / oadby-wigston.gov.uk
- [Oldham Council](/doc/source/oldham_gov_uk.md) / oldham.gov.uk
- [Oxford City Council](/doc/source/oxford_gov_uk.md) / oxford.gov.uk
- [Pembrokeshire County Council](/doc/source/pembrokeshire_gov_uk.md) / pembrokeshire.gov.uk
- [Peterborough City Council](/doc/source/peterborough_gov_uk.md) / peterborough.gov.uk
Expand Down
6 changes: 6 additions & 0 deletions custom_components/waste_collection_schedule/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -13740,6 +13740,12 @@
"default_params": {},
"id": "oadby_wigston_gov_uk"
},
{
"title": "Oldham Council",
"module": "oldham_gov_uk",
"default_params": {},
"id": "oldham_gov_uk"
},
{
"title": "Oxford City Council",
"module": "oxford_gov_uk",
Expand Down
23 changes: 23 additions & 0 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -15389,6 +15389,29 @@
},
"data_description": {}
},
"args_oldham_gov_uk": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\nan 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.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oldham_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_oldham_gov_uk": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\nan 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.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oldham_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."
}
},
"args_oxford_gov_uk": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oxford_gov_uk.md",
Expand Down
23 changes: 23 additions & 0 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15421,6 +15421,29 @@
},
"data_description": {}
},
"args_oldham_gov_uk": {
"title": "Configure Source",
"description": "Configure your service provider. \n\nan 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.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oldham_gov_uk.md.",
"data": {
"calendar_title": "Calendar Title",
"uprn": "Unique Property Reference Number (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": "Unique Property Reference Number (UPRN)"
}
},
"reconfigure_oldham_gov_uk": {
"title": "Reconfigure Source",
"description": "Configure your service provider. \n\nan 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.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oldham_gov_uk.md.",
"data": {
"calendar_title": "Calendar Title",
"uprn": "Unique Property Reference Number (UPRN)"
},
"data_description": {
"uprn": "Unique Property Reference Number (UPRN)"
}
},
"args_oxford_gov_uk": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oxford_gov_uk.md.",
Expand Down
23 changes: 23 additions & 0 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -15371,6 +15371,29 @@
},
"data_description": {}
},
"args_oldham_gov_uk": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nan 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.\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oldham_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_oldham_gov_uk": {
"title": "Riconfigurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nan 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.\n\nPer maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/oldham_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."
}
},
"args_oxford_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/oxford_gov_uk.md.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from datetime import datetime

import requests
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection # type: ignore[attr-defined]

TITLE = "Oldham Council"
DESCRIPTION = "Source for Oldham Council."
URL = "https://oldham.gov.uk/"
TEST_CASES = {
"Test_001": {"uprn": 422000125973},
"Test_002": {"uprn": "422000129104"},
"Test_003": {"uprn": 422000042299},
}
ICON_MAP = {
"Brown": "mdi:recycle",
"Green": "mdi:leaf",
"Grey": "mdi:trash-can",
"Blue": "mdi:newspaper",
}
HOW_TO_GET_ARGUMENTS_DESCRIPTION = {
"en": "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.",
}

PARAM_TRANSLATIONS = {
"en": {
"uprn": "Unique Property Reference Number (UPRN)",
}
}

PARAM_DESCRIPTIONS = {
"en": {
"uprn": "Unique Property Reference Number (UPRN)",
}
}


class Source:
def __init__(self, uprn: str | int):
self._uprn = str(uprn)

def fetch(self):
s = requests.session()
r = s.get(
f"https://portal.oldham.gov.uk/bincollectiondates/details?uprn={self._uprn}"
)
r.raise_for_status

soup = BeautifulSoup(r.content, "html.parser")
pickups: list = soup.find_all("table", {"class": "data-table confirmation"})

entries: list = []
for item in pickups:
w: str = item.find("th")
d: str = item.find("td", {"class": "coltwo"})
entries.append(
Collection(
date=datetime.strptime(d.text.strip(), "%d/%m/%Y").date(),
t=w.text.strip(),
icon=ICON_MAP.get(w.text.strip()),
)
)

return entries
31 changes: 31 additions & 0 deletions doc/source/oldham_gov_uk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Oldham Council

Support for schedules provided by [Oldham Council](https://www.oldham.gov.uk/), in the UK.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: oldham_gov_uk
args:
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER
```
### Configuration Variables
**uprn**<br>
*(string)*
The "Unique Property Reference Number" for your address. You can find it by searching for your address at https://www.findmyaddress.co.uk/.
## Example
```yaml
waste_collection_schedule:
sources:
- name: oldham_gov_uk
args:
uprn: "422000129104"
```
Loading

0 comments on commit 7f7b359

Please sign in to comment.