mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Add ahk_heidekreis
This commit is contained in:
@@ -642,6 +642,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Abfallwirtschaftszweckverband Wartburgkreis (AZV)](/doc/source/hausmuell_info.md) / azv-wak-ea.de
|
||||
- [Abfallzweckverband Rhein-Mosel-Eifel (Landkreis Mayen-Koblenz)](/doc/source/abfall_io.md) / azv-rme.de
|
||||
- [AHE Ennepe-Ruhr-Kreis](/doc/source/ahe_de.md) / ahe.de
|
||||
- [AHK Heidekreis](/doc/source/ahk_heidekreis_de.md) / ahk-heidekreis.de
|
||||
- [ALBA Berlin](/doc/source/abfall_io.md) / berlin.alba.info
|
||||
- [ALBA Braunschweig](/doc/ics/alba_bs_de.md) / alba-bs.de
|
||||
- [ALF Lahn-Fulda](/doc/source/app_abfallplus_de.md) / Abfall+ App: abfallhr
|
||||
|
||||
@@ -3062,6 +3062,11 @@
|
||||
"module": "ahe_de",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "AHK Heidekreis",
|
||||
"module": "ahk_heidekreis_de",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "ALBA Berlin",
|
||||
"module": "abfall_io",
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from waste_collection_schedule.service.ICS import ICS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
TITLE = "AHK Heidekreis"
|
||||
DESCRIPTION = "Source for Abfallwirtschaft Heidekreis."
|
||||
URL = "https://www.ahk-heidekreis.de/"
|
||||
TEST_CASES = {
|
||||
"Munster - Wagnerstr. 10-18": {
|
||||
"city": "Munster",
|
||||
"postcode": "29633",
|
||||
"street": "Wagnerstr.",
|
||||
"house_number": "10-18",
|
||||
},
|
||||
"Fallingbostel - Konrad-Zuse-Str. 4": {
|
||||
"city": "Fallingbostel/Bad Fallingbostel",
|
||||
"postcode": 29683,
|
||||
"street": "Konrad-Zuse-Str.",
|
||||
"house_number": 4,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, city, postcode, street, house_number):
|
||||
self._city = city
|
||||
self._postcode = str(postcode)
|
||||
self._street = street
|
||||
self._house_number = str(house_number)
|
||||
self._ics = ICS()
|
||||
|
||||
def fetch(self):
|
||||
params = {
|
||||
"PartialName": self._street,
|
||||
}
|
||||
|
||||
# get list of streets and house numbers
|
||||
r = requests.get(
|
||||
"https://ahkwebapi.heidekreis.de/api/QMasterData/QStreetByPartialName",
|
||||
params=params,
|
||||
)
|
||||
|
||||
data = json.loads(r.text)
|
||||
if len(data) == 0:
|
||||
raise Exception(f"street not found: {self._street}")
|
||||
|
||||
street_entry = next(
|
||||
(
|
||||
item
|
||||
for item in data
|
||||
if item["name"] == self._street
|
||||
and item["plz"] == self._postcode
|
||||
and item["place"] == self._city
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
if street_entry is None:
|
||||
raise Exception(f"street not found: {self._street}")
|
||||
|
||||
params = {"StreetId": street_entry["id"]}
|
||||
r = requests.get(
|
||||
"https://ahkwebapi.heidekreis.de/api/QMasterData/QHouseNrEkal",
|
||||
params=params,
|
||||
)
|
||||
r.raise_for_status()
|
||||
|
||||
data = json.loads(r.text)
|
||||
if len(data) == 0:
|
||||
raise Exception(f"No house_number not found: {self._street}")
|
||||
|
||||
house_number_entry = next(
|
||||
(
|
||||
item
|
||||
for item in data
|
||||
if f"{item["houseNr"]}{item["houseNrAdd"]}" == self._house_number
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
if house_number_entry is None:
|
||||
raise Exception(f"house_number not found: {self._house_number}")
|
||||
|
||||
# get ics file
|
||||
params = {
|
||||
"von": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
|
||||
+ "Z",
|
||||
"bis": (datetime.now(timezone.utc) + timedelta(days=365)).strftime(
|
||||
"%Y-%m-%dT%H:%M:%S.%f"
|
||||
)[:-3]
|
||||
+ "Z",
|
||||
"benachrichtigungVorJederAbholung": False,
|
||||
"abholbenachrichtigungTageVorher": 1,
|
||||
"abholbenachrichtigungUhrzeit": {
|
||||
"ticks": 28800000,
|
||||
"sekunden": 28800,
|
||||
"minuten": 480,
|
||||
"stunden": 8,
|
||||
},
|
||||
"benachrichtigungNächsterKalender": False,
|
||||
"kalenderBenachrichtigungTageVorEnde": 3,
|
||||
"kalenderbenachrichtigungUhrzeit": {
|
||||
"ticks": 28800000,
|
||||
"sekunden": 28800,
|
||||
"minuten": 480,
|
||||
"stunden": 8,
|
||||
},
|
||||
}
|
||||
headers = {"content-type": "application/json"}
|
||||
|
||||
r = requests.post(
|
||||
f"https://ahkwebapi.heidekreis.de/api/object/{house_number_entry["idObject"]}/QDisposalScheduler/asIcal",
|
||||
data=json.dumps(params),
|
||||
headers=headers,
|
||||
)
|
||||
dates = self._ics.convert(r.text)
|
||||
|
||||
entries = []
|
||||
for d in dates:
|
||||
_LOGGER.info("%s - %s", d[0], d[1])
|
||||
entries.append(Collection(d[0], d[1].removesuffix(", ")))
|
||||
return entries
|
||||
53
doc/source/ahk_heidekreis_de.md
Normal file
53
doc/source/ahk_heidekreis_de.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# AHK Heidekreis
|
||||
|
||||
Support for schedules provided by [ahk-heidekreis.de](https://www.ahk-heidekreis.de/).
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: ahk_heidekreis_de
|
||||
args:
|
||||
city: CITY
|
||||
postcode: POSTCODE
|
||||
street: STREET
|
||||
house_number: HOUSE_NUMBER
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**city**
|
||||
_(string) (required)_
|
||||
|
||||
**postcode**
|
||||
_(string) (required)_
|
||||
|
||||
**street**
|
||||
_(string) (required)_
|
||||
|
||||
**house_number**
|
||||
_(string) (required)_
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: ahk_heidekreis_de
|
||||
args:
|
||||
city: Munster
|
||||
postcode: 29633
|
||||
street: Wagnerstr.
|
||||
house_number: "10-18"
|
||||
- name: ahk_heidekreis_de
|
||||
args:
|
||||
city: Fallingbostel/Bad Fallingbostel
|
||||
postcode: "29683"
|
||||
street: Konrad-Zuse-Str.
|
||||
house_number: "4"
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Find the parameter of your address using [https://www.ahk-heidekreis.de/fuer-privatkunden/abfuhrzeiten.html](https://www.ahk-heidekreis.de/fuer-privatkunden/abfuhrzeiten.html), click on "Entsorgungskalender", use the address lookup and write them exactly like on the web page.
|
||||
Reference in New Issue
Block a user