add rhoen-grabfeld source

This commit is contained in:
Random-Cow
2022-10-15 16:17:22 +02:00
parent 2c3c39928b
commit e566f5e59e
3 changed files with 101 additions and 0 deletions

View File

@@ -105,6 +105,7 @@ Currently the following service providers are supported:
- [KAEV Niederlausitz](./doc/source/kaev_niederlausitz_de.md)
- [KWB-Goslar.de](./doc/source/kwb_goslar_de.md)
- [Landkreis-Wittmund.de](./doc/source/landkreis_wittmund_de.md)
- [Landkreis Rhön Grabfeld"](./doc/source/landkreis_rhoen_grabfeld.md)
- [Landkreis Schwäbisch Hall](./doc/source/lrasha_de.md)
- [Muellmax.de](./doc/source/muellmax_de.md)
- [MyMuell App](./doc/source/jumomind_de.md)

View File

@@ -0,0 +1,51 @@
import datetime
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "Source for Rhön Grabfeld"
DESCRIPTION = "Source for Rhönn Grabfeld uses service by offizium."
URL = 'https://fs-api-rg.offizium.com/abfalltermine'
TEST_CASES = {
"City only": {"city": "Ostheim"},
"City + District": {"city": "Ostheim", "district": "Oberwaldbehrungen"},
"District only": {"district": "Oberwaldbehrungen"},
"empty": {}
}
class Source:
def __init__(self, city: str = None, district: str = None):
self._city = city
self._district = district
self._iconMap = {
"Restmüll/Gelber Sack/Biotonne": "mdi:trash-can",
"Papiersammlung": "mdi:package-variant",
"Problemmüllsammlung": "mdi:biohazard"
}
def fetch(self):
now = datetime.datetime.now().date()
r = requests.get(URL, params={
"stadt": self._city,
"ortsteil": self._district
})
r.raise_for_status()
entries = []
for event in r.json():
# filter out Sammelstellen, Wertstoffhof and Wertstoffzentrum
if event["muellart"] in self._iconMap:
entries.append(
Collection(
date=datetime.datetime.fromisoformat(
event["termin"]).date(),
t=event["muellart"],
icon=self._iconMap.get(
event["muellart"], "mdi:trash-can")
)
)
return entries

View File

@@ -0,0 +1,49 @@
# Abfallkalender Würzburg
Support for schedules provided by [AbfallInfo Rhön Grabfeld](https://www.abfallinfo-rhoen-grabfeld.de/service/abfuhr-wecker), serving the rural district of Rhön Grabfeld.
Api in the background is provided by Offizium.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: landkreis_landkreis_rhoen_grabfeld
args:
district: DISTRICT
city: CITY
```
### Configuration Variables
**district** and **city** can be used independently, they can also be omitted to get the calender for the whole rural district.
**district**<br>
*(string)*
**street**<br>
*(string)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: landkreis_rhoen_grabfeld
args:
district: "Oberwaldbehrungen"
```
```yaml
waste_collection_schedule:
sources:
- name: landkreis_rhoen_grabfeld
args:
city: "Ostheim"
```
## How to get the source argument
To get the names used by the api navigate to the [collection alarm website](https://www.abfallinfo-rhoen-grabfeld.de/service/abfuhr-wecker), enter your city and district, select "Aktuelles Jahr als .ics-Datei exportieren" and copy the parameters from the corresponding download url.