Skip to content

Commit

Permalink
add AWV Ostthüringen
Browse files Browse the repository at this point in the history
  • Loading branch information
5ila5 committed Dec 3, 2024
1 parent c1cd800 commit 0eaa5e4
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [Awista Starnberg](/doc/ics/awista_starnberg_de.md) / awista-starnberg.de
- [AWL Neuss](/doc/source/awlneuss_de.md) / buergerportal.awl-neuss.de
- [AWM München](/doc/source/awm_muenchen_de.md) / awm-muenchen.de
- [AWV: Abfall Wirtschaftszweckverband Ostthüringen](/doc/source/awv_ot_de.md) / awv-ot.de
- [AZV Stadt und Landkreis Hof](/doc/ics/azv_hof_de.md) / azv-hof.de
- [Bad Arolsen](/doc/source/lobbe_app.md) / lobbe.app
- [Bad Arolsen (MyMuell App)](/doc/source/jumomind_de.md) / mymuell.de
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 @@ -4936,6 +4936,12 @@
"default_params": {},
"id": "awm_muenchen_de"
},
{
"title": "AWV: Abfall Wirtschaftszweckverband Ostth\u00fcringen",
"module": "awv_ot_de",
"default_params": {},
"id": "awv_ot_de"
},
{
"title": "AZV Stadt und Landkreis Hof",
"module": "ics",
Expand Down
24 changes: 24 additions & 0 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5070,6 +5070,30 @@
},
"data_description": {}
},
"args_awv_ot_de": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awv_ot_de.md",
"data": {
"calendar_title": "Kalender Titel",
"city": "Stadt",
"hnr": "Hnr",
"street": "Straße"
},
"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_awv_ot_de": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awv_ot_de.md",
"data": {
"calendar_title": "Kalender Titel",
"city": "Stadt",
"hnr": "Hnr",
"street": "Straße"
},
"data_description": {}
},
"args_ics_azv_hof_de": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\n- Go to https://www.azv-hof.de/privat/abfuhrtermine/abfuhrkalender-landkreis-hof.html and select your location. \n- Right-click, copy the link of the `KALENDER EXPORTIEREN` button to get the ICS link.\n- Replace the `url` in the example configuration with this link.\n- Replace the year in the link with '{%Y}'.\n- Feel free to remove the cHash argument (e.g. `&cHash=34c2ea8698d8ebba9d6f9f97abce20cf`) from the link.\n- If you want to ignore the `geschlossen` messages, add the `regex` option (second example) to the configuration. and use the customize parameter of the source to `display: False` all geschlossen entries. \n\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/azv_hof_de.md",
Expand Down
24 changes: 24 additions & 0 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5079,6 +5079,30 @@
},
"data_description": {}
},
"args_awv_ot_de": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awv_ot_de.md.",
"data": {
"calendar_title": "Calendar Title",
"city": "City",
"hnr": "House Number",
"street": "Street"
},
"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_awv_ot_de": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awv_ot_de.md.",
"data": {
"calendar_title": "Calendar Title",
"city": "City",
"hnr": "House Number",
"street": "Street"
},
"data_description": {}
},
"args_ics_azv_hof_de": {
"title": "Configure Source",
"description": "Configure your service provider. \n\n- Go to https://www.azv-hof.de/privat/abfuhrtermine/abfuhrkalender-landkreis-hof.html and select your location. \n- Right-click, copy the link of the `KALENDER EXPORTIEREN` button to get the ICS link.\n- Replace the `url` in the example configuration with this link.\n- Replace the year in the link with '{%Y}'.\n- Feel free to remove the cHash argument (e.g. `&cHash=34c2ea8698d8ebba9d6f9f97abce20cf`) from the link.\n- If you want to ignore the `geschlossen` messages, add the `regex` option (second example) to the configuration. and use the customize parameter of the source to `display: False` all geschlossen entries. \n\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/azv_hof_de.md.",
Expand Down
24 changes: 24 additions & 0 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -5070,6 +5070,30 @@
},
"data_description": {}
},
"args_awv_ot_de": {
"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/awv_ot_de.md.",
"data": {
"calendar_title": "Nome Calendario",
"city": "Città",
"hnr": "Hnr",
"street": "Strada"
},
"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_awv_ot_de": {
"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/awv_ot_de.md.",
"data": {
"calendar_title": "Nome Calendario",
"city": "Città",
"hnr": "Hnr",
"street": "Strada"
},
"data_description": {}
},
"args_ics_azv_hof_de": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\n- Go to https://www.azv-hof.de/privat/abfuhrtermine/abfuhrkalender-landkreis-hof.html and select your location. \n- Right-click, copy the link of the `KALENDER EXPORTIEREN` button to get the ICS link.\n- Replace the `url` in the example configuration with this link.\n- Replace the year in the link with '{%Y}'.\n- Feel free to remove the cHash argument (e.g. `&cHash=34c2ea8698d8ebba9d6f9f97abce20cf`) from the link.\n- If you want to ignore the `geschlossen` messages, add the `regex` option (second example) to the configuration. and use the customize parameter of the source to `display: False` all geschlossen entries. \n\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/azv_hof_de.md.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from datetime import datetime
from urllib.parse import urlencode

import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS

TITLE = "AWV: Abfall Wirtschaftszweckverband Ostthüringen"
DESCRIPTION = "Source for AWV: Abfall Wirtschaftszweckverband Ostthüringen."
URL = "https://www.awv-ot.de/"
TEST_CASES = {
"Bethenhausen Caasen 15A": {
"city": "Bethenhausen OT Caasen",
"street": "Caasen",
"hnr": "15A",
},
"Kraftsdorf OT Oberndorf, Klosterlausnitzer Straße 5/1": {
"city": "Kraftsdorf OT Oberndorf",
"street": "Klosterlausnitzer Straße",
"hnr": "5/1",
},
"Gera, Aga Birkenstraße 9": {
"city": "Gera",
"street": "Aga Birkenstraße",
"hnr": "9",
},
}


ICON_MAP = {
"Hausmuelltonne": "mdi:trash-can",
"Biotonne": "mdi:leaf",
"Papiertonne": "mdi:package-variant",
"Gelbe Tonne": "mdi:recycle",
}


API_URL = "https://www.awv-ot.de/tourenauskunft/auskunftbatix.php"
ICS_URL = "https://www.awv-ot.de/tourenauskunft/ics/ics.php"


class Source:
def __init__(self, city: str, street: str, hnr: str):
self._city: str = city
self._street: str = street
self._hnr: str = hnr
self._ics = ICS()

def fetch(self) -> list[Collection]:
now = datetime.now()
entries = self.fetch_year(now.year)
if now.month == 12:
try:
entries.extend(self.fetch_year(now.year + 1))
except Exception:
pass
return entries

def fetch_year(self, year: int) -> list[Collection]:
args = {
"JAHR": str(year),
"Ort": self._city,
"Strasse": self._street,
"Step": "3",
"HSN": self._hnr,
}

session = requests.Session()
r = session.post(
API_URL,
data=urlencode(args, encoding="latin-1"),
headers={"Content-Type": "application/x-www-form-urlencoded"},
)
r.raise_for_status()
r = session.get(ICS_URL)
r.raise_for_status()
dates = self._ics.convert(r.text)
entries = []
for d in dates:
bin_type = d[1].removeprefix("Leerung").strip()
entries.append(Collection(d[0], bin_type, ICON_MAP.get(bin_type)))

if not entries:
raise Exception(
"No entries found Make sure the address matches exactly with an address suggested here: https://www.awv-ot.de/www/awvot/abfuhrtermine/leerungstage/"
)

return entries
43 changes: 43 additions & 0 deletions doc/source/awv_ot_de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# AWV: Abfall Wirtschaftszweckverband Ostthüringen

Support for schedules provided by [AWV: Abfall Wirtschaftszweckverband Ostthüringen](https://www.awv-ot.de/), serving Ostthüringen, Germany.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: awv_ot_de
args:
city: CITY (Ort)
street: STREET (Straße)
hnr: HNR (Housenummer)

```
### Configuration Variables
**city**
*(String) (required)*
**street**
*(String) (required)*
**hnr**
*(String) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: awv_ot_de
args:
city: Bethenhausen OT Caasen
street: Caasen
hnr: 15A
```
## How to get the source argument
Find the parameter of your address using [https://www.awv-ot.de/www/awvot/abfuhrtermine/leerungstage/](https://www.awv-ot.de/www/awvot/abfuhrtermine/leerungstage/) and write them exactly like on the web page.
Loading

0 comments on commit 0eaa5e4

Please sign in to comment.