diff --git a/homeassistant/components/airly/sensor.py b/homeassistant/components/airly/sensor.py index 122990adecc..38c3cf69e89 100644 --- a/homeassistant/components/airly/sensor.py +++ b/homeassistant/components/airly/sensor.py @@ -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( diff --git a/homeassistant/components/airthings/sensor.py b/homeassistant/components/airthings/sensor.py index 028ea67916a..2f28574796f 100644 --- a/homeassistant/components/airthings/sensor.py +++ b/homeassistant/components/airthings/sensor.py @@ -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( diff --git a/homeassistant/components/airthings_ble/sensor.py b/homeassistant/components/airthings_ble/sensor.py index 37b5ce6160e..90e953383ac 100644 --- a/homeassistant/components/airthings_ble/sensor.py +++ b/homeassistant/components/airthings_ble/sensor.py @@ -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( diff --git a/homeassistant/components/aranet/sensor.py b/homeassistant/components/aranet/sensor.py index 45709a10818..5ce00ca4a52 100644 --- a/homeassistant/components/aranet/sensor.py +++ b/homeassistant/components/aranet/sensor.py @@ -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( diff --git a/homeassistant/components/atag/sensor.py b/homeassistant/components/atag/sensor.py index b009d3a0a37..b1f83fb63d6 100644 --- a/homeassistant/components/atag/sensor.py +++ b/homeassistant/components/atag/sensor.py @@ -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, diff --git a/homeassistant/components/bluemaestro/sensor.py b/homeassistant/components/bluemaestro/sensor.py index 7fff348d587..399f662d264 100644 --- a/homeassistant/components/bluemaestro/sensor.py +++ b/homeassistant/components/bluemaestro/sensor.py @@ -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, ), } diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index 17609dfad46..f24c2438c7d 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -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", diff --git a/homeassistant/components/flo/sensor.py b/homeassistant/components/flo/sensor.py index b945007bc89..68c9adc8c9f 100644 --- a/homeassistant/components/flo/sensor.py +++ b/homeassistant/components/flo/sensor.py @@ -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): diff --git a/homeassistant/components/homekit_controller/sensor.py b/homeassistant/components/homekit_controller/sensor.py index a79453eec98..d7b92f4a44d 100644 --- a/homeassistant/components/homekit_controller/sensor.py +++ b/homeassistant/components/homekit_controller/sensor.py @@ -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, diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index fd232a31b4a..ecf3ad2c54e 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -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, ), diff --git a/homeassistant/components/incomfort/sensor.py b/homeassistant/components/incomfort/sensor.py index 59cd7ed8ae5..3db3eab49e4 100644 --- a/homeassistant/components/incomfort/sensor.py +++ b/homeassistant/components/incomfort/sensor.py @@ -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", diff --git a/homeassistant/components/justnimbus/sensor.py b/homeassistant/components/justnimbus/sensor.py index 96e0b47cace..6f31b9789b6 100644 --- a/homeassistant/components/justnimbus/sensor.py +++ b/homeassistant/components/justnimbus/sensor.py @@ -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, diff --git a/homeassistant/components/luftdaten/sensor.py b/homeassistant/components/luftdaten/sensor.py index 5333d86a708..fd2fa5b6c2c 100644 --- a/homeassistant/components/luftdaten/sensor.py +++ b/homeassistant/components/luftdaten/sensor.py @@ -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, ), diff --git a/homeassistant/components/mazda/sensor.py b/homeassistant/components/mazda/sensor.py index 299e8890222..7ae59572b30 100644 --- a/homeassistant/components/mazda/sensor.py +++ b/homeassistant/components/mazda/sensor.py @@ -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, diff --git a/homeassistant/components/nam/sensor.py b/homeassistant/components/nam/sensor.py index 7cb5940b050..1fc1017e1d9 100644 --- a/homeassistant/components/nam/sensor.py +++ b/homeassistant/components/nam/sensor.py @@ -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, ), diff --git a/homeassistant/components/oncue/sensor.py b/homeassistant/components/oncue/sensor.py index 62112200286..8bc6ae8bc7f 100644 --- a/homeassistant/components/oncue/sensor.py +++ b/homeassistant/components/oncue/sensor.py @@ -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, diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index f59d8a78ba4..0dab56c2ba4 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -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, ), diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index 82f40938624..e024123b067 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -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, diff --git a/homeassistant/components/qingping/sensor.py b/homeassistant/components/qingping/sensor.py index 6f1ad8118ab..674c10fa934 100644 --- a/homeassistant/components/qingping/sensor.py +++ b/homeassistant/components/qingping/sensor.py @@ -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, ), ( diff --git a/homeassistant/components/sensorpush/sensor.py b/homeassistant/components/sensorpush/sensor.py index 58b569d5227..d5109e57173 100644 --- a/homeassistant/components/sensorpush/sensor.py +++ b/homeassistant/components/sensorpush/sensor.py @@ -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, ), ( diff --git a/homeassistant/components/subaru/sensor.py b/homeassistant/components/subaru/sensor.py index 7a74f77b1d5..046c3b4393e 100644 --- a/homeassistant/components/subaru/sensor.py +++ b/homeassistant/components/subaru/sensor.py @@ -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, ), ] diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index 6420221fcf5..b5296b5efd2 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -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, diff --git a/homeassistant/components/wiffi/sensor.py b/homeassistant/components/wiffi/sensor.py index e4c0597d1be..5c39fbe1e8a 100644 --- a/homeassistant/components/wiffi/sensor.py +++ b/homeassistant/components/wiffi/sensor.py @@ -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, } diff --git a/homeassistant/components/wolflink/sensor.py b/homeassistant/components/wolflink/sensor.py index f7dfd5a5616..1df09f691b6 100644 --- a/homeassistant/components/wolflink/sensor.py +++ b/homeassistant/components/wolflink/sensor.py @@ -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): diff --git a/homeassistant/components/xiaomi_aqara/sensor.py b/homeassistant/components/xiaomi_aqara/sensor.py index 2e698ffa4f9..6e2f17d7408 100644 --- a/homeassistant/components/xiaomi_aqara/sensor.py +++ b/homeassistant/components/xiaomi_aqara/sensor.py @@ -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, ), diff --git a/homeassistant/components/xiaomi_ble/sensor.py b/homeassistant/components/xiaomi_ble/sensor.py index 084e5940d9e..a17a6e97483 100644 --- a/homeassistant/components/xiaomi_ble/sensor.py +++ b/homeassistant/components/xiaomi_ble/sensor.py @@ -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, ), ( diff --git a/homeassistant/components/zwave_me/sensor.py b/homeassistant/components/zwave_me/sensor.py index 2ac2a06fcd7..d31af5bd9da 100644 --- a/homeassistant/components/zwave_me/sensor.py +++ b/homeassistant/components/zwave_me/sensor.py @@ -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(