Skip to content

Commit

Permalink
Added Pembrokeshire County Council (mampfes#2755)
Browse files Browse the repository at this point in the history
* Added api calls to find bin dates

* Added markdown file

* Updated README and info markdown files

* Added dict of better formatted bin types

* Correcting bin type strings to fit other formatting

* Changed from using eval to literal_eval

* reformatting + ./update_docu_links.py

---------

Co-authored-by: 5ila5 <[email protected]>
  • Loading branch information
Pricey1600 and 5ila5 authored Sep 27, 2024
1 parent eaab185 commit 5e17519
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [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
- [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
- [Portsmouth City Council](/doc/source/portsmouth_gov_uk.md) / portsmouth.gov.uk
- [Reading Council](/doc/source/reading_gov_uk.md) / reading.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 @@ -11214,6 +11214,12 @@
"default_params": {},
"id": "oxford_gov_uk"
},
{
"title": "Pembrokeshire County Council",
"module": "pembrokeshire_gov_uk",
"default_params": {},
"id": "pembrokeshire_gov_uk"
},
{
"title": "Peterborough City Council",
"module": "peterborough_gov_uk",
Expand Down
39 changes: 31 additions & 8 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -15703,25 +15703,28 @@
},
"data_description": {}
},
"args_roundrocktexas_gov": {
"args_pembrokeshire_gov_uk": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md",
"description": "Konfiguriere deinen Service Provider. \n\nTo get your UPRN go to https://www.findmyaddress.co.uk and search for your address.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pembrokeshire_gov_uk.md",
"data": {
"calendar_title": "Kalender Titel",
"neighborhood": "Neighborhood"
"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."
"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_roundrocktexas_gov": {
"reconfigure_pembrokeshire_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/roundrocktexas_gov.md",
"description": "Konfiguriere deinen Service Provider. \n\nTo get your UPRN go to https://www.findmyaddress.co.uk and search for your address.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pembrokeshire_gov_uk.md",
"data": {
"calendar_title": "Kalender Titel",
"neighborhood": "Neighborhood"
"uprn": "UPRN"
},
"data_description": {}
"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_gfa_lueneburg_de": {
"title": "Quelle konfigurieren",
Expand Down Expand Up @@ -15770,6 +15773,26 @@
"street": "Straße"
},
"data_description": {}
},
"args_roundrocktexas_gov": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md",
"data": {
"calendar_title": "Kalender Titel",
"neighborhood": "Neighborhood"
},
"data_description": {
"calendar_title": "Ein lesbarerer oder benutzerfreundlicherer Name für den Müllkalender. Wenn nichts angegeben wird, wird der Name der Quelle verwendet."
}
},
"reconfigure_roundrocktexas_gov": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md",
"data": {
"calendar_title": "Kalender Titel",
"neighborhood": "Neighborhood"
},
"data_description": {}
}
},
"error": {
Expand Down
39 changes: 31 additions & 8 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15706,25 +15706,28 @@
},
"data_description": {}
},
"args_roundrocktexas_gov": {
"args_pembrokeshire_gov_uk": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md.",
"description": "Configure your service provider. \n\nTo get your UPRN go to https://www.findmyaddress.co.uk and search for your address.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pembrokeshire_gov_uk.md.",
"data": {
"calendar_title": "Calendar Title",
"neighborhood": "Neighborhood"
"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."
"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_roundrocktexas_gov": {
"reconfigure_pembrokeshire_gov_uk": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md.",
"description": "Configure your service provider. \n\nTo get your UPRN go to https://www.findmyaddress.co.uk and search for your address.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pembrokeshire_gov_uk.md.",
"data": {
"calendar_title": "Calendar Title",
"neighborhood": "Neighborhood"
"uprn": "UPRN"
},
"data_description": {}
"data_description": {
"uprn": "Unique Property Reference Number (UPRN)"
}
},
"args_gfa_lueneburg_de": {
"title": "Configure Source",
Expand Down Expand Up @@ -15773,6 +15776,26 @@
"street": "Street"
},
"data_description": {}
},
"args_roundrocktexas_gov": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md.",
"data": {
"calendar_title": "Calendar Title",
"neighborhood": "Neighborhood"
},
"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."
}
},
"reconfigure_roundrocktexas_gov": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/roundrocktexas_gov.md.",
"data": {
"calendar_title": "Calendar Title",
"neighborhood": "Neighborhood"
},
"data_description": {}
}
},
"error": {
Expand Down
39 changes: 31 additions & 8 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -15678,25 +15678,28 @@
},
"data_description": {}
},
"args_roundrocktexas_gov": {
"args_pembrokeshire_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/roundrocktexas_gov.md.",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nTo get your UPRN go to https://www.findmyaddress.co.uk and search for your address.\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pembrokeshire_gov_uk.md.",
"data": {
"calendar_title": "Nome Calendario",
"neighborhood": "Neighborhood"
"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."
"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_roundrocktexas_gov": {
"reconfigure_pembrokeshire_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/roundrocktexas_gov.md.",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nTo get your UPRN go to https://www.findmyaddress.co.uk and search for your address.\n\nPer maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pembrokeshire_gov_uk.md.",
"data": {
"calendar_title": "Nome Calendario",
"neighborhood": "Neighborhood"
"uprn": "UPRN"
},
"data_description": {}
"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_gfa_lueneburg_de": {
"title": "Configurazione Sorgente",
Expand Down Expand Up @@ -15745,6 +15748,26 @@
"street": "Via/Piazza/Corso"
},
"data_description": {}
},
"args_roundrocktexas_gov": {
"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/roundrocktexas_gov.md.",
"data": {
"calendar_title": "Nome Calendario",
"neighborhood": "Neighborhood"
},
"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."
}
},
"reconfigure_roundrocktexas_gov": {
"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/roundrocktexas_gov.md.",
"data": {
"calendar_title": "Nome Calendario",
"neighborhood": "Neighborhood"
},
"data_description": {}
}
},
"error": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import ast
from datetime import datetime

import requests
from waste_collection_schedule import Collection

TITLE = "Pembrokeshire County Council" # Title will show up in README.md and info.md
DESCRIPTION = "Source script for pembrokeshire.gov.uk" # Describe your source
URL = "https://www.pembrokeshire.gov.uk/" # Insert url to service homepage. URL will show up in README.md and info.md
TEST_CASES = { # Insert arguments for test cases to be used by test_sources.py script
"Dew Street": {"uprn": "100100283349"},
"Heol Cleddau": {"uprn": "100100281816"},
}

API_URL = "https://www.pembrokeshire.gov.uk/template/waste/api.asp"

TYPE_MAP = { # Dict of waste formatted bin types
"FOODCAD": "GREEN CADDY",
"BLUEBOX": "BLUE BOX",
"GREENBOX": "GREEN BOX",
"BLUEBAG": "BLUE BAG",
"REDBAG": "RED BAG",
"GREYBAG": "BLACK/GREY BAGS",
}
ICON_MAP = { # Optional: Dict of waste types and suitable mdi icons
"FOODCAD": "mdi:food-apple",
"BLUEBOX": "mdi:note-multiple",
"GREENBOX": "mdi:glass-fragile",
"BLUEBAG": "mdi:recycle",
"REDBAG": "mdi:recycle",
"GREYBAG": "mdi:trash-can",
}

# ### Arguments affecting the configuration GUI ####

HOW_TO_GET_ARGUMENTS_DESCRIPTION = { # Optional dictionary to describe how to get the arguments, will be shown in the GUI configuration form above the input fields, does not need to be translated in all languages
"en": "To get your UPRN go to https://www.findmyaddress.co.uk and search for your address.",
}

PARAM_DESCRIPTIONS = { # Optional dict to describe the arguments, will be shown in the GUI configuration below the respective input field
"en": {
"uprn": "Unique Property Reference Number (UPRN)",
},
}

# ### End of arguments affecting the configuration GUI ####


class Source:
def __init__(
self, uprn: str
): # argX correspond to the args dict in the source configuration
self._uprn = uprn

def fetch(self) -> list[Collection]:
session = requests.Session()

form_data = {
"action": "dates",
"public": "true",
"uprn": self._uprn,
"language": "eng",
}

collection_response = session.post(API_URL, params=form_data)

if ast.literal_eval(collection_response.text)["error"] == "true":
raise Exception("No collections found for the given UPRN.")

entries = [] # List that holds collection schedule

bin_dates = ast.literal_eval(collection_response.text)["bins"]
for bin in bin_dates:
date_string = bin["nextdate"]
date_format = "%d/%m/%Y"
date = datetime.strptime(date_string, date_format).date()
bin_type = bin["type"]

entries.append(
Collection(
date=date, # Collection date
t=TYPE_MAP.get(bin_type), # Collection type
icon=ICON_MAP.get(bin_type), # Collection icon
)
)

return entries
56 changes: 56 additions & 0 deletions doc/source/pembrokeshire_gov_uk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Pembrokeshire County Council

Bin collection schedules provided by [Pembrokeshire County Council](https://www.pembrokeshire.gov.uk/) in Wales, UK.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: pembrokeshire_gov_uk
args:
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER
```

### Configuration Variables

**UPRN**
*(string)(required)*

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: pembrokeshire_gov_uk
args:
uprn: "100100283349"
```

## Returned collection types

### Food

Green Caddy for food recycling

### Paper

Blue Box for paper recycling

### Glass

Green box for glass recycling

### Cardboard

Blue Bag for cardboard recycling

### Plastics

Red Bag for plastics recycling

### Non-Recyclables

Black/Grey Bags for non-recyclable waste
Loading

0 comments on commit 5e17519

Please sign in to comment.