From 1de7d6718c33b2dd0ef76b5d81801c17a9abb20f Mon Sep 17 00:00:00 2001 From: Tomasz Sienicki Date: Sat, 2 Nov 2024 11:30:20 +0100 Subject: [PATCH] Fix warszawa19115 response schedule new field name and check it is not null --- .../waste_collection_schedule/source/warszawa19115_pl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py index aeed08894..02aed48e7 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/warszawa19115_pl.py @@ -121,10 +121,12 @@ def fetch(self): calendar_result = calendar_request.json() _LOGGER.debug(f"Calendar response: {calendar_result!r}") + harmonogramy = "harmonogramyZ" if ( len(calendar_result) <= 0 - or "harmonogramy" not in calendar_result[0] - or len(calendar_result[0]["harmonogramy"]) <= 0 + or harmonogramy not in calendar_result[0] + or not calendar_result[0][harmonogramy] + or len(calendar_result[0][harmonogramy]) <= 0 ): raise SourceParseError( "Expected list of dates from calendar search, got empty or missing list" @@ -133,7 +135,7 @@ def fetch(self): entries = [] for result in calendar_result: - for entry in result["harmonogramy"]: + for entry in result[harmonogramy]: if entry["data"]: original_type = entry["frakcja"]["id_frakcja"] waste_type = NAME_MAP.get(original_type, original_type)