Skip to content

Commit

Permalink
Merge pull request #1837 from custom-components/1824
Browse files Browse the repository at this point in the history
fix: update coordinator callback to update sensors
  • Loading branch information
alandtse authored Jan 14, 2023
2 parents f55b398 + 708b6c5 commit d521dc7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d521dc7

Please sign in to comment.