From 22f71a89e021cf3d877367b9023e4020ee552758 Mon Sep 17 00:00:00 2001
From: Maikel Punie <maikel.punie@gmail.com>
Date: Thu, 9 Dec 2021 10:28:51 +0100
Subject: [PATCH] Use new SensorDeviceClass and SensorStateClass in velbus
 (#61339)

---
 homeassistant/components/velbus/sensor.py | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/homeassistant/components/velbus/sensor.py b/homeassistant/components/velbus/sensor.py
index 34642dd3bf1..86e9a606d36 100644
--- a/homeassistant/components/velbus/sensor.py
+++ b/homeassistant/components/velbus/sensor.py
@@ -4,16 +4,11 @@ from __future__ import annotations
 from velbusaio.channels import ButtonCounter, LightSensor, SensorNumber, Temperature
 
 from homeassistant.components.sensor import (
-    STATE_CLASS_MEASUREMENT,
-    STATE_CLASS_TOTAL_INCREASING,
+    SensorDeviceClass,
     SensorEntity,
+    SensorStateClass,
 )
 from homeassistant.config_entries import ConfigEntry
-from homeassistant.const import (
-    DEVICE_CLASS_ENERGY,
-    DEVICE_CLASS_POWER,
-    DEVICE_CLASS_TEMPERATURE,
-)
 from homeassistant.core import HomeAssistant
 from homeassistant.helpers.entity_platform import AddEntitiesCallback
 
@@ -58,19 +53,19 @@ class VelbusSensor(VelbusEntity, SensorEntity):
             self._attr_name = f"{self._attr_name}-counter"
         # define the device class
         if self._is_counter:
-            self._attr_device_class = DEVICE_CLASS_ENERGY
+            self._attr_device_class = SensorDeviceClass.ENERGY
         elif channel.is_counter_channel():
-            self._attr_device_class = DEVICE_CLASS_POWER
+            self._attr_device_class = SensorDeviceClass.POWER
         elif channel.is_temperature():
-            self._attr_device_class = DEVICE_CLASS_TEMPERATURE
+            self._attr_device_class = SensorDeviceClass.TEMPERATURE
         # define the icon
         if self._is_counter:
             self._attr_icon = "mdi:counter"
         # the state class
         if self._is_counter:
-            self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
+            self._attr_state_class = SensorStateClass.TOTAL_INCREASING
         else:
-            self._attr_state_class = STATE_CLASS_MEASUREMENT
+            self._attr_state_class = SensorStateClass.MEASUREMENT
         # unit
         if self._is_counter:
             self._attr_native_unit_of_measurement = channel.get_counter_unit()