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: PreZero Bad Oeynhausen #3449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -1228,6 +1228,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [Ostprignitz-Ruppin](/doc/source/app_abfallplus_de.md) / Abfall+ App: app
- [Plettenberg](/doc/source/lobbe_app.md) / lobbe.app
- [Potsdam](/doc/source/potsdam_de.md) / potsdam.de
- [PreZero Bad Oeynhausen](/doc/source/prezero_bad_oeynhausen.md) / abfallkalender.prezero.network/bad-oeynhausen
- [Prignitz](/doc/source/app_abfallplus_de.md) / Abfall+ App: abfallwecker
- [Prignitz](/doc/source/app_abfallplus_de.md) / Abfall+ App: unterallgaeu
- [Prignitz](/doc/source/app_abfallplus_de.md) / Abfall+ App: willkommen
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 @@ -7945,6 +7945,12 @@
"default_params": {},
"id": "potsdam_de"
},
{
"title": "PreZero Bad Oeynhausen",
"module": "prezero_bad_oeynhausen",
"default_params": {},
"id": "prezero_bad_oeynhausen"
},
{
"title": "Prignitz",
"module": "app_abfallplus_de",
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 @@ -10849,6 +10849,28 @@
"voivodeship": "Voivodeship"
},
"data_description": {}
},
"args_prezero_bad_oeynhausen": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/prezero_bad_oeynhausen.md",
"data": {
"calendar_title": "Kalender Titel",
"street": "street",
"houseNo": "houseNo"
},
"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_prezero_bad_oeynhausen": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/prezero_bad_oeynhausen.md",
"data": {
"calendar_title": "Kalender Titel",
"street": "street",
"houseNo": "houseNo"
},
"data_description": {}
},
"args_pronatura_bydgoszcz_pl": {
"title": "Quelle konfigurieren",
Expand Down
22 changes: 22 additions & 0 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10881,6 +10881,28 @@
},
"data_description": {}
},
"args_prezero_bad_oeynhausen": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/prezero_bad_oeynhausen.md",
"data": {
"calendar_title": "Kalender Title",
"street": "street",
"houseNo": "houseNo"
},
"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_prezero_bad_oeynhausen": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/prezero_bad_oeynhausen.md",
"data": {
"calendar_title": "Kalender Title",
"street": "street",
"houseNo": "houseNo"
},
"data_description": {}
},
"args_pronatura_bydgoszcz_pl": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/pronatura_bydgoszcz_pl.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 @@ -10811,6 +10811,28 @@
},
"data_description": {}
},
"args_prezero_bad_oeynhausen": {
"title": "Configurazione 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/prezero_bad_oeynhausen.md",
"data": {
"calendar_title": "Nome Calendario",
"street": "street",
"houseNo": "houseNo"
},
"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_prezero_bad_oeynhausen": {
"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/prezero_bad_oeynhausen.md",
"data": {
"calendar_title": "Nome Calendario",
"street": "street",
"houseNo": "houseNo"
},
"data_description": {}
},
"args_pronatura_bydgoszcz_pl": {
"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/pronatura_bydgoszcz_pl.md.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS
from bs4 import BeautifulSoup

TITLE = "Abfallkalender Stadt Bad Oeynhausen"
DESCRIPTION = "Waste collection schedule for Bad Oeynhausen."
URL = "https://abfallkalender.prezero.network/bad-oeynhausen"
TEST_CASES = {
"street": "Eidingsen",
"houseNo": "6"
}

class Source:
def __init__(self, street, houseNo):
self._street = street
self._houseNo = houseNo
self._ics = ICS()

def fetch(self):
args = {"street": self._street, "houseNo": self._houseNo}

response = requests.post(URL, data=args, verify=False)

if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')

ical_form = soup.find('form', {'action': True, 'class': 'ical'})
if not ical_form:
raise ValueError("iCal form not found on the page.")

ical_url = "https://abfallkalender.prezero.network" + ical_form['action']

ical_response = requests.post(ical_url, data=args, verify=False)
if ical_response.status_code != 200:
raise ValueError(f"Failed to download iCal. Status code: {ical_response.status_code}")

ical_data = ical_response.content.decode('utf-8')

dates = self._ics.convert(ical_data)
entries = []
for d in dates:
entries.append(Collection(d[0], d[1]))

return entries
else:
raise ValueError(f"Failed to fetch calendar page. Status code: {response.status_code}")
36 changes: 36 additions & 0 deletions doc/source/prezero_bad_oeynhausen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# PreZero Bad Oeynhausen

Add support for schedules provided by [PreZero Bad Oeynhausen](https://abfallkalender.prezero.network/bad-oeynhausen).

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: prezero_bad_oeynhausen
args:
street: "Eidingsen"
houseNo: "2"
```

### Configuration Variables

**street**
*(string) (required)*

**houseNo**
*(string) (required)*

## Example

```yaml
waste_collection_schedule:
sources:
- name: prezero_bad_oeynhausen
args:
street: "Eidingsen"
```

## How to get the source arguments

Just add your Street Name and House Number and add your iCal.