Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Source: Folkestone & Hythe, UK #2733

Merged
merged 10 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [Fenland District Council](/doc/source/fenland_gov_uk.md) / fenland.gov.uk
- [Fife Council](/doc/source/fife_gov_uk.md) / fife.gov.uk
- [Flintshire](/doc/source/flintshire_gov_uk.md) / flintshire.gov.uk
- [Folkestone and Hythe District Councol](/doc/source/folkestone_hythe_gov_uk.md) / folkestone-hythe.gov.uk
- [Fylde Council](/doc/source/fylde_gov_uk.md) / fylde.gov.uk
- [Gateshead Council](/doc/source/gateshead_gov_uk.md) / gateshead.gov.uk
- [Gedling Borough Council (unofficial)](/doc/ics/gedling_gov_uk.md) / gbcbincalendars.co.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 @@ -10756,6 +10756,12 @@
"default_params": {},
"id": "flintshire_gov_uk"
},
{
"title": "Folkestone and Hythe District Councol",
"module": "folkestone_hythe_gov_uk",
"default_params": {},
"id": "folkestone_hythe_gov_uk"
},
{
"title": "Fylde Council",
"module": "fylde_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 @@ -15660,6 +15660,29 @@
},
"data_description": {}
},
"args_folkestone_hythe_gov_uk": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/folkestone_hythe_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_folkestone_hythe_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/folkestone_hythe_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_wastecollection_mt": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/wastecollection_mt.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 @@ -15660,6 +15660,29 @@
},
"data_description": {}
},
"args_folkestone_hythe_gov_uk": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/folkestone_hythe_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_folkestone_hythe_gov_uk": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/folkestone_hythe_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."
}
},
"args_wastecollection_mt": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/wastecollection_mt.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 @@ -15635,6 +15635,29 @@
},
"data_description": {}
},
"args_folkestone_hythe_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/folkestone_hythe_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_folkestone_hythe_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/folkestone_hythe_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_wastecollection_mt": {
"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/wastecollection_mt.md.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from datetime import datetime
import re
import requests
from bs4 import BeautifulSoup

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

TITLE = "Folkestone and Hythe District Councol"
DESCRIPTION = "Source for Folkestone and Hythe District Council, United Kingdom."
URL = "https://www.folkestone-hythe.gov.uk/"
TEST_CASES = {
"Folkestone_Test": {"uprn": 50032102},
"Hythe_Test": {"uprn": "50019287"},
}
ICON_MAP = {
"Non-Recyclables (Green Lid) and Food Waste": "mdi:trash-can",
"Recycling (Purple Lid / Black Box and Food Waste)": "mdi:recycle",
}
REGEX_ORDINALS = r"(st|nd|rd|th)"


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

def fetch(self):

s = requests.Session()
r = s.get(
f"https://service.folkestone-hythe.gov.uk/webapp/myarea/index.php?uprn={self._uprn}"
)
r.raise_for_status()

soup = BeautifulSoup(r.text, "html.parser")
bin_tab = soup.findAll("div", {"id": "bincollections"})
waste_types = bin_tab[0].findAll("span", {"class": "bold"})
schedules = bin_tab[0].findAll("ul")

entries = []

for idx, item in enumerate(waste_types):
for li in schedules[idx].findAll("li"):
entries.append(
Collection(
date=datetime.strptime(
re.compile(REGEX_ORDINALS).sub("", li.text), "%A %d %B %Y"
dt215git marked this conversation as resolved.
Show resolved Hide resolved
).date(),
t=item.text,
icon=ICON_MAP.get(item.text),
)
)

return entries
36 changes: 36 additions & 0 deletions doc/source/folkestone_hythe_gov_uk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Folkestone & Hythe District Council, United Kingdom

Support for schedules provided by [Folkestone & Hythe District Council, United Kingdom](https://www.folkestone-hythe.gov.uk/recycling-waste-bins).

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: folkestone_hythe_gov_uk
args:
uprn: "UPRN"

```

### Configuration Variables

**uprn**
*(String | Integer) (required)*


## Example

```yaml
waste_collection_schedule:
sources:
- name: folkestone_hythe_gov_uk
args:
uprn: "50032102"

```

## How to get the source argument

Your UPRN is displayed on the council web site underneath your address when it displays your bin collection shedule.
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.
Loading