diff --git a/homeassistant/components/watttime/sensor.py b/homeassistant/components/watttime/sensor.py index f44249ecde1..4453044e0d2 100644 --- a/homeassistant/components/watttime/sensor.py +++ b/homeassistant/components/watttime/sensor.py @@ -17,8 +17,9 @@ from homeassistant.const import ( MASS_POUNDS, PERCENTAGE, ) -from homeassistant.core import HomeAssistant, callback +from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -115,20 +116,7 @@ class RealtimeEmissionsSensor(CoordinatorEntity, SensorEntity): self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}" self.entity_description = description - @callback - def _handle_coordinator_update(self) -> None: - """Respond to a DataUpdateCoordinator update.""" - self.update_from_latest_data() - self.async_write_ha_state() - - async def async_added_to_hass(self) -> None: - """Handle entity which will be added.""" - await super().async_added_to_hass() - self.update_from_latest_data() - - @callback - def update_from_latest_data(self) -> None: - """Update the state.""" - self._attr_native_value = self.coordinator.data[ - self.entity_description.data_key - ] + @property + def native_value(self) -> StateType: + """Return the value reported by the sensor.""" + return self.coordinator.data[self.entity_description.data_key]