Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
address API causing frequent state changes
  • Loading branch information
finity69x2 authored Dec 16, 2024
1 parent 3a97e75 commit 2e4a2ee
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/nws_alerts/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 2e4a2ee

Please sign in to comment.