Use new unit enumerators in tuya (#84229)

This commit is contained in:
epenet 2022-12-19 13:11:48 +01:00 committed by GitHub
parent 4461e0f262
commit cce438951d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,26 +14,18 @@ from homeassistant.const import (
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_CURRENT_AMPERE,
ELECTRIC_CURRENT_MILLIAMPERE,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_BAR,
PRESSURE_HPA,
PRESSURE_INHG,
PRESSURE_MBAR,
PRESSURE_PA,
PRESSURE_PSI,
SIGNAL_STRENGTH_DECIBELS,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
VOLUME_CUBIC_FEET,
VOLUME_CUBIC_METERS,
Platform,
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfEnergy,
UnitOfPower,
UnitOfPressure,
UnitOfTemperature,
UnitOfVolume,
)
DOMAIN = "tuya"
@ -428,15 +420,15 @@ UNITS = (
conversion_fn=lambda x: x / 1000,
),
UnitOfMeasurement(
unit=ELECTRIC_CURRENT_AMPERE,
unit=UnitOfElectricCurrent.AMPERE,
aliases={"a", "ampere"},
device_classes={SensorDeviceClass.CURRENT},
),
UnitOfMeasurement(
unit=ELECTRIC_CURRENT_MILLIAMPERE,
unit=UnitOfElectricCurrent.MILLIAMPERE,
aliases={"ma", "milliampere"},
device_classes={SensorDeviceClass.CURRENT},
conversion_unit=ELECTRIC_CURRENT_AMPERE,
conversion_unit=UnitOfElectricCurrent.AMPERE,
conversion_fn=lambda x: x / 1000,
),
UnitOfMeasurement(
@ -450,12 +442,12 @@ UNITS = (
device_classes={SensorDeviceClass.ENERGY},
),
UnitOfMeasurement(
unit=VOLUME_CUBIC_FEET,
unit=UnitOfVolume.CUBIC_FEET,
aliases={"ft3"},
device_classes={SensorDeviceClass.GAS},
),
UnitOfMeasurement(
unit=VOLUME_CUBIC_METERS,
unit=UnitOfVolume.CUBIC_METERS,
aliases={"m3"},
device_classes={SensorDeviceClass.GAS},
),
@ -512,30 +504,30 @@ UNITS = (
device_classes={SensorDeviceClass.POWER},
),
UnitOfMeasurement(
unit=PRESSURE_BAR,
unit=UnitOfPressure.BAR,
device_classes={SensorDeviceClass.PRESSURE},
),
UnitOfMeasurement(
unit=PRESSURE_MBAR,
unit=UnitOfPressure.MBAR,
aliases={"millibar"},
device_classes={SensorDeviceClass.PRESSURE},
),
UnitOfMeasurement(
unit=PRESSURE_HPA,
unit=UnitOfPressure.HPA,
aliases={"hpa", "hectopascal"},
device_classes={SensorDeviceClass.PRESSURE},
),
UnitOfMeasurement(
unit=PRESSURE_INHG,
unit=UnitOfPressure.INHG,
aliases={"inhg"},
device_classes={SensorDeviceClass.PRESSURE},
),
UnitOfMeasurement(
unit=PRESSURE_PSI,
unit=UnitOfPressure.PSI,
device_classes={SensorDeviceClass.PRESSURE},
),
UnitOfMeasurement(
unit=PRESSURE_PA,
unit=UnitOfPressure.PA,
device_classes={SensorDeviceClass.PRESSURE},
),
UnitOfMeasurement(
@ -549,12 +541,12 @@ UNITS = (
device_classes={SensorDeviceClass.SIGNAL_STRENGTH},
),
UnitOfMeasurement(
unit=TEMP_CELSIUS,
unit=UnitOfTemperature.CELSIUS,
aliases={"°c", "c", "celsius", ""},
device_classes={SensorDeviceClass.TEMPERATURE},
),
UnitOfMeasurement(
unit=TEMP_FAHRENHEIT,
unit=UnitOfTemperature.FAHRENHEIT,
aliases={"°f", "f", "fahrenheit"},
device_classes={SensorDeviceClass.TEMPERATURE},
),