diff --git a/custom_components/alexa_media/sensor.py b/custom_components/alexa_media/sensor.py index c1451393..4b341772 100644 --- a/custom_components/alexa_media/sensor.py +++ b/custom_components/alexa_media/sensor.py @@ -17,6 +17,7 @@ SensorStateClass, ) from homeassistant.const import UnitOfTemperature, __version__ as HA_VERSION +from homeassistant.core import callback from homeassistant.exceptions import ConfigEntryNotReady, NoEntitySpecifiedError from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.event import async_track_point_in_utc_time @@ -266,6 +267,14 @@ def __init__(self, coordinator, entity_id, name, media_player_device_id): else None ) + @callback + def _handle_coordinator_update(self) -> None: + """Handle updated data from the coordinator.""" + self._attr_native_value = parse_temperature_from_coordinator( + self.coordinator, self.alexa_entity_id + ) + super()._handle_coordinator_update() + class AirQualitySensor(SensorEntity, CoordinatorEntity): """A air quality sensor reported by an Amazon indoor air quality monitor.""" @@ -307,6 +316,15 @@ def __init__( if media_player_device_id else None ) + self._instance = instance + + @callback + def _handle_coordinator_update(self) -> None: + """Handle updated data from the coordinator.""" + self._attr_native_value = parse_air_quality_from_coordinator( + self.coordinator, self.alexa_entity_id, self._instance + ) + super()._handle_coordinator_update() class AlexaMediaNotificationSensor(SensorEntity):