Remove STATE_CLASS_TOTAL and last_reset from sensor (#54755)
* Remove STATE_CLASS_TOTAL * Update mill sensor * Update tests * Kill last_reset * Return ATTR_LAST_RESET to utility_meter * Update energy cost sensor * Restore last_reset for backwards compatibility * Re-add and update deprecation warning * Update tests * Fix utility_meter * Update EnergyCostSensor * Tweak * Fix rebase mistake * Fix test
This commit is contained in:
parent
85d9890447
commit
e1926caeb9
12 changed files with 68 additions and 251 deletions
|
@ -5,11 +5,7 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_LAST_RESET,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorEntity,
|
||||
)
|
||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONF_NAME,
|
||||
|
@ -58,6 +54,7 @@ ATTR_SOURCE_ID = "source"
|
|||
ATTR_STATUS = "status"
|
||||
ATTR_PERIOD = "meter_period"
|
||||
ATTR_LAST_PERIOD = "last_period"
|
||||
ATTR_LAST_RESET = "last_reset"
|
||||
ATTR_TARIFF = "tariff"
|
||||
|
||||
DEVICE_CLASS_MAP = {
|
||||
|
@ -352,6 +349,7 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
|||
ATTR_SOURCE_ID: self._sensor_source_id,
|
||||
ATTR_STATUS: PAUSED if self._collecting is None else COLLECTING,
|
||||
ATTR_LAST_PERIOD: self._last_period,
|
||||
ATTR_LAST_RESET: self._last_reset.isoformat(),
|
||||
}
|
||||
if self._period is not None:
|
||||
state_attr[ATTR_PERIOD] = self._period
|
||||
|
@ -363,8 +361,3 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
|||
def icon(self):
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
return ICON
|
||||
|
||||
@property
|
||||
def last_reset(self):
|
||||
"""Return the time when the sensor was last reset."""
|
||||
return self._last_reset
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue