mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 05:06:33 +01:00
add Abfall_IO ics source (#1958)
* add Abfall_IO ics source * Zollernalbkreis stopped working use abfall_io_ics now --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
@@ -519,6 +519,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
|
||||
- [Aballwirtschaft Ludwigslust-Parchim AöR](/doc/ics/alp_lup_de.md) / alp-lup.de
|
||||
- [Abfall App](/doc/ics/abfall_app_net.md) / abfall-app.net
|
||||
- [Abfall IO ICS Version](/doc/ics/abfall_io_ics.md) / abfallplus.de
|
||||
- [Abfall Stuttgart](/doc/source/stuttgart_de.md) / service.stuttgart.de
|
||||
- [Abfall-Wirtschafts-Verband Nordschwaben](/doc/source/awido_de.md) / awv-nordschwaben.de
|
||||
- [Abfall.IO / AbfallPlus](/doc/source/abfall_io.md) / abfallplus.de
|
||||
@@ -544,8 +545,9 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Abfallwirtschaft Isar-Inn](/doc/source/awido_de.md) / awv-isar-inn.de
|
||||
- [Abfallwirtschaft Kreis Plön](/doc/ics/kreis_ploen_de.md) / kreis-ploen.de
|
||||
- [Abfallwirtschaft Lahn-Dill-Kreises](/doc/source/awido_de.md) / awld.de
|
||||
- [Abfallwirtschaft Landkreis Böblingen](/doc/source/abfall_io.md) / awb-bb.de
|
||||
- [Abfallwirtschaft Landkreis Böblingen](/doc/ics/abfall_io_ics.md) / awb-bb.de
|
||||
- [Abfallwirtschaft Landkreis Freudenstadt](/doc/source/abfall_io.md) / awb-fds.de
|
||||
- [Abfallwirtschaft Landkreis Göppingen](/doc/ics/abfall_io_ics.md) / awb-gp.de
|
||||
- [Abfallwirtschaft Landkreis Harburg](/doc/source/aw_harburg_de.md) / landkreis-harburg.de
|
||||
- [Abfallwirtschaft Landkreis Haßberge](/doc/ics/awhas_de.md) / awhas.de
|
||||
- [Abfallwirtschaft Landkreis Kitzingen](/doc/source/abfall_io.md) / abfallwelt.de
|
||||
@@ -565,7 +567,6 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Abfallwirtschaft Stadt Schweinfurt](/doc/source/schweinfurt_de.md) / schweinfurt.de
|
||||
- [Abfallwirtschaft Südholstein](/doc/source/awsh_de.md) / awsh.de
|
||||
- [Abfallwirtschaft Werra-Meißner-Kreis](/doc/source/zva_wmk_de.md) / zva-wmk.de
|
||||
- [Abfallwirtschaft Zollernalbkreis](/doc/source/abfall_zollernalbkreis_de.md) / abfallkalender-zak.de
|
||||
- [Abfallwirtschafts-Zweckverband des Landkreises Hersfeld-Rotenburg](/doc/source/awido_de.md) / azv-hef-rof.de
|
||||
- [Abfallwirtschaftsbetrieb Bergisch Gladbach](/doc/source/abfallnavi_de.md) / bergischgladbach.de
|
||||
- [Abfallwirtschaftsbetrieb Emsland](/doc/source/awb_emsland_de.md) / awb-emsland.de
|
||||
@@ -608,7 +609,6 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [AWB Köln](/doc/source/awbkoeln_de.md) / awbkoeln.de
|
||||
- [AWB Landkreis Bad Dürkheim](/doc/source/awido_de.md) / awb.kreis-bad-duerkheim.de
|
||||
- [AWB Landkreis Fürstenfeldbruck](/doc/source/awido_de.md) / awb-ffb.de
|
||||
- [AWB Landkreis Göppingen](/doc/source/abfall_io.md) / awb-gp.de
|
||||
- [AWB Oldenburg](/doc/source/awb_oldenburg_de.md) / oldenburg.de
|
||||
- [AWB Westerwaldkreis](/doc/source/abfall_io.md) / wab.rlp.de
|
||||
- [AWG Donau-Wald](/doc/source/app_abfallplus_de.md) / Abfall+ App: zawdw
|
||||
@@ -987,6 +987,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [ZEW Zweckverband Entsorgungsregion West](/doc/source/abfallnavi_de.md) / zew-entsorgung.de
|
||||
- [ZfA Iserlohn](/doc/ics/zfa_iserlohn_de.md) / zfa-iserlohn.de
|
||||
- [Zollernalbkreis](/doc/source/app_abfallplus_de.md) / Abfall+ App: abfallzak
|
||||
- [Zollernalbkreis](/doc/ics/abfall_io_ics.md) / zollernalbkreis.de
|
||||
- [Zweckverband Abfallwirtschaft Kreis Bergstraße](/doc/source/zakb_de.md) / zakb.de
|
||||
- [Zweckverband Abfallwirtschaft Oberes Elbtal](/doc/ics/zaoe_de.md) / zaoe.de
|
||||
- [Zweckverband Abfallwirtschaft Region Hannover](/doc/source/aha_region_de.md) / aha-region.de
|
||||
|
||||
@@ -22,11 +22,6 @@ SERVICE_MAP = [
|
||||
"url": "https://www.landkreis-bayreuth.de/",
|
||||
"service_id": "951da001077dc651a3bf437bc829964e",
|
||||
},
|
||||
{
|
||||
"title": "Abfallwirtschaft Landkreis Böblingen",
|
||||
"url": "https://www.awb-bb.de/",
|
||||
"service_id": "8215c62763967916979e0e8566b6172e",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Calw",
|
||||
"url": "https://www.kreis-calw.de/",
|
||||
@@ -42,11 +37,6 @@ SERVICE_MAP = [
|
||||
"url": "https://www.awb-fds.de/",
|
||||
"service_id": "595f903540a36fe8610ec39aa3a06f6a",
|
||||
},
|
||||
{
|
||||
"title": "AWB Landkreis Göppingen",
|
||||
"url": "https://www.awb-gp.de/",
|
||||
"service_id": "365d791b58c7e39b20bb8f167bd33981",
|
||||
},
|
||||
{
|
||||
"title": "Göttinger Entsorgungsbetriebe",
|
||||
"url": "https://www.geb-goettingen.de/",
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
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 = "Abfallwirtschaft Zollernalbkreis"
|
||||
DESCRIPTION = "Source for Abfallwirtschaft Zollernalbkreis waste collection."
|
||||
URL = "https://www.abfallkalender-zak.de"
|
||||
TEST_CASES = {
|
||||
"Ebingen": {
|
||||
"city": "2,3,4",
|
||||
"street": "3",
|
||||
},
|
||||
"Erlaheim": {
|
||||
"city": "79",
|
||||
"street": "",
|
||||
},
|
||||
"Ebingen names": {
|
||||
"city": "Ebingen",
|
||||
"street": "Am schnecklesfelsen",
|
||||
},
|
||||
"Schlatt names": {
|
||||
"city": "Schlatt",
|
||||
},
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"Restmüll": "mdi:trash-can",
|
||||
"Grünabfall": "mdi:leaf",
|
||||
"Biomüll": "mdi:leaf",
|
||||
"Gelber Sack": "mdi:sack",
|
||||
"Papiertonne": "mdi:package-variant",
|
||||
"Bildschirm-/Kühlgeräte": "mdi:television-classic",
|
||||
"Schadstoffsammlung": "mdi:biohazard",
|
||||
"altmetalle": "mdi:nail",
|
||||
}
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, city, types=None, street=None):
|
||||
self._city = city
|
||||
self._street = street
|
||||
if types:
|
||||
LOGGER.warning(
|
||||
"you provided types parameter but filtering should be done by using the customize argument. Ignoring types"
|
||||
)
|
||||
|
||||
self._ics = ICS()
|
||||
|
||||
def get_ids(self, soup, id, copmare):
|
||||
options = soup.find("select", id=id).findAll("option")
|
||||
for option in options:
|
||||
if option.text.lower().strip() == copmare.lower().strip():
|
||||
return option["value"]
|
||||
raise Exception(f"{id.capitalize()} {copmare} not found")
|
||||
|
||||
def fetch(self):
|
||||
r = requests.get("https://www.abfallkalender-zak.de")
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
types = [t["value"] for t in soup.findAll("input", attrs={"name": "types[]"})]
|
||||
|
||||
if not self._city.replace(" ", "").replace(",", "").isnumeric():
|
||||
# city is not a number, so we need to get the id
|
||||
self._city = self.get_ids(soup, "city", self._city)
|
||||
if (
|
||||
self._street
|
||||
and not self._city.replace(" ", "").replace(",", "").isnumeric()
|
||||
):
|
||||
# city is not a number, so we need to get the id
|
||||
self._street = self.get_ids(soup, "street", self._street)
|
||||
|
||||
now = datetime.now()
|
||||
entries = self.fetch_year(now.year, self._city, self._street, types)
|
||||
if now.month == 12:
|
||||
# also get data for next year if we are already in december
|
||||
try:
|
||||
entries.extend(
|
||||
self.fetch_year((now.year + 1), self._city, self._street, types)
|
||||
)
|
||||
except Exception:
|
||||
# ignore if fetch for next year fails
|
||||
pass
|
||||
return entries
|
||||
|
||||
def fetch_year(self, year, city, street, types):
|
||||
args = {
|
||||
"city": city,
|
||||
"street": street,
|
||||
"year": year,
|
||||
"types[]": types,
|
||||
"go_ics": "Download",
|
||||
}
|
||||
|
||||
# get ics file
|
||||
r = requests.get("https://www.abfallkalender-zak.de", params=args)
|
||||
|
||||
# parse ics file
|
||||
dates = self._ics.convert(r.text)
|
||||
|
||||
entries = []
|
||||
for d in dates:
|
||||
waste_type = d[1]
|
||||
next_pickup_date = d[0]
|
||||
|
||||
entries.append(
|
||||
Collection(
|
||||
date=next_pickup_date,
|
||||
t=waste_type,
|
||||
icon=ICON_MAP.get(waste_type.split(" ")[0]),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
@@ -181,6 +181,7 @@ class Source:
|
||||
return self.fetch_file(self._file)
|
||||
|
||||
def fetch_url(self, url, params=None):
|
||||
print(url)
|
||||
# get ics file
|
||||
if self._method == "GET":
|
||||
r = requests.get(
|
||||
|
||||
25
doc/ics/abfall_io_ics.md
Normal file
25
doc/ics/abfall_io_ics.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Abfall IO ICS Version
|
||||
|
||||
Abfall IO ICS Version is supported by the generic [ICS](/doc/source/ics.md) source. For all available configuration options, please refer to the source description.
|
||||
|
||||
Support for multiple service provider using the AbfallPlus API.
|
||||
|
||||
## How to get the configuration arguments
|
||||
|
||||
- Goto your regions collection dates form.
|
||||
- Select you location and your desired waste types.
|
||||
- Right click -> copy link address of the `ICS` button.
|
||||
- Replace the `url` in the example configuration with this link.
|
||||
- Replace the year in the URL with `{%Y}` (`...timeperiod=20240101-20241231` -> `...timeperiod={%Y}0101-{%Y}1231`).
|
||||
|
||||
## Examples
|
||||
|
||||
### Göppingen
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: ics
|
||||
args:
|
||||
url: https://api.abfall.io/?key=f35bd08b1d18d9c81fcdee75dbcce5d3&mode=export&idhousenumber=2859&wastetypes=20,17,59,18,19,60&timeperiod={%Y}0101-{%Y}1231&showinactive=false&type=ics
|
||||
```
|
||||
27
doc/ics/yaml/abfall_io_ics.yaml
Normal file
27
doc/ics/yaml/abfall_io_ics.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
title: Abfall IO ICS Version
|
||||
url: https://www.abfallplus.de
|
||||
|
||||
description: Support for multiple service provider using the AbfallPlus API.
|
||||
howto: |
|
||||
- Goto your regions collection dates form.
|
||||
- Select you location and your desired waste types.
|
||||
- Right click -> copy link address of the `ICS` button.
|
||||
- Replace the `url` in the example configuration with this link.
|
||||
- Replace the year in the URL with `{%Y}` (`...timeperiod=20240101-20241231` -> `...timeperiod={%Y}0101-{%Y}1231`).
|
||||
country: de
|
||||
extra_info:
|
||||
- title: Abfallwirtschaft Landkreis Böblingen
|
||||
url: https://www.awb-bb.de/
|
||||
country: de
|
||||
- title: Abfallwirtschaft Landkreis Göppingen
|
||||
url: https://www.awb-gp.de/
|
||||
country: de
|
||||
- title: Zollernalbkreis
|
||||
url: https://www.zollernalbkreis.de/
|
||||
country: de
|
||||
|
||||
|
||||
|
||||
test_cases:
|
||||
Göppingen:
|
||||
url: "https://api.abfall.io/?key=f35bd08b1d18d9c81fcdee75dbcce5d3&mode=export&idhousenumber=2859&wastetypes=20,17,59,18,19,60&timeperiod={%Y}0101-{%Y}1231&showinactive=false&type=ics"
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Support for schedules provided by [Abfall.IO](https://abfall.io). The official homepage is using the URL [AbfallPlus.de](https://www.abfallplus.de/) instead.
|
||||
|
||||
This source is designed for the old API of Abfall.IO. If your region/preovider uses the new API you should use the [Abfall ICS version](/doc/ics/abfall_io_ics.md) source instead. Your provider uses the new API if you can see an `ICS` button above your collection dates on the website after selecting your location and waste types.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
# Abfallwirtschaft Zollernalbkreis
|
||||
|
||||
Support for schedules provided by [https://www.abfallkalender-zak.de/](https://www.abfallkalender-zak.de/).
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: abfall_zollernalbkreis_de
|
||||
args:
|
||||
city: CITY
|
||||
street: STREET
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**city**
|
||||
*(string) (required)*
|
||||
|
||||
**street**
|
||||
*(string) (optional)*
|
||||
|
||||
**types** (not supported anymore use [customize](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/installation.md#configuring-sources) parameter instead)
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: abfall_zollernalbkreis_de
|
||||
args:
|
||||
city: "Ebingen"
|
||||
street: "Am schnecklesfelsen"
|
||||
```
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: abfall_zollernalbkreis_de
|
||||
args:
|
||||
city: "Schlatt"
|
||||
```
|
||||
|
||||
## How to get the source arguments
|
||||
|
||||
### Using city/street names
|
||||
|
||||
1. Open [https://www.abfallkalender-zak.de/](https://www.abfallkalender-zak.de/).
|
||||
2. Enter your data
|
||||
3. Use the city and street names as arguments (write them exactly like in the dropdown menu).
|
||||
|
||||
### Using city/street IDs: Hardcore Variant: Extract arguments from website
|
||||
|
||||
Another way get the source arguments is to extract the arguments from the website using a (desktop) browser with developer tools, e.g. Google Chrome:
|
||||
|
||||
1. Open [https://www.abfallkalender-zak.de/](https://www.abfallkalender-zak.de/).
|
||||
2. Enter your data, but don't click on "ICS Download" so far!
|
||||
3. Open the Developer Tools (Ctrl + Shift + I) and open the `Network` tab.
|
||||
4. Now click the "ICS Download" button.
|
||||
5. You should see (amongst other's) one POST entry to Host `https://www.abfallkalender-zak.de/` labeled `/` in the network recording.
|
||||
6. Select `/` on the left hand side and click on Request on the right hand side.
|
||||
7. At the `Form Data` you can find the values for `city` and `street`.
|
||||
@@ -150,11 +150,14 @@ This source has been successfully tested with the following service providers:
|
||||
|
||||
- [Aballwirtschaft Ludwigslust-Parchim AöR](/doc/ics/alp_lup_de.md) / alp-lup.de
|
||||
- [Abfall App](/doc/ics/abfall_app_net.md) / abfall-app.net
|
||||
- [Abfall IO ICS Version](/doc/ics/abfall_io_ics.md) / abfallplus.de
|
||||
- [Abfallbehandlungsgesellschaft Havelland mbH (abh)](/doc/ics/abfall_havelland_de.md) / abfall-havelland.de
|
||||
- [Abfallentsorgung Kreis Kassel](/doc/ics/abfall_kreis_kassel_de.md) / abfall-kreis-kassel.de
|
||||
- [Abfallwirtschaft Enzkreis](/doc/ics/entsorgung_regional_de.md) / entsorgung-regional.de
|
||||
- [Abfallwirtschaft Freiburg](/doc/ics/abfallwirtschaft_freiburg_de.md) / abfall-eglz.de
|
||||
- [Abfallwirtschaft Kreis Plön](/doc/ics/kreis_ploen_de.md) / kreis-ploen.de
|
||||
- [Abfallwirtschaft Landkreis Böblingen](/doc/ics/abfall_io_ics.md) / awb-bb.de
|
||||
- [Abfallwirtschaft Landkreis Göppingen](/doc/ics/abfall_io_ics.md) / awb-gp.de
|
||||
- [Abfallwirtschaft Landkreis Haßberge](/doc/ics/awhas_de.md) / awhas.de
|
||||
- [Abfallwirtschaft Potsdam-Mittelmark (APM)](/doc/ics/apm_de.md) / apm-niemegk.de
|
||||
- [Abfallwirtschaft Sonneberg](/doc/ics/abfallwirtschaft_sonneberg_de.md) / abfallwirtschaft-sonneberg.de
|
||||
@@ -220,6 +223,7 @@ This source has been successfully tested with the following service providers:
|
||||
- [ULM (EBU)](/doc/ics/ebu_ulm_de.md) / ebu-ulm.de
|
||||
- [ZAH Hildesheim](/doc/ics/zah_hildesheim_de.md) / zah-hildesheim.de
|
||||
- [ZfA Iserlohn](/doc/ics/zfa_iserlohn_de.md) / zfa-iserlohn.de
|
||||
- [Zollernalbkreis](/doc/ics/abfall_io_ics.md) / zollernalbkreis.de
|
||||
- [Zweckverband Abfallwirtschaft Oberes Elbtal](/doc/ics/zaoe_de.md) / zaoe.de
|
||||
- [Zweckverband Abfallwirtschaft Südwestsachsen (ZAS)](/doc/ics/za_sws_de.md) / za-sws.de
|
||||
|
||||
|
||||
Reference in New Issue
Block a user