mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Remove last_reset
attribute and set state class to total_increasing
for sense energy sensors (#54825)
This commit is contained in:
parent
9947795068
commit
4892f6b094
@ -1,7 +1,9 @@
|
|||||||
"""Support for monitoring a Sense energy sensor."""
|
"""Support for monitoring a Sense energy sensor."""
|
||||||
import datetime
|
from homeassistant.components.sensor import (
|
||||||
|
STATE_CLASS_MEASUREMENT,
|
||||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
SensorEntity,
|
||||||
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
ATTR_ATTRIBUTION,
|
||||||
DEVICE_CLASS_ENERGY,
|
DEVICE_CLASS_ENERGY,
|
||||||
@ -12,7 +14,6 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
import homeassistant.util.dt as dt_util
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ACTIVE_NAME,
|
ACTIVE_NAME,
|
||||||
@ -223,7 +224,7 @@ class SenseTrendsSensor(SensorEntity):
|
|||||||
"""Implementation of a Sense energy sensor."""
|
"""Implementation of a Sense energy sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_ENERGY
|
_attr_device_class = DEVICE_CLASS_ENERGY
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||||
_attr_icon = ICON
|
_attr_icon = ICON
|
||||||
@ -258,13 +259,6 @@ class SenseTrendsSensor(SensorEntity):
|
|||||||
"""Return if entity is available."""
|
"""Return if entity is available."""
|
||||||
return self._had_any_update and self._coordinator.last_update_success
|
return self._had_any_update and self._coordinator.last_update_success
|
||||||
|
|
||||||
@property
|
|
||||||
def last_reset(self) -> datetime.datetime:
|
|
||||||
"""Return the time when the sensor was last reset, if any."""
|
|
||||||
if self._sensor_type == "DAY":
|
|
||||||
return dt_util.start_of_local_day()
|
|
||||||
return None
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update(self):
|
def _async_update(self):
|
||||||
"""Track if we had an update so we do not report zero data."""
|
"""Track if we had an update so we do not report zero data."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user