From e0285169396e7187b16f83d7f9d199268ce0fe1c Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sat, 19 Nov 2022 16:57:18 +0100 Subject: [PATCH] Use unit enums in nibe heatpump (#82370) Use unit enums in nibe --- .../components/nibe_heatpump/sensor.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/nibe_heatpump/sensor.py b/homeassistant/components/nibe_heatpump/sensor.py index 0b12afd9e05..c092464b1bf 100644 --- a/homeassistant/components/nibe_heatpump/sensor.py +++ b/homeassistant/components/nibe_heatpump/sensor.py @@ -16,14 +16,10 @@ from homeassistant.const import ( ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_VOLT, - ENERGY_KILO_WATT_HOUR, - ENERGY_MEGA_WATT_HOUR, - ENERGY_WATT_HOUR, - POWER_KILO_WATT, - POWER_WATT, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, TIME_HOURS, + UnitOfEnergy, + UnitOfPower, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -37,14 +33,14 @@ UNIT_DESCRIPTIONS = { entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), "°F": SensorEntityDescription( key="°F", entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_FAHRENHEIT, + native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT, ), "A": SensorEntityDescription( key="A", @@ -79,35 +75,35 @@ UNIT_DESCRIPTIONS = { entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), "kW": SensorEntityDescription( key="kW", entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, ), "Wh": SensorEntityDescription( key="Wh", entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, ), "kWh": SensorEntityDescription( key="kWh", entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, ), "MWh": SensorEntityDescription( key="MWh", entity_category=EntityCategory.DIAGNOSTIC, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=ENERGY_MEGA_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.MEGA_WATT_HOUR, ), "h": SensorEntityDescription( key="h",