mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
@@ -331,6 +331,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [AWB Westerwaldkreis](/doc/source/abfall_io.md) / wab.rlp.de
|
||||
- [AWG Kreis Warendorf](/doc/source/abfallnavi_de.md) / awg-waf.de
|
||||
- [AWIDO Online](/doc/source/awido_de.md) / awido-online.de
|
||||
- [AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH](/doc/source/awigo_de.md) / awigo.de
|
||||
- [AWISTA Düsseldorf](/doc/source/muellmax_de.md) / awista.de
|
||||
- [Awista Starnberg](/doc/ics/awista_starnberg_de.md) / awista-starnberg.de
|
||||
- [Bad Arolsen (MyMuell App)](/doc/source/jumomind_de.md) / mymuell.de
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from waste_collection_schedule.service.ICS import ICS
|
||||
|
||||
TITLE = "AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH"
|
||||
DESCRIPTION = "Source for AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH."
|
||||
URL = "https://www.awigo.de/"
|
||||
TEST_CASES = {
|
||||
"Bippen Am Bad 4": {"ort": "Bippen", "strasse": "Am Bad", "hnr": 4},
|
||||
"fürstenau, Am Gültum, 9": {"ort": "Fürstenau", "strasse": "Am Gültum", "hnr": 9},
|
||||
"Melle, Allee, 78-80": {"ort": "Melle", "strasse": "Allee", "hnr": "78-80"},
|
||||
}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"Restmülltonne": "mdi:trash-can",
|
||||
"Glass": "mdi:bottle-soda",
|
||||
"Bio-Tonne": "mdi:leaf",
|
||||
"Papiermülltonne": "mdi:package-variant",
|
||||
"Gelbe Tonne/Gelben Sack": "mdi:recycle",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://www.awigo.de/index.php"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, ort: str, strasse: str, hnr: str | int):
|
||||
self._ort: str = str(ort)
|
||||
self._strasse: str = strasse
|
||||
self._hnr: str = str(hnr)
|
||||
self._ics = ICS()
|
||||
|
||||
def fetch(self):
|
||||
s = requests.Session()
|
||||
args = {
|
||||
"eID": "awigoCalendar",
|
||||
"calendar[method]": "getCities",
|
||||
"calendar[rest]": 1,
|
||||
"calendar[paper]": 1,
|
||||
"calendar[yellow]": 1,
|
||||
"calendar[brown]": 1,
|
||||
"calendar[mobile]": 1,
|
||||
}
|
||||
|
||||
r = s.post(API_URL, params=urllib.parse.urlencode(args, safe="[]"))
|
||||
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
for option in soup.findAll("option"):
|
||||
if self._ort.lower().strip() in option.text.lower().strip():
|
||||
args["calendar[cityID]"] = option.get("value")
|
||||
break
|
||||
if "calendar[cityID]" not in args:
|
||||
raise ValueError(f'City "{self._ort}" not found')
|
||||
|
||||
args["calendar[method]"] = "getStreets"
|
||||
|
||||
r = s.post(API_URL, params=urllib.parse.urlencode(args, safe="[]"))
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
for option in soup.findAll("option"):
|
||||
if option.text.lower().strip() == self._strasse.lower().strip():
|
||||
args["calendar[streetID]"] = option.get("value")
|
||||
break
|
||||
if "calendar[streetID]" not in args:
|
||||
raise ValueError(f'Street "{self._strasse}" not found')
|
||||
|
||||
args["calendar[method]"] = "getNumbers"
|
||||
r = s.post(API_URL, params=urllib.parse.urlencode(args, safe="[]"))
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
for option in soup.findAll("option"):
|
||||
if option.text.lower().strip().replace(
|
||||
" ", ""
|
||||
) == self._hnr.lower().strip().replace(" ", ""):
|
||||
args["calendar[locationID]"] = option.get("value")
|
||||
break
|
||||
if "calendar[locationID]" not in args:
|
||||
raise ValueError(f'House number "{self._hnr}" not found')
|
||||
|
||||
args["calendar[method]"] = "getICSfile"
|
||||
r = s.post(API_URL, params=urllib.parse.urlencode(args, safe="[]"))
|
||||
r = s.get(r.text)
|
||||
|
||||
dates = self._ics.convert(r.text)
|
||||
entries = []
|
||||
for d in dates:
|
||||
bin_type = d[1].replace("wird abgeholt.", "").strip()
|
||||
entries.append(Collection(d[0], bin_type, ICON_MAP.get(bin_type)))
|
||||
|
||||
return entries
|
||||
44
doc/source/awigo_de.md
Normal file
44
doc/source/awigo_de.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH
|
||||
|
||||
Support for schedules provided by [AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH](https://www.awigo.de/), serving Landkreis Osnabrück, Germany.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: awigo_de
|
||||
args:
|
||||
ort: "ORT"
|
||||
strasse: STRAßE
|
||||
hnr: "HAUSNUMMER"
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**ort**
|
||||
*(String) (required)*
|
||||
|
||||
**strasse**
|
||||
*(String) (required)*
|
||||
|
||||
**hnr**
|
||||
*(String | Integer) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: awigo_de
|
||||
args:
|
||||
ort: Bippen
|
||||
strasse: Am Bad
|
||||
hnr: 4
|
||||
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Find the parameter of your address using [https://www.awigo.de/](https://www.awigo.de/) and write them exactly like on the web page.
|
||||
Reference in New Issue
Block a user