Use Irradiance unit and device class in integrations (#83576)

pull/83597/head
epenet 2022-12-08 23:51:47 +01:00 committed by GitHub
parent 7f345e7672
commit 911863ebf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 10 deletions

View File

@ -15,9 +15,9 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
DEGREE,
IRRADIATION_WATTS_PER_SQUARE_METER,
LIGHT_LUX,
PERCENTAGE,
UnitOfIrradiance,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
@ -486,8 +486,8 @@ SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
key=TYPE_SOLARRADIATION,
name="Solar rad",
native_unit_of_measurement=IRRADIATION_WATTS_PER_SQUARE_METER,
device_class=SensorDeviceClass.ILLUMINANCE,
native_unit_of_measurement=UnitOfIrradiance.WATTS_PER_SQUARE_METER,
device_class=SensorDeviceClass.IRRADIANCE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(

View File

@ -34,8 +34,8 @@ from homeassistant.const import (
CONF_LONGITUDE,
CONF_NAME,
DEGREE,
IRRADIATION_WATTS_PER_SQUARE_METER,
PERCENTAGE,
UnitOfIrradiance,
UnitOfLength,
UnitOfPrecipitationDepth,
UnitOfPressure,
@ -188,8 +188,8 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="irradiance",
name="Irradiance",
native_unit_of_measurement=IRRADIATION_WATTS_PER_SQUARE_METER,
icon="mdi:sunglasses",
device_class=SensorDeviceClass.IRRADIANCE,
native_unit_of_measurement=UnitOfIrradiance.WATTS_PER_SQUARE_METER,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(

View File

@ -18,11 +18,11 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
DEGREE,
IRRADIATION_WATTS_PER_SQUARE_METER,
LIGHT_LUX,
PERCENTAGE,
UV_INDEX,
UnitOfElectricPotential,
UnitOfIrradiance,
UnitOfLength,
UnitOfPrecipitationDepth,
UnitOfPressure,
@ -68,7 +68,8 @@ ECOWITT_SENSORS_MAPPING: Final = {
),
EcoWittSensorTypes.WATT_METERS_SQUARED: SensorEntityDescription(
key="WATT_METERS_SQUARED",
native_unit_of_measurement=IRRADIATION_WATTS_PER_SQUARE_METER,
device_class=SensorDeviceClass.IRRADIANCE,
native_unit_of_measurement=UnitOfIrradiance.WATTS_PER_SQUARE_METER,
state_class=SensorStateClass.MEASUREMENT,
),
EcoWittSensorTypes.UV_INDEX: SensorEntityDescription(

View File

@ -98,7 +98,6 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
FREQUENCY_HERTZ,
FREQUENCY_KILOHERTZ,
IRRADIATION_WATTS_PER_SQUARE_METER,
LIGHT_LUX,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS,
@ -107,6 +106,7 @@ from homeassistant.const import (
VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE,
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
UnitOfEnergy,
UnitOfIrradiance,
UnitOfLength,
UnitOfMass,
UnitOfPower,
@ -209,7 +209,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = {
UnitOfPressure.MMHG: UNIT_SYSTOLIC,
ELECTRIC_POTENTIAL_VOLT: SENSOR_UNIT_VOLT,
UnitOfPower.WATT: SENSOR_UNIT_WATT,
IRRADIATION_WATTS_PER_SQUARE_METER: UNIT_WATT_PER_SQUARE_METER,
UnitOfIrradiance.WATTS_PER_SQUARE_METER: UNIT_WATT_PER_SQUARE_METER,
}
_LOGGER = logging.getLogger(__name__)