mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use shorthand attribute for native value in statistics (#129355)
This commit is contained in:
parent
dd9ce34d18
commit
9546bf1dee
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user