Add native unit where device class is set in rflink (#82729)

Add native unit where device class is set
This commit is contained in:
mbo18 2022-11-26 16:40:57 +01:00 committed by GitHub
parent 5adfae2235
commit 405c2ca82d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
CONF_DEVICES, CONF_DEVICES,
CONF_NAME, CONF_NAME,
CONF_SENSOR_TYPE, CONF_SENSOR_TYPE,
@ -25,7 +26,9 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
PRECIPITATION_MILLIMETERS, PRECIPITATION_MILLIMETERS,
UV_INDEX, UV_INDEX,
UnitOfLength,
UnitOfPower, UnitOfPower,
UnitOfPressure,
UnitOfSpeed, UnitOfSpeed,
UnitOfTemperature, UnitOfTemperature,
UnitOfVolumetricFlux, UnitOfVolumetricFlux,
@ -64,6 +67,7 @@ SENSOR_TYPES = (
name="Barometric pressure", name="Barometric pressure",
device_class=SensorDeviceClass.PRESSURE, device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPressure.HPA,
), ),
SensorEntityDescription( SensorEntityDescription(
key="battery", key="battery",
@ -75,6 +79,7 @@ SENSOR_TYPES = (
name="CO2 air quality", name="CO2 air quality",
device_class=SensorDeviceClass.CO2, device_class=SensorDeviceClass.CO2,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
), ),
SensorEntityDescription( SensorEntityDescription(
key="command", key="command",
@ -107,6 +112,7 @@ SENSOR_TYPES = (
name="Distance", name="Distance",
device_class=SensorDeviceClass.DISTANCE, device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
), ),
SensorEntityDescription( SensorEntityDescription(
key="doorbell_melody", key="doorbell_melody",