Skip to content

Commit

Permalink
add Bad Einsenkappel, AT
Browse files Browse the repository at this point in the history
  • Loading branch information
5ila5 committed Oct 22, 2024
1 parent 59ccef0 commit ec2f520
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [Eggenburg](/doc/source/citiesapps_com.md) / eggenburg.gv.at
- [Eggersdorf bei Graz](/doc/source/citiesapps_com.md) / eggersdorf-graz.gv.at
- [Eichgraben](/doc/source/citiesapps_com.md) / eichgraben.at
- [Eisenkappel-Vellach](/doc/source/bad_eisenkappel_info.md) / bad-eisenkappel.info
- [Eisenstadt](/doc/source/citiesapps_com.md) / eisenstadt.gv.at
- [Enzenreith](/doc/source/citiesapps_com.md) / gemeinde-enzenreith.at
- [Eugendorf](/doc/ics/muellapp_com.md) / muellapp.com
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 @@ -1262,6 +1262,12 @@
"default_params": {},
"id": "citiesapps_com"
},
{
"title": "Eisenkappel-Vellach",
"module": "bad_eisenkappel_info",
"default_params": {},
"id": "bad_eisenkappel_info"
},
{
"title": "Eisenstadt",
"module": "citiesapps_com",
Expand Down
20 changes: 20 additions & 0 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,26 @@
},
"data_description": {}
},
"args_bad_eisenkappel_info": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/bad_eisenkappel_info.md",
"data": {
"calendar_title": "Kalender Titel",
"region": "Ortsteil"
},
"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_bad_eisenkappel_info": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/bad_eisenkappel_info.md",
"data": {
"calendar_title": "Kalender Titel",
"region": "Ortsteil"
},
"data_description": {}
},
"args_ics_gda_gv_at": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\n- Go to https://gda.gv.at/abholtermine and select your location. \n- Copy the link of the `iCal` Button.\n- Replace the `url` in the example configuration with this link.\n\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/gda_gv_at.md",
Expand Down
20 changes: 20 additions & 0 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,26 @@
},
"data_description": {}
},
"args_bad_eisenkappel_info": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/bad_eisenkappel_info.md.",
"data": {
"calendar_title": "Calendar Title",
"region": "Region"
},
"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_bad_eisenkappel_info": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/bad_eisenkappel_info.md.",
"data": {
"calendar_title": "Calendar Title",
"region": "Region"
},
"data_description": {}
},
"args_ics_gda_gv_at": {
"title": "Configure Source",
"description": "Configure your service provider. \n\n- Go to https://gda.gv.at/abholtermine and select your location. \n- Copy the link of the `iCal` Button.\n- Replace the `url` in the example configuration with this link.\n\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/gda_gv_at.md.",
Expand Down
20 changes: 20 additions & 0 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,26 @@
},
"data_description": {}
},
"args_bad_eisenkappel_info": {
"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/bad_eisenkappel_info.md.",
"data": {
"calendar_title": "Nome Calendario",
"region": "Regione"
},
"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_bad_eisenkappel_info": {
"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/bad_eisenkappel_info.md.",
"data": {
"calendar_title": "Nome Calendario",
"region": "Regione"
},
"data_description": {}
},
"args_ics_gda_gv_at": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\n- Go to https://gda.gv.at/abholtermine and select your location. \n- Copy the link of the `iCal` Button.\n- Replace the `url` in the example configuration with this link.\n\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/gda_gv_at.md.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from datetime import datetime

import requests
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection
from waste_collection_schedule.exceptions import SourceArgumentNotFoundWithSuggestions

TITLE = "Eisenkappel-Vellach"
DESCRIPTION = "Source for Eisenkappel-Vellach."
URL = "https://www.bad-eisenkappel.info/"
TEST_CASES = {"Leppen": {"region": "Leppen"}}
COUNTRY = "at"

ICON_MAP = {
"Restmüll": "mdi:trash-can",
"Glasbehälter": "mdi:bottle-soda",
"Biomüll": "mdi:leaf",
"Altpapiertonne": "mdi:package-variant",
"Recycle": "mdi:recycle",
"Recyclinghof": "mdi:factory",
"Gelbe": "mdi:recycle",
}


API_URL = "https://www.bad-eisenkappel.info/gemeinde/onlineservice/abfuhrtermine.html"

PARAM_TRANSLATIONS = {
"de": {
"region": "Ortsteil",
}
}


class Source:
def __init__(self, region: str):
self._region: str = region

def fetch(self) -> list[Collection]:
# get json file
r = requests.get(API_URL)
r.raise_for_status()

soup = BeautifulSoup(r.text, "html.parser")
tables = soup.select("table")
entries = []
regions = set[str]()
for table in tables:
trs = table.select("tr")
for tr in trs:
tds = tr.select("td")
if len(tds) < 3:
continue
date_str = tds[0].text.strip().split(". ")[1]

date = datetime.strptime(date_str, "%d.%m.%y").date()
bin_type = (
tds[1]
.text.strip()
.removeprefix("Abholung")
.removeprefix("Entleerung")
.strip()
.removeprefix("von")
.strip()
.removeprefix("der")
.strip()
)
icon = ICON_MAP.get(bin_type.split()[0].strip(", "))
region_str = tds[2].text.strip()
for region in region_str.split(","):
regions.add(region.strip())

if (
region_str.lower() == "Gesamtes Gemeindegebiet".lower()
or self._region.lower().replace(" ", "")
in region_str.lower().replace(" ", "").split(",")
):
entries.append(Collection(date=date, t=bin_type, icon=icon))

regions.remove("Gesamtes Gemeindegebiet")
if self._region.lower().replace(" ", "") not in map(
lambda x: x.lower().replace(" ", ""), regions
):
raise SourceArgumentNotFoundWithSuggestions(
argument="region",
value=self._region,
suggestions=regions,
)

return entries
32 changes: 32 additions & 0 deletions doc/source/bad_eisenkappel_info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Eisenkappel-Vellach / Bad Eisenkappel

Support for schedules provided by [Bad Eisenkappel](https://www.bad-eisenkappel.info/), serving Eisenkappel-Vellach, Germany.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: bad_eisenkappel_info
args:
region: REGION
```
### Configuration Variables
**region**
*(String) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: bad_eisenkappel_info
args:
region: Leppen
```
## How to get the source argument
The region should match one of the regions listed in the third column of the table at <https://www.bad-eisenkappel.info/gemeinde/onlineservice/abfuhrtermine.html>
2 changes: 1 addition & 1 deletion info.md

Large diffs are not rendered by default.

0 comments on commit ec2f520

Please sign in to comment.