From ea564aa96755b99446437b54c905e4999cae5de6 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Thu, 26 Oct 2023 14:48:33 +1100 Subject: [PATCH] Fixing problem where organic isn't shown properly --- .../source/innerwest_nsw_gov_au.py | 36 ++++++++++--------- doc/source/innerwest_nsw_gov_au.md | 9 +++++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py index cb755358b..2263afc89 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/innerwest_nsw_gov_au.py @@ -38,6 +38,7 @@ "waste": "mdi:trash-can", "recycle": "mdi:recycle", "organic": "mdi:leaf", + "special": "mdi:star", } @@ -114,23 +115,24 @@ def fetch(self): entries = [] for item in data: - if "start" not in item and "start_date" not in item: - continue - key = ( - "start" - if "start" in item - else "start_date" - if "start_date" in item - else "" - ) - collection_date = date.fromisoformat(item[key]) - if (collection_date - today).days >= 0: - entries.append( - Collection( - date=collection_date, - t=item["event_type"], - icon=ICON_MAP.get(item["event_type"]), + if "start" in item: + collection_date = date.fromisoformat(item["start"]) + if (collection_date - today).days >= 0: + # Only consider recycle and waste events as they are fortnightly + if item["event_type"] in ["recycle", "waste"]: + # Every collection day includes organic + entries.append( + Collection( + date=collection_date, t="organic", icon="mdi:leaf" + ) + ) + + entries.append( + Collection( + date=collection_date, + t=item["event_type"], + icon=ICON_MAP.get(item["event_type"]), + ) ) - ) return entries diff --git a/doc/source/innerwest_nsw_gov_au.md b/doc/source/innerwest_nsw_gov_au.md index 6a5a7bacb..b1b6b4b4c 100644 --- a/doc/source/innerwest_nsw_gov_au.md +++ b/doc/source/innerwest_nsw_gov_au.md @@ -40,3 +40,12 @@ waste_collection_schedule: ## How to get the source arguments Visit the [Inner West Council (NSW)](https://www.innerwest.nsw.gov.au/live/waste-and-recycling/bins-and-clean-ups/waste-calendar) page and search for your address. The arguments should exactly match the results shown for Suburb and Street and the number portion of the Property. + +## Known collection types + +The following is a list of known collection types (`event_type` in the API): + +- organic +- waste +- recycle +- special