Use unit enums in nibe heatpump (#82370)

Use unit enums in nibe
This commit is contained in:
Joakim Plate 2022-11-19 16:57:18 +01:00 committed by GitHub
parent 14f2649ae2
commit e028516939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,14 +16,10 @@ from homeassistant.const import (
ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_CURRENT_MILLIAMPERE,
ELECTRIC_POTENTIAL_MILLIVOLT, ELECTRIC_POTENTIAL_MILLIVOLT,
ELECTRIC_POTENTIAL_VOLT, 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, TIME_HOURS,
UnitOfEnergy,
UnitOfPower,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -37,14 +33,14 @@ UNIT_DESCRIPTIONS = {
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
), ),
"°F": SensorEntityDescription( "°F": SensorEntityDescription(
key="°F", key="°F",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=TEMP_FAHRENHEIT, native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
), ),
"A": SensorEntityDescription( "A": SensorEntityDescription(
key="A", key="A",
@ -79,35 +75,35 @@ UNIT_DESCRIPTIONS = {
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
), ),
"kW": SensorEntityDescription( "kW": SensorEntityDescription(
key="kW", key="kW",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
), ),
"Wh": SensorEntityDescription( "Wh": SensorEntityDescription(
key="Wh", key="Wh",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=ENERGY_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
), ),
"kWh": SensorEntityDescription( "kWh": SensorEntityDescription(
key="kWh", key="kWh",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
), ),
"MWh": SensorEntityDescription( "MWh": SensorEntityDescription(
key="MWh", key="MWh",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=ENERGY_MEGA_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.MEGA_WATT_HOUR,
), ),
"h": SensorEntityDescription( "h": SensorEntityDescription(
key="h", key="h",