mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix possible unhandled IQVIA exception with allergy outlook data (#54477)
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
This commit is contained in:
parent
d6483f2f36
commit
98a4e6a7e8
@ -104,7 +104,7 @@ class ForecastSensor(IQVIAEntity):
|
||||
@callback
|
||||
def update_from_latest_data(self):
|
||||
"""Update the sensor."""
|
||||
if not self.coordinator.data:
|
||||
if not self.available:
|
||||
return
|
||||
|
||||
data = self.coordinator.data.get("Location", {})
|
||||
@ -120,6 +120,7 @@ class ForecastSensor(IQVIAEntity):
|
||||
if i["minimum"] <= average <= i["maximum"]
|
||||
]
|
||||
|
||||
self._attr_state = average
|
||||
self._attr_extra_state_attributes.update(
|
||||
{
|
||||
ATTR_CITY: data["City"].title(),
|
||||
@ -134,6 +135,10 @@ class ForecastSensor(IQVIAEntity):
|
||||
outlook_coordinator = self.hass.data[DOMAIN][DATA_COORDINATOR][
|
||||
self._entry.entry_id
|
||||
][TYPE_ALLERGY_OUTLOOK]
|
||||
|
||||
if not outlook_coordinator.last_update_success:
|
||||
return
|
||||
|
||||
self._attr_extra_state_attributes[
|
||||
ATTR_OUTLOOK
|
||||
] = outlook_coordinator.data.get("Outlook")
|
||||
@ -141,8 +146,6 @@ class ForecastSensor(IQVIAEntity):
|
||||
ATTR_SEASON
|
||||
] = outlook_coordinator.data.get("Season")
|
||||
|
||||
self._attr_state = average
|
||||
|
||||
|
||||
class IndexSensor(IQVIAEntity):
|
||||
"""Define sensor related to indices."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user