From 87e23e5d438c8703faea1180381b2200dc0a6f5e Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 18 Aug 2021 11:33:29 +0200 Subject: [PATCH] Remove last_reset attribute from devolo energy sensors --- .../components/devolo_home_control/sensor.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/devolo_home_control/sensor.py b/homeassistant/components/devolo_home_control/sensor.py index 5c8bed7818ba7..61c3e9a5c195f 100644 --- a/homeassistant/components/devolo_home_control/sensor.py +++ b/homeassistant/components/devolo_home_control/sensor.py @@ -12,7 +12,7 @@ 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 @@ def __init__( ) 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 @@ def unique_id(self) -> str: 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()