From 9546bf1dee8fc944ed0e9a205288eb2958aacc80 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Mon, 28 Oct 2024 22:43:09 +0100 Subject: [PATCH] Use shorthand attribute for native value in statistics (#129355) --- homeassistant/components/statistics/sensor.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/homeassistant/components/statistics/sensor.py b/homeassistant/components/statistics/sensor.py index 0bde1271720..50d07d4e466 100644 --- a/homeassistant/components/statistics/sensor.py +++ b/homeassistant/components/statistics/sensor.py @@ -360,7 +360,6 @@ class StatisticsSensor(SensorEntity): self.samples_keep_last: bool = samples_keep_last self._precision: int = precision self._percentile: int = percentile - self._value: float | int | datetime | None = None self._attr_available: bool = False self.states: deque[float | bool] = deque(maxlen=self._samples_max_buffer_size) @@ -585,11 +584,6 @@ class StatisticsSensor(SensorEntity): return None return SensorStateClass.MEASUREMENT - @property - def native_value(self) -> float | int | datetime | None: - """Return the state of the sensor.""" - return self._value - @property def extra_state_attributes(self) -> dict[str, StateType] | None: """Return the state attributes of the sensor.""" @@ -776,7 +770,7 @@ class StatisticsSensor(SensorEntity): value = round(cast(float, value), self._precision) if self._precision == 0: value = int(value) - self._value = value + self._attr_native_value = value def _callable_characteristic_fn( self, characteristic: str