Remove last_reset attribute from devolo energy sensors (#54803)

This commit is contained in:
Erik Montnemery 2021-08-18 13:55:21 +02:00 committed by GitHub
parent d9bfb8fc58
commit 0b7b4152f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,7 @@ from homeassistant.components.sensor import (
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
)
from homeassistant.config_entries import ConfigEntry
@ -162,10 +162,7 @@ class DevoloConsumptionEntity(DevoloMultiLevelDeviceEntity):
)
if consumption == "total":
self._attr_state_class = STATE_CLASS_MEASUREMENT
self._attr_last_reset = device_instance.consumption_property[
element_uid
].total_since
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
self._value = getattr(
device_instance.consumption_property[element_uid], consumption
@ -180,15 +177,11 @@ class DevoloConsumptionEntity(DevoloMultiLevelDeviceEntity):
def _sync(self, message: tuple) -> None:
"""Update the consumption sensor state."""
if message[0] == self._attr_unique_id and message[2] != "total_since":
if message[0] == self._attr_unique_id:
self._value = getattr(
self._device_instance.consumption_property[self._attr_unique_id],
self._sensor_type,
)
elif message[0] == self._attr_unique_id and message[2] == "total_since":
self._attr_last_reset = self._device_instance.consumption_property[
self._attr_unique_id
].total_since
else:
self._generic_message(message)
self.schedule_update_ha_state()