Add new attribute "abfall" (#2278)

* Update c_trace_de.py

add a new a attribute "abfall" to select specific waste types. Currently all types would be collected.
If the attribute is missing, all types will be collect.

* add documentation

* reformatting

---------

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
funknerGER
2024-07-30 15:09:11 +02:00
committed by GitHub
parent fb4f3682de
commit 33cce0cda7
2 changed files with 25 additions and 10 deletions

View File

@@ -160,7 +160,14 @@ BASE_URL = "https://{subdomain}.c-trace.de"
class Source:
def __init__(
self, strasse, hausnummer, gemeinde="", ort="", ortsteil="", service=None
self,
strasse,
hausnummer,
gemeinde="",
ort="",
ortsteil="",
service=None,
abfall="",
):
# Compatibility handling for Bremen which was the first supported
# district and didn't require to set a service name.
@@ -192,6 +199,9 @@ class Source:
self._base_url = BASE_URL.format(subdomain=subdomain)
self.ical_url_file = ical_url_file
self._ics = ICS(regex=r"Abfuhr: (.*)")
if not abfall:
abfall = "|".join(str(i) for i in range(0, 99))
self._abfall = abfall
def fetch(self):
session = requests.session()
@@ -213,7 +223,7 @@ class Source:
"Gemeinde": self._gemeinde,
"Strasse": self._strasse,
"Hausnr": self._hausnummer,
"Abfall": "|".join(str(i) for i in range(0, 99)), # return all waste types
"Abfall": self._abfall,
}
if self._ortsteil:
args["Ortsteil"] = self._ortsteil

View File

@@ -15,32 +15,37 @@ waste_collection_schedule:
ortsteil: ORTSTEIL
strasse: STRASSE
hausnummer: HAUSNUMMER
abfall: ABFALLARTEN
```
### Configuration Variables
**service**
*(string) (required)*
**service**
*(string) (required)*
Name of the service which is specific to your municipality. See the table below to get the right value for your location.
**ort**
**ort**
*(string) (optional)*
Needed for most municipalities but no all
**gemeinde**
**gemeinde**
*(string) (optional)*
Needed for some municipalities but not all (can be left empty if same as `ort` or unneeded)
**ortsteil**
**ortsteil**
*(string) (optional)*
Needed only for some municipalities but not all (can be left empty if unneeded)
**strasse**
**strasse**
*(string) (required)*
**hausnummer**
**hausnummer**
*(string) (required)*
**abfall**
*(string) (optional)*
Needed only to filter waste types (if empty you get all waste types). Separator between waste types is '|'.
## Example
```yaml
@@ -122,4 +127,4 @@ Link for above image: https://web.c-trace.de/segebergwzv-abfallkalender/(S(ebi2z
From this Link you can extract the following parameters:
`web|app`.c-trace.de/`(web.)service`/some-id/abfallkalender/`cal|downloadcal` `/year|`?Ort=`ort`&Ortsteil=`ortsteil`&Strasse=`strasse`&Hausnr=`hausnummer`...
`web|app`.c-trace.de/`(web.)service`/some-id/abfallkalender/`cal|downloadcal` `/year|`?Ort=`ort`&Ortsteil=`ortsteil`&Strasse=`strasse`&Hausnr=`hausnummer`&abfall='abfallarten'...