Verisure Improve Unpack (#98696)

pull/98704/head
Niels Perfors 2023-08-20 13:45:58 +02:00 committed by GitHub
parent e484066f2b
commit 614904512c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 10 deletions

View File

@ -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(
unpacked: dict | list | None = next(
(
item["data"]["installation"][value]
for item in overview
if value in item.get("data", {}).get("installation", {})
),
[],
)
or []
None,
)
return unpacked or []
# Store data in a way Home Assistant can easily consume it
self._overview = overview