mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
improve stadtreinigung dresden code and docu
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import datetime
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from waste_collection_schedule.service.ICS import ICS
|
||||
|
||||
|
||||
TITLE = "Stadtreinigung Dresden"
|
||||
DESCRIPTION = "Source for Stadtreinigung Dresden waste collection."
|
||||
URL = "https://stadtplan.dresden.de/project/cardo3Apps/IDU_DDStadtplan/abfall/ical.ashx"
|
||||
URL = "https://www.dresden.de/apps_ext/AbfallApp/wastebins?0"
|
||||
TEST_CASES = {
|
||||
"Neumarkt 6": {"standort": 80542},
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, standort, asId=None):
|
||||
def __init__(self, standort):
|
||||
self._standort = standort
|
||||
self._ics = ICS()
|
||||
|
||||
@@ -22,7 +22,7 @@ class Source:
|
||||
now = datetime.datetime.now().date()
|
||||
|
||||
r = requests.get(
|
||||
URL,
|
||||
"https://stadtplan.dresden.de/project/cardo3Apps/IDU_DDStadtplan/abfall/ical.ashx",
|
||||
params={
|
||||
"STANDORT": self._standort,
|
||||
"DATUM_VON": now.strftime("%d.%m.%Y"),
|
||||
@@ -32,7 +32,14 @@ class Source:
|
||||
|
||||
dates = self._ics.convert(r.text)
|
||||
|
||||
# example: "Leerung Gelbe Tonne, Bio-Tonne"
|
||||
|
||||
entries = []
|
||||
for d in dates:
|
||||
entries.append(Collection(d[0], d[1]))
|
||||
if d[1] == "Abfallkalender endet bald":
|
||||
continue
|
||||
|
||||
types = d[1].removeprefix("Leerung ")
|
||||
for type in types.split(", "):
|
||||
entries.append(Collection(d[0], type))
|
||||
return entries
|
||||
|
||||
@@ -7,7 +7,7 @@ Add support for schedules provided by [https://www.dresden.de/](https://www.dres
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: stadtreinigung_dresden
|
||||
- name: stadtreinigung_dresden_de
|
||||
args:
|
||||
standort: STANDORT_ID
|
||||
```
|
||||
@@ -22,7 +22,7 @@ waste_collection_schedule:
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: stadtreinigung_dresden
|
||||
- name: stadtreinigung_dresden_de
|
||||
args:
|
||||
standort: 80542
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user