Skip to content

Commit

Permalink
New Source: Shire of Mundaring (#2848)
Browse files Browse the repository at this point in the history
* different date formates handled

* test cases added

* arg details added

* .md added,  arg text made consistent

* updaet doculinks

* pre-commit installed into venv
  • Loading branch information
dt215git authored Oct 18, 2024
1 parent d6a2ade commit 56d9db0
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [Renmark Paringa Council](/doc/source/app_my_local_services_au.md) / renmarkparinga.sa.gov.au
- [Rural City of Murray Bridge](/doc/source/app_my_local_services_au.md) / murraybridge.sa.gov.au
- [Shellharbour City Council](/doc/source/shellharbourwaste_com_au.md) / shellharbourwaste.com.au
- [Shire of Mundaring](/doc/source/mundaring_wa_gov_au.md) / wwwhttps://www.mundaring.wa.gov.au
- [Snowy Valleys Council](/doc/source/impactapps_com_au.md) / snowyvalleys.nsw.gov.au
- [South Burnett Regional Council](/doc/source/impactapps_com_au.md) / southburnett.qld.gov.au
- [Southern Mallee District Council](/doc/source/app_my_local_services_au.md) / southernmallee.sa.gov.au
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 @@ -680,6 +680,12 @@
"default_params": {},
"id": "shellharbourwaste_com_au"
},
{
"title": "Shire of Mundaring",
"module": "mundaring_wa_gov_au",
"default_params": {},
"id": "mundaring_wa_gov_au"
},
{
"title": "Snowy Valleys Council",
"module": "impactapps_com_au",
Expand Down
22 changes: 22 additions & 0 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,28 @@
},
"data_description": {}
},
"args_mundaring_wa_gov_au": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\nAn easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mundaring_wa_gov_au.md",
"data": {
"calendar_title": "Kalender Titel",
"parcel_number": "Parcel Number",
"suburb": "Suburb"
},
"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_mundaring_wa_gov_au": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\nAn easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mundaring_wa_gov_au.md",
"data": {
"calendar_title": "Kalender Titel",
"parcel_number": "Parcel Number",
"suburb": "Suburb"
},
"data_description": {}
},
"args_stirling_wa_gov_au": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/stirling_wa_gov_au.md",
Expand Down
25 changes: 25 additions & 0 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,31 @@
},
"data_description": {}
},
"args_mundaring_wa_gov_au": {
"title": "Configure Source",
"description": "Configure your service provider. \n\nAn easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mundaring_wa_gov_au.md.",
"data": {
"calendar_title": "Calendar Title",
"parcel_number": "A number that uniquely identifies your property.",
"suburb": "Suburb"
},
"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.",
"parcel_number": "An easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number."
}
},
"reconfigure_mundaring_wa_gov_au": {
"title": "Reconfigure Source",
"description": "Configure your service provider. \n\nAn easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mundaring_wa_gov_au.md.",
"data": {
"calendar_title": "Calendar Title",
"parcel_number": "A number that uniquely identifies your property.",
"suburb": "Suburb"
},
"data_description": {
"parcel_number": "An easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number."
}
},
"args_stirling_wa_gov_au": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/stirling_wa_gov_au.md.",
Expand Down
22 changes: 22 additions & 0 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,28 @@
},
"data_description": {}
},
"args_mundaring_wa_gov_au": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nAn easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mundaring_wa_gov_au.md.",
"data": {
"calendar_title": "Nome Calendario",
"parcel_number": "Parcel Number",
"suburb": "Suburb"
},
"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_mundaring_wa_gov_au": {
"title": "Riconfigurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nAn easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.\n\nPer maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mundaring_wa_gov_au.md.",
"data": {
"calendar_title": "Nome Calendario",
"parcel_number": "Parcel Number",
"suburb": "Suburb"
},
"data_description": {}
},
"args_stirling_wa_gov_au": {
"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/stirling_wa_gov_au.md.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from datetime import datetime

import requests
from bs4 import BeautifulSoup
from dateutil.rrule import FR, MO, SA, SU, TH, TU, WE, WEEKLY, rrule
from waste_collection_schedule import Collection # type: ignore[attr-defined]

TITLE = "Shire of Mundaring"
DESCRIPTION = "Source for mundaring.wa.gov.au services for the Shire of Mundaring, Western Australia"
URL = "https://wwwhttps://www.mundaring.wa.gov.au/"
TEST_CASES = {
"Test_001": {"parcel_number": 103239, "suburb": "Helena Valley"},
"Test_002": {"parcel_number": "100119", "suburb": "Swan View"},
"Test_003": {"parcel_number": 1119284, "suburb": "Glen Forrest"},
}
ICON_MAP = {
"FOGO Bin": "mdi:leaf",
"Recycle Bin": "mdi:recycle",
"General Waste": "mdi:trash-can",
"Bulk Verge Collection": "mdi:sofa",
}
HEADERS = {
"user-agent": "Mozilla/5.0",
}
DAYS = {
"Monday": MO,
"Tuesday": TU,
"Wednesday": WE,
"Thursday": TH,
"Friday": FR,
"Saturday": SA,
"Sunday": SU,
}
HOW_TO_GET_ARGUMENTS_DESCRIPTION = {
"en": "An easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.",
}
PARAM_TRANSLATIONS = {
"en": {
"parcel_number": "A number that uniquely identifies your property.",
}
}
PARAM_DESCRIPTIONS = {
"en": {
"parcel_number": "An easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the Property Map to search for your address ensuring both Lot Numbers and House Number checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.",
}
}


class Source:
def __init__(self, parcel_number: str | int, suburb: str):
self._parcel_number = str(parcel_number)
self._suburb = str(suburb).upper()

def tidytext(self, lst: list) -> list:
temp_list = [
txt.replace("\r\n ", "").replace("\r\n", "").strip()
for txt in lst
]
return temp_list

def fetch(self):
s = requests.Session()

params = {"parcelNumber": self._parcel_number, "suburb": self._suburb}
r = s.get(
"https://my.mundaring.wa.gov.au/BinLocationInfo/Info?",
headers=HEADERS,
params=params,
)
r.raise_for_status()

soup = BeautifulSoup(r.content.decode("utf-8"), "html.parser")
pickups = soup.find_all("div", {"class": "form-group mb-3"})

today = datetime.now()
entries = []
for pickup in pickups[1:]:
details: list = self.tidytext(pickup.text.split(":"))
for detail in details:
if "FOGO" in details[0]:
dt = list(
rrule(
WEEKLY, byweekday=DAYS[details[1]], dtstart=today, count=1
)
)[0]
waste = "FOGO Bin"
elif "Bulk" in details[0]:
dt = datetime.strptime(details[1], "%d %B %Y")
waste = "Bulk Verge Collection"
else:
dt = datetime.strptime(details[1], "%d/%m/%Y")
if "Recycle" in details[0]:
waste = "Recycle Bin"
else:
waste = "General Waste"
entries.append(
Collection(
date=dt.date(),
t=waste,
icon=ICON_MAP.get(waste),
)
)

return entries
41 changes: 41 additions & 0 deletions doc/source/mundaring_wa_gov_au.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Shire of Mundaring

Support for schedules provided by the [Shire of Mundaring](https://mundaring.wa.gov.au/), in Western Australia.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: mundaring_wa_gov_au
args:
parcel_number: PARCEL_NUMBER
suburb: SUBURB
```
### Configuration Variables
**parcel_number**
*(integer | string)*
The unique reference number that identified your property
**suburb**
*(string)*
The suburb for your address
## Example
```yaml
waste_collection_schedule:
sources:
- name: mundaring_wa_gov_au
args:
parcel_number: 103239
suburb: "Helena Valley"
```
## How to get the parcel_number source argument
An easy way to discover your parcel_number is by going to https://geohub-mundaring.hub.arcgis.com/, and use the *Property Map* to search for your address ensuring both *Lot Numbers* and *House Number* checkboxes are ticked. The pop-up that appears contains an entry that shows your parcel number.
Loading

0 comments on commit 56d9db0

Please sign in to comment.