From 4f63472c29f36b1610996ad815d7f64791907123 Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 18 Aug 2021 14:55:38 +0200 Subject: [PATCH 1/2] Remove last_reset attribute from mysensors energy sensors --- homeassistant/components/mysensors/sensor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index 68fdf2a21b2508..94a9cde1df288b 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -9,6 +9,7 @@ from homeassistant.components.sensor import ( DOMAIN, STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL_INCREASING, SensorEntity, SensorEntityDescription, ) @@ -42,7 +43,6 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.util.dt import utc_from_timestamp from .const import MYSENSORS_DISCOVERY, DiscoveryInfo from .helpers import on_unload @@ -122,8 +122,7 @@ key="V_KWH", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_MEASUREMENT, - last_reset=utc_from_timestamp(0), + state_class=STATE_CLASS_TOTAL_INCREASING, ), "V_LIGHT_LEVEL": SensorEntityDescription( key="V_LIGHT_LEVEL", From c902277cc24dc11c82d47dd05163607e2268ac1d Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 18 Aug 2021 15:22:51 +0200 Subject: [PATCH 2/2] Adjust tests --- tests/components/mysensors/test_sensor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/components/mysensors/test_sensor.py b/tests/components/mysensors/test_sensor.py index 880226ced60300..18d88a24206d61 100644 --- a/tests/components/mysensors/test_sensor.py +++ b/tests/components/mysensors/test_sensor.py @@ -10,6 +10,7 @@ ATTR_LAST_RESET, ATTR_STATE_CLASS, STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL_INCREASING, ) from homeassistant.const import ( ATTR_DEVICE_CLASS, @@ -24,7 +25,6 @@ TEMP_FAHRENHEIT, ) from homeassistant.core import HomeAssistant -from homeassistant.util.dt import utc_from_timestamp from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem from tests.common import MockConfigEntry @@ -92,8 +92,7 @@ async def test_energy_sensor( assert state.state == "18000" assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_ENERGY assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == ENERGY_KILO_WATT_HOUR - assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_MEASUREMENT - assert state.attributes[ATTR_LAST_RESET] == utc_from_timestamp(0).isoformat() + assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_TOTAL_INCREASING async def test_sound_sensor(