diff --git a/custom_components/nws_alerts/sensor.py b/custom_components/nws_alerts/sensor.py index 6e607ee..cd25574 100644 --- a/custom_components/nws_alerts/sensor.py +++ b/custom_components/nws_alerts/sensor.py @@ -5,7 +5,10 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME -from homeassistant.core import HomeAssistant +from homeassistant.core import ( + callback, + HomeAssistant, +) from homeassistant.helpers import config_validation as cv from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.entity import DeviceInfo @@ -108,3 +111,9 @@ def device_info(self) -> DeviceInfo: manufacturer="NWS", name="NWS Alerts", ) + + @callback + def _handle_coordinator_update(self) -> None: + """Handle updated data from the coordinator.""" + if self.coordinator.data != "AttributeError": + self.async_write_ha_state()