diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py index fa71bf82..a58abaf4 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/awido_de.py @@ -26,6 +26,7 @@ TEST_CASES = { "city": "Kaufbeuren", "street": "Rehgrund", }, + "Tübingen, Dettenhausen": {"customer": "tuebingen", "city": "Dettenhausen"}, } _LOGGER = logging.getLogger(__name__) @@ -54,7 +55,25 @@ class Source: oid = city_to_oid[self._city] - if self._street is not None: + if self._street is None: + # test if we have to use city also as street name + self._street = self._city + r = requests.get( + f"https://awido.cubefour.de/WebServices/Awido.Service.svc/secure/getGroupedStreets/{oid}", + params={"client": self._customer}, + ) + streets = json.loads(r.text) + + # create street to key map from retrieved places + street_to_oid = { + street["value"].strip(): street["key"] for (street) in streets + } + + if self._street in street_to_oid: + oid = street_to_oid[self._street] + + else: + # street specified r = requests.get( f"https://awido.cubefour.de/WebServices/Awido.Service.svc/secure/getGroupedStreets/{oid}", params={"client": self._customer}, diff --git a/doc/source/awido_de.md b/doc/source/awido_de.md index 2a34142b..e1d6c5bc 100644 --- a/doc/source/awido_de.md +++ b/doc/source/awido_de.md @@ -84,6 +84,6 @@ List of customers (2021-07-09): ### city, street, house number - Go to your calendar at `https://awido.cubefour.de/Customer//v2/Calendar2.aspx`. Replace `` with the one of the keys listed above. -- Enter your city name from the first page into the `city` field, except for single-city customers, then the parameter `city` is the city. +- Enter your city name from the first page into the `city` field. - If you have to enter a street or district, enter the name into the `street` field. - If you have to enter a house number, enter the house number into the `housenumber` field.