From 45425f118cb2e91084b81444659b9be245f1a096 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 10 Dec 2021 09:12:38 +0100 Subject: [PATCH] Use new DeviceClass and StateClass in enphase_envoy (#61388) Co-authored-by: epenet --- .../components/enphase_envoy/const.py | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/enphase_envoy/const.py b/homeassistant/components/enphase_envoy/const.py index 7e278d83b86..747a4886f15 100644 --- a/homeassistant/components/enphase_envoy/const.py +++ b/homeassistant/components/enphase_envoy/const.py @@ -2,16 +2,11 @@ from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, + SensorDeviceClass, SensorEntityDescription, + SensorStateClass, ) -from homeassistant.const import ( - DEVICE_CLASS_ENERGY, - ENERGY_WATT_HOUR, - POWER_WATT, - Platform, -) +from homeassistant.const import ENERGY_WATT_HOUR, POWER_WATT, Platform DOMAIN = "enphase_envoy" @@ -26,60 +21,60 @@ SENSORS = ( key="production", name="Current Power Production", native_unit_of_measurement=POWER_WATT, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="daily_production", name="Today's Energy Production", native_unit_of_measurement=ENERGY_WATT_HOUR, - state_class=STATE_CLASS_TOTAL_INCREASING, - device_class=DEVICE_CLASS_ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, ), SensorEntityDescription( key="seven_days_production", name="Last Seven Days Energy Production", native_unit_of_measurement=ENERGY_WATT_HOUR, - state_class=STATE_CLASS_MEASUREMENT, - device_class=DEVICE_CLASS_ENERGY, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.ENERGY, ), SensorEntityDescription( key="lifetime_production", name="Lifetime Energy Production", native_unit_of_measurement=ENERGY_WATT_HOUR, - state_class=STATE_CLASS_TOTAL_INCREASING, - device_class=DEVICE_CLASS_ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, ), SensorEntityDescription( key="consumption", name="Current Power Consumption", native_unit_of_measurement=POWER_WATT, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="daily_consumption", name="Today's Energy Consumption", native_unit_of_measurement=ENERGY_WATT_HOUR, - state_class=STATE_CLASS_MEASUREMENT, - device_class=DEVICE_CLASS_ENERGY, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.ENERGY, ), SensorEntityDescription( key="seven_days_consumption", name="Last Seven Days Energy Consumption", native_unit_of_measurement=ENERGY_WATT_HOUR, - state_class=STATE_CLASS_MEASUREMENT, - device_class=DEVICE_CLASS_ENERGY, + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.ENERGY, ), SensorEntityDescription( key="lifetime_consumption", name="Lifetime Energy Consumption", native_unit_of_measurement=ENERGY_WATT_HOUR, - state_class=STATE_CLASS_TOTAL_INCREASING, - device_class=DEVICE_CLASS_ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, ), SensorEntityDescription( key="inverters", name="Inverter", native_unit_of_measurement=POWER_WATT, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), )