From 3518a31f3bbc730757b59676899fa0be47e858b0 Mon Sep 17 00:00:00 2001 From: 5ila5 <5ila5@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:39:54 +0200 Subject: [PATCH] =?UTF-8?q?abfallnavi=20make=20street=20an=20optional=20pa?= =?UTF-8?q?rameter=20if=20only=20one=20street=20(like=20alle=20Stra=C3=9Fe?= =?UTF-8?q?n=20is=20returned)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../waste_collection_schedule/service/AbfallnaviDe.py | 6 ++++++ .../waste_collection_schedule/source/abfallnavi_de.py | 11 ++++++++++- doc/source/abfallnavi_de.md | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/service/AbfallnaviDe.py b/custom_components/waste_collection_schedule/waste_collection_schedule/service/AbfallnaviDe.py index efcff1cb..bd44961c 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/service/AbfallnaviDe.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/service/AbfallnaviDe.py @@ -186,6 +186,12 @@ class AbfallnaviDe: may return multiple on change of id (may occur on year change) """ streets = self.get_streets(city_id) + if len(streets) == 1: + return list(streets.keys()) + if street is None: + raise Exception( + f"Multiple streets found for city: {city_id} please specify street, one of: {streets.values()}" + ) return [id for id, name in streets.items() if name == street] def get_house_numbers(self, street_id): diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py index 0f9ff230..363eff51 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/abfallnavi_de.py @@ -43,12 +43,21 @@ TEST_CASES = { "ort": "Bergkamen", "strasse": "Agnes-Miegel-Str.", }, + "Pinneberg Kummerfeld no Street": { + "service": "pi", + "ort": "Kummerfeld", + "strasse": "alle Straßen", + }, } class Source: def __init__( - self, service: str, ort: str, strasse: str, hausnummer: str | int | None = None + self, + service: str, + ort: str, + strasse: str | None = None, + hausnummer: str | int | None = None, ): self._api = AbfallnaviDe(service) self._ort = ort diff --git a/doc/source/abfallnavi_de.md b/doc/source/abfallnavi_de.md index ff8831d0..dc98176c 100644 --- a/doc/source/abfallnavi_de.md +++ b/doc/source/abfallnavi_de.md @@ -24,7 +24,8 @@ waste_collection_schedule: *(string) (required)* **strasse** -*(string) (required)* +*(string) (optional)* +*required if the service provider website requests it* **hausnummer** *(string | Integer) (optional)*