From 6f54636baff03961f5c8c6c28a1eda67239bcc0e Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Thu, 16 Dec 2021 16:38:26 -0500 Subject: [PATCH] Use enums in rainforest_eagle (#62057) --- .../components/rainforest_eagle/sensor.py | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/rainforest_eagle/sensor.py b/homeassistant/components/rainforest_eagle/sensor.py index bdd6ac541a9..0f2c4f62125 100644 --- a/homeassistant/components/rainforest_eagle/sensor.py +++ b/homeassistant/components/rainforest_eagle/sensor.py @@ -2,19 +2,14 @@ from __future__ import annotations from homeassistant.components.sensor import ( - DEVICE_CLASS_ENERGY, - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, StateType, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - DEVICE_CLASS_POWER, - ENERGY_KILO_WATT_HOUR, - POWER_KILO_WATT, -) +from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_KILO_WATT from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -29,22 +24,22 @@ SENSORS = ( # We can drop the "Eagle-200" part of the name in HA 2021.12 name="Eagle-200 Meter Power Demand", native_unit_of_measurement=POWER_KILO_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="zigbee:CurrentSummationDelivered", name="Eagle-200 Total Meter Energy Delivered", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), SensorEntityDescription( key="zigbee:CurrentSummationReceived", name="Eagle-200 Total Meter Energy Received", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), ) @@ -64,7 +59,7 @@ async def async_setup_entry( key="zigbee:Price", name="Meter Price", native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{ENERGY_KILO_WATT_HOUR}", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), ) )