From 8e3d9d7435315ec7f3f01e83274d3e24a7325f82 Mon Sep 17 00:00:00 2001
From: Peter Galantha <peter.galantha@gmail.com>
Date: Mon, 20 Jun 2022 01:45:35 -0700
Subject: [PATCH] Specify device_class and state_class on OpenEVSE sensors
 (#73672)

* Specify device_class and state_class

* import SensorStateClass
---
 homeassistant/components/openevse/sensor.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/homeassistant/components/openevse/sensor.py b/homeassistant/components/openevse/sensor.py
index 9f953832674..3dcea4d0126 100644
--- a/homeassistant/components/openevse/sensor.py
+++ b/homeassistant/components/openevse/sensor.py
@@ -12,6 +12,7 @@ from homeassistant.components.sensor import (
     SensorDeviceClass,
     SensorEntity,
     SensorEntityDescription,
+    SensorStateClass,
 )
 from homeassistant.const import (
     CONF_HOST,
@@ -36,34 +37,43 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
         key="charge_time",
         name="Charge Time Elapsed",
         native_unit_of_measurement=TIME_MINUTES,
+        device_class=SensorDeviceClass.DURATION,
+        state_class=SensorStateClass.MEASUREMENT,
     ),
     SensorEntityDescription(
         key="ambient_temp",
         name="Ambient Temperature",
         native_unit_of_measurement=TEMP_CELSIUS,
         device_class=SensorDeviceClass.TEMPERATURE,
+        state_class=SensorStateClass.MEASUREMENT,
     ),
     SensorEntityDescription(
         key="ir_temp",
         name="IR Temperature",
         native_unit_of_measurement=TEMP_CELSIUS,
         device_class=SensorDeviceClass.TEMPERATURE,
+        state_class=SensorStateClass.MEASUREMENT,
     ),
     SensorEntityDescription(
         key="rtc_temp",
         name="RTC Temperature",
         native_unit_of_measurement=TEMP_CELSIUS,
         device_class=SensorDeviceClass.TEMPERATURE,
+        state_class=SensorStateClass.MEASUREMENT,
     ),
     SensorEntityDescription(
         key="usage_session",
         name="Usage this Session",
         native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
+        device_class=SensorDeviceClass.ENERGY,
+        state_class=SensorStateClass.TOTAL_INCREASING,
     ),
     SensorEntityDescription(
         key="usage_total",
         name="Total Usage",
         native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
+        device_class=SensorDeviceClass.ENERGY,
+        state_class=SensorStateClass.TOTAL_INCREASING,
     ),
 )