Remove lumen from Illuminance units (#84386)

pull/84611/head
epenet 2022-12-27 14:25:47 +01:00 committed by GitHub
parent 2215adf5cf
commit 4c8e3aa7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 6 additions and 16 deletions

View File

@ -592,7 +592,6 @@ SENSOR_DESCRIPTIONS = (
key=TYPE_UV,
name="UV index",
native_unit_of_measurement="Index",
device_class=SensorDeviceClass.ILLUMINANCE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(

View File

@ -214,7 +214,7 @@ def get_accessory( # noqa: C901
a_type = "CarbonMonoxideSensor"
elif device_class == SensorDeviceClass.CO2 or "co2" in state.entity_id:
a_type = "CarbonDioxideSensor"
elif device_class == SensorDeviceClass.ILLUMINANCE or unit in ("lm", LIGHT_LUX):
elif device_class == SensorDeviceClass.ILLUMINANCE or unit == LIGHT_LUX:
a_type = "LightSensor"
elif state.domain == "switch":

View File

@ -143,7 +143,7 @@ class NumberDeviceClass(StrEnum):
ILLUMINANCE = "illuminance"
"""Illuminance.
Unit of measurement: `lx`, `lm`
Unit of measurement: `lx`
"""
IRRADIANCE = "irradiance"

View File

@ -258,7 +258,6 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
key="illuminance",
name="Illuminance",
native_unit_of_measurement=UNIT_LUMEN,
device_class=SensorDeviceClass.ILLUMINANCE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(

View File

@ -235,7 +235,7 @@ class SensorDeviceClass(StrEnum):
ILLUMINANCE = "illuminance"
"""Illuminance.
Unit of measurement: `lx`, `lm`
Unit of measurement: `lx`
"""
IRRADIANCE = "irradiance"
@ -503,7 +503,7 @@ DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = {
UnitOfVolume.CUBIC_METERS,
},
SensorDeviceClass.HUMIDITY: {PERCENTAGE},
SensorDeviceClass.ILLUMINANCE: {LIGHT_LUX, "lm"},
SensorDeviceClass.ILLUMINANCE: {LIGHT_LUX},
SensorDeviceClass.IRRADIANCE: set(UnitOfIrradiance),
SensorDeviceClass.MOISTURE: {PERCENTAGE},
SensorDeviceClass.NITROGEN_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},

View File

@ -57,7 +57,6 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
name="Light level",
native_unit_of_measurement="Level",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.ILLUMINANCE,
),
"humidity": SensorEntityDescription(
key="humidity",

View File

@ -456,11 +456,6 @@ UNITS = (
aliases={"lux"},
device_classes={SensorDeviceClass.ILLUMINANCE},
),
UnitOfMeasurement(
unit="lm",
aliases={"lum", "lumen"},
device_classes={SensorDeviceClass.ILLUMINANCE},
),
UnitOfMeasurement(
unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
aliases={"ug/m3", "µg/m3", "ug/m³"},

View File

@ -42,7 +42,6 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
"illumination": SensorEntityDescription(
key="illumination",
native_unit_of_measurement="lm",
device_class=SensorDeviceClass.ILLUMINANCE,
state_class=SensorStateClass.MEASUREMENT,
),
"lux": SensorEntityDescription(

View File

@ -246,7 +246,6 @@ SENSOR_TYPES = {
key=ATTR_ILLUMINANCE,
name="Illuminance",
native_unit_of_measurement=UNIT_LUMEN,
device_class=SensorDeviceClass.ILLUMINANCE,
state_class=SensorStateClass.MEASUREMENT,
),
ATTR_ILLUMINANCE_LUX: XiaomiMiioSensorDescription(

View File

@ -258,7 +258,6 @@ def test_type_media_player(type_name, entity_id, state, attrs, config):
{ATTR_DEVICE_CLASS: "humidity", ATTR_UNIT_OF_MEASUREMENT: PERCENTAGE},
),
("LightSensor", "sensor.light", "900", {ATTR_DEVICE_CLASS: "illuminance"}),
("LightSensor", "sensor.light", "900", {ATTR_UNIT_OF_MEASUREMENT: "lm"}),
("LightSensor", "sensor.light", "900", {ATTR_UNIT_OF_MEASUREMENT: LIGHT_LUX}),
(
"TemperatureSensor",

View File

@ -13,6 +13,7 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
FREQUENCY_GIGAHERTZ,
LIGHT_LUX,
PERCENTAGE,
POWER_VOLT_AMPERE,
POWER_VOLT_AMPERE_REACTIVE,
@ -31,7 +32,7 @@ UNITS_OF_MEASUREMENT = {
SensorDeviceClass.CO: CONCENTRATION_PARTS_PER_MILLION, # ppm of CO concentration
SensorDeviceClass.CO2: CONCENTRATION_PARTS_PER_MILLION, # ppm of CO2 concentration
SensorDeviceClass.HUMIDITY: PERCENTAGE, # % of humidity in the air
SensorDeviceClass.ILLUMINANCE: "lm", # current light level (lx/lm)
SensorDeviceClass.ILLUMINANCE: LIGHT_LUX, # current light level lx
SensorDeviceClass.MOISTURE: PERCENTAGE, # % of water in a substance
SensorDeviceClass.NITROGEN_DIOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen dioxide
SensorDeviceClass.NITROGEN_MONOXIDE: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, # µg/m³ of nitrogen monoxide