Fix unhandled exception with missing IQVIA data (#125114)

pull/124880/head
Aaron Bach 2024-09-03 06:21:52 -06:00 committed by Bram Kragten
parent a0bbcb0401
commit 393a0ac0df
1 changed files with 2 additions and 2 deletions

View File

@ -244,8 +244,8 @@ class IndexSensor(IQVIAEntity, SensorEntity):
key = self.entity_description.key.split("_")[-1].title()
try:
[period] = [p for p in data["periods"] if p["Type"] == key] # type: ignore[index]
except TypeError:
period = next(p for p in data["periods"] if p["Type"] == key) # type: ignore[index]
except StopIteration:
return
data = cast(dict[str, Any], data)