mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix unhandled exception when IQVIA API fails to return data (#43359)
This commit is contained in:
parent
be39104a36
commit
3ffd97acd4
@ -155,6 +155,9 @@ class IQVIAEntity(CoordinatorEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""Handle updated data from the coordinator."""
|
||||||
|
if not self.coordinator.last_update_success:
|
||||||
|
return
|
||||||
|
|
||||||
self.update_from_latest_data()
|
self.update_from_latest_data()
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ class ForecastSensor(IQVIAEntity):
|
|||||||
def update_from_latest_data(self):
|
def update_from_latest_data(self):
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
data = self.coordinator.data.get("Location")
|
data = self.coordinator.data.get("Location")
|
||||||
|
|
||||||
if not data or not data.get("periods"):
|
if not data or not data.get("periods"):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -142,6 +143,9 @@ class IndexSensor(IQVIAEntity):
|
|||||||
@callback
|
@callback
|
||||||
def update_from_latest_data(self):
|
def update_from_latest_data(self):
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
|
if not self.coordinator.last_update_success:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._type in (TYPE_ALLERGY_TODAY, TYPE_ALLERGY_TOMORROW):
|
if self._type in (TYPE_ALLERGY_TODAY, TYPE_ALLERGY_TOMORROW):
|
||||||
data = self.coordinator.data.get("Location")
|
data = self.coordinator.data.get("Location")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user