Use UnitOfPressure in integrations (#84230)

This commit is contained in:
epenet 2022-12-19 21:41:46 +01:00 committed by GitHub
parent 0ccac69ce1
commit f988a1164d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 72 additions and 68 deletions

View file

@ -16,8 +16,8 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONF_NAME,
PERCENTAGE,
PRESSURE_HPA,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
@ -105,7 +105,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
key=ATTR_API_PRESSURE,
device_class=SensorDeviceClass.PRESSURE,
name=ATTR_API_PRESSURE.capitalize(),
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
state_class=SensorStateClass.MEASUREMENT,
),
AirlySensorEntityDescription(

View file

@ -15,9 +15,9 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
PRESSURE_MBAR,
SIGNAL_STRENGTH_DECIBELS,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
@ -51,7 +51,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
"pressure": SensorEntityDescription(
key="pressure",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
name="Pressure",
),
"battery": SensorEntityDescription(

View file

@ -17,8 +17,8 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_MBAR,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH
@ -75,7 +75,7 @@ SENSORS_MAPPING_TEMPLATE: dict[str, SensorEntityDescription] = {
"pressure": SensorEntityDescription(
key="pressure",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
name="Pressure",
),
"battery": SensorEntityDescription(

View file

@ -25,9 +25,9 @@ from homeassistant.const import (
ATTR_SW_VERSION,
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
PRESSURE_HPA,
TEMP_CELSIUS,
TIME_SECONDS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
@ -54,7 +54,7 @@ SENSOR_DESCRIPTIONS = {
key="pressure",
name="Pressure",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
state_class=SensorStateClass.MEASUREMENT,
),
"co2": SensorEntityDescription(

View file

@ -3,10 +3,10 @@ from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
PERCENTAGE,
PRESSURE_BAR,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
TIME_HOURS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -48,7 +48,7 @@ class AtagSensor(AtagEntity, SensorEntity):
):
self._attr_device_class = coordinator.data.report[self._id].sensorclass
if coordinator.data.report[self._id].measure in (
PRESSURE_BAR,
UnitOfPressure.BAR,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
PERCENTAGE,

View file

@ -24,9 +24,9 @@ from homeassistant.components.sensor import (
)
from homeassistant.const import (
PERCENTAGE,
PRESSURE_MBAR,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
@ -85,7 +85,7 @@ SENSOR_DESCRIPTIONS = {
): SensorEntityDescription(
key=f"{BlueMaestroSensorDeviceClass.PRESSURE}_{Units.PRESSURE_MBAR}",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
state_class=SensorStateClass.MEASUREMENT,
),
}

View file

@ -36,10 +36,10 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_BILLION,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_HPA,
TEMP_CELSIUS,
UnitOfEnergy,
UnitOfPower,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory
@ -190,7 +190,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (
instance_check=Pressure,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
),
DeconzSensorDescription[Temperature](
key="temperature",

View file

@ -7,7 +7,12 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, PRESSURE_PSI, TEMP_FAHRENHEIT, UnitOfVolume
from homeassistant.const import (
PERCENTAGE,
TEMP_FAHRENHEIT,
UnitOfPressure,
UnitOfVolume,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -160,7 +165,7 @@ class FloPressureSensor(FloEntity, SensorEntity):
"""Monitors the water pressure."""
_attr_device_class = SensorDeviceClass.PRESSURE
_attr_native_unit_of_measurement = PRESSURE_PSI
_attr_native_unit_of_measurement = UnitOfPressure.PSI
_attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
def __init__(self, device):

View file

@ -25,7 +25,6 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_HPA,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
Platform,
@ -33,6 +32,7 @@ from homeassistant.const import (
UnitOfElectricPotential,
UnitOfEnergy,
UnitOfPower,
UnitOfPressure,
UnitOfSoundPressure,
)
from homeassistant.core import HomeAssistant, callback
@ -216,7 +216,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
name="Air Pressure",
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
),
CharacteristicsTypes.VENDOR_VOCOLINC_OUTLET_ENERGY: HomeKitSensorEntityDescription(
key=CharacteristicsTypes.VENDOR_VOCOLINC_OUTLET_ENERGY,

View file

@ -17,7 +17,6 @@ from homeassistant.const import (
DEGREE,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_HPA,
TEMP_CELSIUS,
UnitOfElectricCurrent,
UnitOfElectricPotential,
@ -25,6 +24,7 @@ from homeassistant.const import (
UnitOfFrequency,
UnitOfPower,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfVolume,
)
@ -188,7 +188,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
),
"AIR_PRESSURE": SensorEntityDescription(
key="AIR_PRESSURE",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),

View file

@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
SensorEntity,
SensorEntityDescription,
)
from homeassistant.const import PRESSURE_BAR, TEMP_CELSIUS
from homeassistant.const import TEMP_CELSIUS, UnitOfPressure
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
@ -35,7 +35,7 @@ SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
key="pressure",
name=INCOMFORT_PRESSURE,
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_BAR,
native_unit_of_measurement=UnitOfPressure.BAR,
),
IncomfortSensorEntityDescription(
key="heater_temp",

View file

@ -14,9 +14,9 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_CLIENT_ID,
PRESSURE_BAR,
TEMP_CELSIUS,
TIME_HOURS,
UnitOfPressure,
UnitOfVolume,
)
from homeassistant.core import HomeAssistant
@ -65,7 +65,7 @@ SENSOR_TYPES = (
JustNimbusEntityDescription(
key="pump_pressure",
name="Pump pressure",
native_unit_of_measurement=PRESSURE_BAR,
native_unit_of_measurement=UnitOfPressure.BAR,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,

View file

@ -16,8 +16,8 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONF_SHOW_ON_MAP,
PERCENTAGE,
PRESSURE_PA,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
@ -47,14 +47,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="pressure",
name="Pressure",
native_unit_of_measurement=PRESSURE_PA,
native_unit_of_measurement=UnitOfPressure.PA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="pressure_at_sealevel",
name="Pressure at sealevel",
native_unit_of_measurement=PRESSURE_PA,
native_unit_of_measurement=UnitOfPressure.PA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),

View file

@ -12,7 +12,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, PRESSURE_PSI, UnitOfLength
from homeassistant.const import PERCENTAGE, UnitOfLength, UnitOfPressure
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
@ -185,7 +185,7 @@ SENSOR_ENTITIES = [
name="Front left tire pressure",
icon="mdi:car-tire-alert",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_PSI,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
is_supported=_front_left_tire_pressure_supported,
value=_front_left_tire_pressure_value,
@ -195,7 +195,7 @@ SENSOR_ENTITIES = [
name="Front right tire pressure",
icon="mdi:car-tire-alert",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_PSI,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
is_supported=_front_right_tire_pressure_supported,
value=_front_right_tire_pressure_value,
@ -205,7 +205,7 @@ SENSOR_ENTITIES = [
name="Rear left tire pressure",
icon="mdi:car-tire-alert",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_PSI,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
is_supported=_rear_left_tire_pressure_supported,
value=_rear_left_tire_pressure_value,
@ -215,7 +215,7 @@ SENSOR_ENTITIES = [
name="Rear right tire pressure",
icon="mdi:car-tire-alert",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_PSI,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
is_supported=_rear_right_tire_pressure_supported,
value=_rear_right_tire_pressure_value,

View file

@ -17,9 +17,9 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
PRESSURE_HPA,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry
@ -81,7 +81,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=ATTR_BME280_PRESSURE,
name="BME280 pressure",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),
@ -95,7 +95,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=ATTR_BMP180_PRESSURE,
name="BMP180 pressure",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),
@ -109,7 +109,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=ATTR_BMP280_PRESSURE,
name="BMP280 pressure",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),

View file

@ -12,7 +12,6 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
PERCENTAGE,
PRESSURE_PSI,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UnitOfElectricCurrent,
@ -20,6 +19,7 @@ from homeassistant.const import (
UnitOfEnergy,
UnitOfFrequency,
UnitOfPower,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
@ -47,7 +47,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
),
SensorEntityDescription(
key="EngineOilPressure",
native_unit_of_measurement=PRESSURE_PSI,
native_unit_of_measurement=UnitOfPressure.PSI,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,

View file

@ -19,10 +19,9 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
LIGHT_LUX,
PERCENTAGE,
PRESSURE_CBAR,
PRESSURE_MBAR,
TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -95,7 +94,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.PRESSURE,
entity_registry_enabled_default=False,
name="Pressure",
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT,
),
@ -153,7 +152,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.PRESSURE,
entity_registry_enabled_default=False,
name="Pressure",
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT,
),
@ -284,7 +283,7 @@ HOBBYBOARD_EF: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key=f"moisture/sensor.{id}",
device_class=SensorDeviceClass.PRESSURE,
name=f"Moisture {id}",
native_unit_of_measurement=PRESSURE_CBAR,
native_unit_of_measurement=UnitOfPressure.CBAR,
read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT,
)
@ -308,7 +307,7 @@ EDS_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key="EDS0066/pressure",
device_class=SensorDeviceClass.PRESSURE,
name="Pressure",
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT,
),
@ -326,7 +325,7 @@ EDS_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key="EDS0068/pressure",
device_class=SensorDeviceClass.PRESSURE,
name="Pressure",
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT,
),

View file

@ -10,10 +10,10 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
PERCENTAGE,
PRESSURE_BAR,
TEMP_CELSIUS,
UnitOfEnergy,
UnitOfPower,
UnitOfPressure,
UnitOfVolume,
)
from homeassistant.core import HomeAssistant
@ -280,7 +280,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="water_pressure",
name="Water pressure",
native_unit_of_measurement=PRESSURE_BAR,
native_unit_of_measurement=UnitOfPressure.BAR,
device_class=SensorDeviceClass.PRESSURE,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,

View file

@ -27,9 +27,9 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_MBAR,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
@ -89,7 +89,7 @@ SENSOR_DESCRIPTIONS = {
(QingpingSensorDeviceClass.PRESSURE, Units.PRESSURE_MBAR): SensorEntityDescription(
key=f"{QingpingSensorDeviceClass.PRESSURE}_{Units.PRESSURE_MBAR}",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
state_class=SensorStateClass.MEASUREMENT,
),
(

View file

@ -21,9 +21,9 @@ from homeassistant.components.sensor import (
)
from homeassistant.const import (
PERCENTAGE,
PRESSURE_MBAR,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -47,7 +47,7 @@ SENSOR_DESCRIPTIONS = {
(DeviceClass.PRESSURE, Units.PRESSURE_MBAR): SensorEntityDescription(
key=f"{DeviceClass.PRESSURE}_{Units.PRESSURE_MBAR}",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
state_class=SensorStateClass.MEASUREMENT,
),
(

View file

@ -13,7 +13,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, PRESSURE_HPA, UnitOfLength, UnitOfVolume
from homeassistant.const import PERCENTAGE, UnitOfLength, UnitOfPressure, UnitOfVolume
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -84,28 +84,28 @@ API_GEN_2_SENSORS = [
key=sc.TIRE_PRESSURE_FL,
device_class=SensorDeviceClass.PRESSURE,
name="Tire pressure FL",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_FR,
device_class=SensorDeviceClass.PRESSURE,
name="Tire pressure FR",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_RL,
device_class=SensorDeviceClass.PRESSURE,
name="Tire pressure RL",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_RR,
device_class=SensorDeviceClass.PRESSURE,
name="Tire pressure RR",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
state_class=SensorStateClass.MEASUREMENT,
),
]

View file

@ -21,7 +21,6 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_HPA,
SIGNAL_STRENGTH_DECIBELS,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
SPEED_KILOMETERS_PER_HOUR,
@ -38,6 +37,7 @@ from homeassistant.const import (
UnitOfLength,
UnitOfMass,
UnitOfPower,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -222,7 +222,7 @@ SENSOR_UNIT_MAP = {
hc.MASS_KILOGRAMS: UnitOfMass.KILOGRAMS,
hc.PERCENTAGE: PERCENTAGE,
hc.POWER_WATT: UnitOfPower.WATT,
hc.PRESSURE_HPA: PRESSURE_HPA,
hc.PRESSURE_HPA: UnitOfPressure.HPA,
hc.SIGNAL_STRENGTH_DECIBELS: SIGNAL_STRENGTH_DECIBELS,
hc.SIGNAL_STRENGTH_DECIBELS_MILLIWATT: SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
hc.SPEED_KILOMETERS_PER_HOUR: SPEED_KILOMETERS_PER_HOUR,

View file

@ -5,7 +5,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEGREE, PRESSURE_MBAR, TEMP_CELSIUS
from homeassistant.const import DEGREE, TEMP_CELSIUS, UnitOfPressure
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -32,7 +32,7 @@ UOM_TO_DEVICE_CLASS_MAP = {
UOM_MAP = {
WIFFI_UOM_DEGREE: DEGREE,
WIFFI_UOM_TEMP_CELSIUS: TEMP_CELSIUS,
WIFFI_UOM_MILLI_BAR: PRESSURE_MBAR,
WIFFI_UOM_MILLI_BAR: UnitOfPressure.MBAR,
}

View file

@ -13,7 +13,7 @@ from wolf_smartset.models import (
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PRESSURE_BAR, TEMP_CELSIUS, TIME_HOURS
from homeassistant.const import TEMP_CELSIUS, TIME_HOURS, UnitOfPressure
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -128,7 +128,7 @@ class WolfLinkPressure(WolfLinkSensor):
@property
def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return PRESSURE_BAR
return UnitOfPressure.BAR
class WolfLinkPercentage(WolfLinkSensor):

View file

@ -14,9 +14,9 @@ from homeassistant.const import (
ATTR_BATTERY_LEVEL,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_HPA,
TEMP_CELSIUS,
UnitOfPower,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -53,7 +53,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
),
"pressure": SensorEntityDescription(
key="pressure",
native_unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=UnitOfPressure.HPA,
device_class=SensorDeviceClass.PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),

View file

@ -23,10 +23,10 @@ from homeassistant.const import (
CONDUCTIVITY,
LIGHT_LUX,
PERCENTAGE,
PRESSURE_MBAR,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
@ -79,7 +79,7 @@ SENSOR_DESCRIPTIONS = {
(DeviceClass.PRESSURE, Units.PRESSURE_MBAR): SensorEntityDescription(
key=f"{DeviceClass.PRESSURE}_{Units.PRESSURE_MBAR}",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_MBAR,
native_unit_of_measurement=UnitOfPressure.MBAR,
state_class=SensorStateClass.MEASUREMENT,
),
(

View file

@ -16,12 +16,12 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
LIGHT_LUX,
PERCENTAGE,
PRESSURE_KPA,
TEMP_CELSIUS,
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfEnergy,
UnitOfPower,
UnitOfPressure,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -42,7 +42,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = {
"barometer": ZWaveMeSensorEntityDescription(
key="barometer",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=PRESSURE_KPA,
native_unit_of_measurement=UnitOfPressure.KPA,
state_class=SensorStateClass.MEASUREMENT,
),
"co": ZWaveMeSensorEntityDescription(