Merge pull request #183 from tschnilo/stadtreinigung_dresden_de

add source for Stadtreinigung Dresden
This commit is contained in:
Steffen Zimmermann
2022-03-22 20:22:53 +01:00
committed by GitHub
4 changed files with 80 additions and 0 deletions

View File

@@ -92,6 +92,7 @@ Currently the following service providers are supported:
- [MyMuell App](./doc/source/jumomind_de.md)
- [Rhein-Hunsrück Entsorgung (RHE)](./doc/source/rh_entsorgung_de.md)
- [Sector27.de](./doc/source/sector27_de.md)
- [Stadtreinigung Dresden](./doc/source/stadtreinigung_dresden_de.md)
- [Stadtreinigung.Hamburg](./doc/source/stadtreinigung_hamburg.md)
- [Stadtreinigung-Leipzig.de](./doc/source/stadtreinigung_leipzig_de.md)
- [WAS Wolfsburg](./doc/source/was_wolfsburg_de.md)

View File

@@ -0,0 +1,38 @@
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"
TEST_CASES = {
"Neumarkt 6": {"standort": 80542},
}
class Source:
def __init__(self, standort, asId=None):
self._standort = standort
self._ics = ICS()
def fetch(self):
now = datetime.datetime.now().date()
r = requests.get(
URL,
params={
"STANDORT": self._standort,
"DATUM_VON": now.strftime("%d.%m.%Y"),
"DATUM_BIS": (now + datetime.timedelta(days=365)).strftime("%d.%m.%Y"),
},
)
dates = self._ics.convert(r.text)
entries = []
for d in dates:
entries.append(Collection(d[0], d[1]))
return entries

View File

@@ -0,0 +1,40 @@
# Stadtreinigung Dresden
Add support for schedules provided by [https://www.dresden.de/](https://www.dresden.de/apps_ext/AbfallApp/wastebins?0).
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: stadtreinigung_dresden
args:
standort: STANDORT_ID
```
### Configuration Variables
**standort**<br>
*(string) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: stadtreinigung_dresden
args:
standort: 80542
```
## How to get the source arguments
Open [https://www.dresden.de/](https://www.dresden.de/apps_ext/AbfallApp/wastebins?0) and search for schedules for your location.
Check the Link-URL for downloading the schedules as *.PDF and extract the number after field `STANDORT`.
Example:
`https://stadtplan.dresden.de/project/cardo3Apps/IDU_DDStadtplan/abfall/kalender.ashx?STANDORT=80542&DUMMY=637834733764191577`
The resulting `STANDORT_ID` is `80542`.

View File

@@ -78,6 +78,7 @@ Currently the following service providers are supported:
- [MyMuell App](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/jumomind_de.md)
- [Rhein-Hunsrück Entsorgung (RHE)](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/rh_entsorgung_de.md)
- [Sector27.de](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/sector27_de.md)
- [Stadtreinigung Dresden](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/stadtreinigung_dresden_de.md)
- [Stadtreinigung.Hamburg](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/stadtreinigung_hamburg.md)
- [Stadtreinigung-Leipzig.de](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/stadtreinigung_leipzig_de.md)
- [WAS Wolfsburg](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/was_wolfsburg_de.md)