From 614904512cda52a674fcc6cf70a9de56c6e163c1 Mon Sep 17 00:00:00 2001 From: Niels Perfors Date: Sun, 20 Aug 2023 13:45:58 +0200 Subject: [PATCH] Verisure Improve Unpack (#98696) --- .../components/verisure/coordinator.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/verisure/coordinator.py b/homeassistant/components/verisure/coordinator.py index bbfaed0a0a4..3779af4fd16 100644 --- a/homeassistant/components/verisure/coordinator.py +++ b/homeassistant/components/verisure/coordinator.py @@ -83,17 +83,15 @@ class VerisureDataUpdateCoordinator(DataUpdateCoordinator): raise UpdateFailed("Could not read overview") from err def unpack(overview: list, value: str) -> dict | list: - return ( - next( - ( - item["data"]["installation"][value] - for item in overview - if value in item.get("data", {}).get("installation", {}) - ), - [], - ) - or [] + unpacked: dict | list | None = next( + ( + item["data"]["installation"][value] + for item in overview + if value in item.get("data", {}).get("installation", {}) + ), + None, ) + return unpacked or [] # Store data in a way Home Assistant can easily consume it self._overview = overview