From a9efde71a090b09777a3c4d8927b0b8fb4a8f998 Mon Sep 17 00:00:00 2001 From: syre Date: Tue, 9 Apr 2024 07:56:49 +0200 Subject: [PATCH] add include_ordered_pickup_entries --- .../source/renoweb_dk.py | 16 ++++++++++++++-- doc/source/renoweb_dk.md | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/renoweb_dk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/renoweb_dk.py index eb4df4bf..8e87b99f 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/renoweb_dk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/renoweb_dk.py @@ -27,6 +27,11 @@ TEST_CASES = { "municipality": "rudersdal", "address": "Stationsvej 38", }, + "test_04": { + "municipality": "fh", + "address": "Odinsvej 58", + "include_ordered_pickup_entries": True, + }, } _LOGGER = logging.getLogger("waste_collection_schedule.renoweb_dk") @@ -43,15 +48,18 @@ class Source: municipality: str, address: str | None = None, address_id: int | None = None, + include_ordered_pickup_entries: bool = False, ): _LOGGER.debug( - "Source.__init__(); municipality=%s, address_id=%s, address=%s", + "Source.__init__(); municipality=%s, address_id=%s, address=%s, include_ordered_pickup_entries=%s", municipality, address_id, address, + include_ordered_pickup_entries, ) self._api_url = API_URL.format(municipality=municipality.lower()) + self._include_ordered_pickup_entries = include_ordered_pickup_entries if address_id: self.__address_id = address_id @@ -116,7 +124,11 @@ class Source: raise ValueError("No waste schemes found, check address or address_id") for entry in waste_schemes: - if not entry["afhentningsbestillingmateriel"] and re.search( + include_entry = ( + self._include_ordered_pickup_entries + or not entry["afhentningsbestillingmateriel"] + ) + if include_entry and re.search( r"dag den \d{2}-\d{2}-\d{4}", entry["toemningsdato"] ): response = self._session.post( diff --git a/doc/source/renoweb_dk.md b/doc/source/renoweb_dk.md index 227d22ba..3b90fd1f 100644 --- a/doc/source/renoweb_dk.md +++ b/doc/source/renoweb_dk.md @@ -33,6 +33,11 @@ Use address_id if the address lookup fails. _Note that while both **address** and **address_id** are optional, one of them must be supplied and if both are used, **address_id** will take precedence._ +**include_ordered_pickup_entries** +_(Bool) (optional)_ + +Whether to include entries that are not collected automatically but should be ordered for pickup (has 'afhentningsbestillingmateriel' = True). + ## Example ```yaml