diff --git a/README.md b/README.md index 6a70d57c..edb2ddb3 100644 --- a/README.md +++ b/README.md @@ -1150,6 +1150,7 @@ If your service provider is not listed, feel free to open a [source request issu - [Würzburg](/doc/source/app_abfallplus_de.md) / Abfall+ App: wuerzburg - [ZAH Hildesheim](/doc/ics/zah_hildesheim_de.md) / zah-hildesheim.de - [ZAK Kempten](/doc/source/app_abfallplus_de.md) / Abfall+ App: abfallappzak +- [ZAW Donau-Wald](/doc/source/awg_de.md) / awg.de - [ZAW-SR](/doc/source/app_abfallplus_de.md) / Abfall+ App: zawsr - [ZEW Zweckverband Entsorgungsregion West](/doc/source/abfallnavi_de.md) / zew-entsorgung.de - [ZfA Iserlohn](/doc/ics/zfa_iserlohn_de.md) / zfa-iserlohn.de diff --git a/custom_components/waste_collection_schedule/sources.json b/custom_components/waste_collection_schedule/sources.json index 589937fe..7048ae1d 100644 --- a/custom_components/waste_collection_schedule/sources.json +++ b/custom_components/waste_collection_schedule/sources.json @@ -6420,6 +6420,11 @@ "app_id": "de.k4systems.abfallappzak" } }, + { + "title": "ZAW Donau-Wald", + "module": "awg_de", + "default_params": {} + }, { "title": "ZAW-SR", "module": "app_abfallplus_de", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awg_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awg_de.py new file mode 100644 index 00000000..a518d78b --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awg_de.py @@ -0,0 +1,138 @@ +# This is a nearly 1:1 copy of the original file waste_collection_schedule/waste_collection_schedule/source/meinawb_de.py + +import html +import logging +import random +import re +import string + +import requests +from waste_collection_schedule import Collection +from waste_collection_schedule.service.ICS import ICS + +_LOGGER = logging.getLogger(__name__) + + +TITLE = "ZAW Donau-Wald" +DESCRIPTION = "Source for ZAW Donau-Wald." +URL = "https://www.awg.de/" +TEST_CASES = { + "Achslach Aign 1 ": {"city": "Achslach", "street": "Aign", "hnr": "1"}, + "Böbrach Bärnerauweg 10A": { + "city": "Böbrach", + "street": "Bärnerauweg", + "hnr": 10, + "addition": "A", + }, + "Am Bäckergütl 1, 94094 Malching": { + "city": "Malching", + "street": "Am Bäckergütl", + "hnr": 1, + "addition": "", + }, +} + + +ICON_MAP = { + "Biotonne": "mdi:leaf", + "Papiertonne": "mdi:package-variant", + "Restmuelltonne": "mdi:trash-can", + "Restmüllcontainer": "mdi:trash-can", + "Papiercontainer": "mdi:package-variant", +} + + +API_URL = ( + "https://wastemanagement.awg.de/WasteManagementDonauwald/WasteManagementServlet" +) + + +class Source: + def __init__(self, city, street, hnr, addition=""): + self._city = city + self._street = street + self._house_number = hnr + self._address_suffix = addition + self._boundary = "WebKitFormBoundary" + "".join( + random.sample(string.ascii_letters + string.digits, 16) + ) + self._ics = ICS() + + def __str__(self): + return ( + f"{self._city} {self._street} {self._house_number} {self._address_suffix}" + ) + + @staticmethod + def _parse_data(data, boundary): + result = "" + for key, value in data.items(): + result += f'------{boundary}\r\nContent-Disposition: form-data; name="{key}"\r\n\r\n{value}\r\n' + result += f"------{boundary}--\r\n" + return result.encode() + + @staticmethod + def _parse_response_input(text): + parsed = re.findall( + '