From d9bfb8fc58f54c4460a853fac46b70e970dd9819 Mon Sep 17 00:00:00 2001
From: Erik Montnemery <erik@montnemery.com>
Date: Wed, 18 Aug 2021 13:44:08 +0200
Subject: [PATCH] Remove `last_reset` attribute and set state class to
 `total_increasing` for rainforest energy sensors (#54810)

---
 homeassistant/components/rainforest_eagle/sensor.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/homeassistant/components/rainforest_eagle/sensor.py b/homeassistant/components/rainforest_eagle/sensor.py
index 64eb243c15d..6e42d2a13a2 100644
--- a/homeassistant/components/rainforest_eagle/sensor.py
+++ b/homeassistant/components/rainforest_eagle/sensor.py
@@ -2,7 +2,7 @@
 from __future__ import annotations
 
 from dataclasses import dataclass
-from datetime import datetime, timedelta
+from datetime import timedelta
 import logging
 
 from eagle200_reader import EagleReader
@@ -14,6 +14,7 @@ from homeassistant.components.sensor import (
     DEVICE_CLASS_ENERGY,
     PLATFORM_SCHEMA,
     STATE_CLASS_MEASUREMENT,
+    STATE_CLASS_TOTAL_INCREASING,
     SensorEntity,
 )
 from homeassistant.const import (
@@ -22,7 +23,7 @@ from homeassistant.const import (
     ENERGY_KILO_WATT_HOUR,
 )
 import homeassistant.helpers.config_validation as cv
-from homeassistant.util import Throttle, dt
+from homeassistant.util import Throttle
 
 CONF_CLOUD_ID = "cloud_id"
 CONF_INSTALL_CODE = "install_code"
@@ -41,7 +42,6 @@ class SensorType:
     unit_of_measurement: str
     device_class: str | None = None
     state_class: str | None = None
-    last_reset: datetime | None = None
 
 
 SENSORS = {
@@ -54,15 +54,13 @@ SENSORS = {
         name="Eagle-200 Total Meter Energy Delivered",
         unit_of_measurement=ENERGY_KILO_WATT_HOUR,
         device_class=DEVICE_CLASS_ENERGY,
-        state_class=STATE_CLASS_MEASUREMENT,
-        last_reset=dt.utc_from_timestamp(0),
+        state_class=STATE_CLASS_TOTAL_INCREASING,
     ),
     "summation_received": SensorType(
         name="Eagle-200 Total Meter Energy Received",
         unit_of_measurement=ENERGY_KILO_WATT_HOUR,
         device_class=DEVICE_CLASS_ENERGY,
-        state_class=STATE_CLASS_MEASUREMENT,
-        last_reset=dt.utc_from_timestamp(0),
+        state_class=STATE_CLASS_TOTAL_INCREASING,
     ),
     "summation_total": SensorType(
         name="Eagle-200 Net Meter Energy (Delivered minus Received)",
@@ -134,7 +132,6 @@ class EagleSensor(SensorEntity):
         self._attr_native_unit_of_measurement = sensor_info.unit_of_measurement
         self._attr_device_class = sensor_info.device_class
         self._attr_state_class = sensor_info.state_class
-        self._attr_last_reset = sensor_info.last_reset
 
     def update(self):
         """Get the energy information from the Rainforest Eagle."""
-- 
GitLab