-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added hubert schmid gmbh * fixed review feedback and added test cases * reformatting --------- Co-authored-by: 5ila5 <[email protected]>
- Loading branch information
1 parent
ada82e6
commit a71e2e1
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...onents/waste_collection_schedule/waste_collection_schedule/source/api_hubert_schmid_de.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from datetime import datetime | ||
|
||
import requests | ||
from waste_collection_schedule import Collection # type: ignore[attr-defined] | ||
|
||
TITLE = "HubertSchmid Recycling und Umweltschutz GmbH" | ||
DESCRIPTION = "Abfuhrtermine Blaue Tonne" | ||
URL = "https://www.hschmid24.de/BlaueTonne/" | ||
API_URL = "https://www.hschmid24.de/BlaueTonne/php/ajax.php" | ||
|
||
TEST_CASES = { | ||
"Albatsried(Seeg)": {"city": "Albatsried(Seeg)"}, | ||
"Nesselwang > Attlesee": {"city": "Nesselwang", "ortsteil": "Attlesee"}, | ||
"Buchloe > Hausen > Dorfstraße": { | ||
"city": "Buchloe", | ||
"ortsteil": "Hausen", | ||
"strasse": "Dorfstraße", | ||
}, | ||
} | ||
|
||
|
||
class Source: | ||
def __init__( | ||
self, | ||
city: str, | ||
ortsteil: str | None = None, | ||
strasse: str | None = None, | ||
): | ||
self._city = city | ||
self._ortsteil = ortsteil | ||
self._strasse = strasse | ||
|
||
def fetch(self): | ||
r = requests.post( | ||
f"{API_URL}", | ||
data={"l": 3, "p1": self._city, "p2": self._ortsteil, "p3": self._strasse}, | ||
) | ||
|
||
r.raise_for_status() | ||
calendarEntries = r.json()["cal"] | ||
|
||
entries = [] | ||
for entry in calendarEntries: | ||
if entry != "0000-00-00": | ||
entries.append( | ||
Collection( | ||
date=datetime.strptime(entry, "%Y-%m-%d").date(), | ||
t="Blaue Tonne", | ||
icon="mdi:package-variant", | ||
) | ||
) | ||
|
||
return entries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Hubert Schmid GmbH (Blaue Tonne) Landkreis Ostallgäu | ||
|
||
Support for schedules provided by [Hubert Schmid GmbH](https://www.hschmid24.de/BlaueTonne/), serving in Ostallgäu, Bavaria, Germany. | ||
|
||
## Configuration via configuration.yaml | ||
|
||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: api_hubert_schmid_de | ||
args: | ||
city: STADT/KOMMUNE | ||
ortsteil: ORTSTEIL | ||
strasse: STRASSE | ||
|
||
``` | ||
### Configuration Variables | ||
**city** | ||
*(String) (required)* | ||
**strasse** | ||
*(String) (optional)* | ||
**ortsteil** | ||
*(String) (optional)* | ||
## Examples | ||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: api_hubert_schmid_de | ||
args: | ||
city: Füssen | ||
ortsteil: Eschach | ||
strasse: Schorrenmoos | ||
``` | ||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: api_hubert_schmid_de | ||
args: | ||
city: Emmenhausen(Waal) | ||
strasse: Am Hofanger | ||
``` | ||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: api_hubert_schmid_de | ||
args: | ||
app_id: de.k4systems.abfallappwug | ||
city: Bergen | ||
strasse: Alle Straßen | ||
``` | ||
## How to get the source arguments | ||
Use the website (https://www.hschmid24.de/BlaueTonne/) to find the exact notation of the city, street and optional district. |
Oops, something went wrong.