From 47f8250bdd40eb9a4b4f842498b3cd4af5968062 Mon Sep 17 00:00:00 2001 From: jberrenberg Date: Thu, 2 Dec 2021 12:44:55 +0100 Subject: [PATCH] fix problem in ics source When trying to prefetch the next year the component crashed when no year_field was provided. Additionally there was a syntax error in the fetching of next years ics. --- .../waste_collection_schedule/source/ics.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py index 0d94b0619..47c2598a4 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py @@ -159,10 +159,11 @@ def fetch(self): if now.month == 12: # also get data for next year if we are already in december url = self._url.replace("{%Y}", str(now.year + 1)) - self._params[self._year_field] = str(now.year + 1) + if self._year_field is not None: + self._params[self._year_field] = str(now.year + 1) try: - entries.extend(self.fetch_url(url), self._params) + entries.extend(self.fetch_url(url, self._params)) except Exception: # ignore if fetch for next year fails pass