From 456c5515c8fdab388e2b16518cbc6d784c2c885d Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sat, 10 Dec 2022 12:43:13 +0100 Subject: [PATCH] Use UnitOfVolume in integrations (#83646) --- homeassistant/components/dsmr/sensor.py | 4 ++-- homeassistant/components/flo/sensor.py | 9 ++------- homeassistant/components/flume/sensor.py | 16 ++++++++-------- homeassistant/components/homematic/sensor.py | 6 +++--- homeassistant/components/homewizard/sensor.py | 6 +++--- homeassistant/components/justnimbus/sensor.py | 12 ++++++------ homeassistant/components/kegtron/sensor.py | 8 ++++---- .../components/nsw_fuel_station/sensor.py | 4 ++-- homeassistant/components/omnilogic/sensor.py | 4 ++-- homeassistant/components/p1_monitor/sensor.py | 11 +++++------ homeassistant/components/plugwise/sensor.py | 6 +++--- homeassistant/components/renault/sensor.py | 4 ++-- homeassistant/components/starline/sensor.py | 4 ++-- homeassistant/components/subaru/sensor.py | 5 ++--- homeassistant/components/surepetcare/sensor.py | 4 ++-- homeassistant/components/toon/sensor.py | 14 +++++++------- homeassistant/components/youless/sensor.py | 4 ++-- 17 files changed, 57 insertions(+), 64 deletions(-) diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 5cbd3e14be0..9e05111d284 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -28,7 +28,7 @@ from homeassistant.const import ( CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, - VOLUME_CUBIC_METERS, + UnitOfVolume, ) from homeassistant.core import CoreState, Event, HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory @@ -55,7 +55,7 @@ from .const import ( LOGGER, ) -UNIT_CONVERSION = {"m3": VOLUME_CUBIC_METERS} +UNIT_CONVERSION = {"m3": UnitOfVolume.CUBIC_METERS} @dataclass diff --git a/homeassistant/components/flo/sensor.py b/homeassistant/components/flo/sensor.py index 58e8417de09..b945007bc89 100644 --- a/homeassistant/components/flo/sensor.py +++ b/homeassistant/components/flo/sensor.py @@ -7,12 +7,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - PERCENTAGE, - PRESSURE_PSI, - TEMP_FAHRENHEIT, - VOLUME_GALLONS, -) +from homeassistant.const import PERCENTAGE, PRESSURE_PSI, TEMP_FAHRENHEIT, UnitOfVolume from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -68,7 +63,7 @@ class FloDailyUsageSensor(FloEntity, SensorEntity): """Monitors the daily water usage.""" _attr_icon = WATER_ICON - _attr_native_unit_of_measurement = VOLUME_GALLONS + _attr_native_unit_of_measurement = UnitOfVolume.GALLONS _attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING _attr_device_class = SensorDeviceClass.WATER diff --git a/homeassistant/components/flume/sensor.py b/homeassistant/components/flume/sensor.py index 5b8dbde69e4..c7ebbd1f456 100644 --- a/homeassistant/components/flume/sensor.py +++ b/homeassistant/components/flume/sensor.py @@ -10,7 +10,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import VOLUME_GALLONS +from homeassistant.const import UnitOfVolume from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -35,45 +35,45 @@ FLUME_QUERIES_SENSOR: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="current_interval", name="Current", - native_unit_of_measurement=f"{VOLUME_GALLONS}/m", + native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/m", ), SensorEntityDescription( key="month_to_date", name="Current Month", - native_unit_of_measurement=VOLUME_GALLONS, + native_unit_of_measurement=UnitOfVolume.GALLONS, device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL_INCREASING, ), SensorEntityDescription( key="week_to_date", name="Current Week", - native_unit_of_measurement=VOLUME_GALLONS, + native_unit_of_measurement=UnitOfVolume.GALLONS, device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL_INCREASING, ), SensorEntityDescription( key="today", name="Current Day", - native_unit_of_measurement=VOLUME_GALLONS, + native_unit_of_measurement=UnitOfVolume.GALLONS, device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL_INCREASING, ), SensorEntityDescription( key="last_60_min", name="60 Minutes", - native_unit_of_measurement=f"{VOLUME_GALLONS}/h", + native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/h", state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="last_24_hrs", name="24 Hours", - native_unit_of_measurement=f"{VOLUME_GALLONS}/d", + native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/d", state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="last_30_days", name="30 Days", - native_unit_of_measurement=f"{VOLUME_GALLONS}/mo", + native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/mo", state_class=SensorStateClass.MEASUREMENT, ), ) diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index 38b2b4e73f3..24045c5e158 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -24,10 +24,10 @@ from homeassistant.const import ( POWER_WATT, PRESSURE_HPA, TEMP_CELSIUS, - VOLUME_CUBIC_METERS, UnitOfElectricCurrent, UnitOfPrecipitationDepth, UnitOfSpeed, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -154,13 +154,13 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { ), "GAS_POWER": SensorEntityDescription( key="GAS_POWER", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.MEASUREMENT, ), "GAS_ENERGY_COUNTER": SensorEntityDescription( key="GAS_ENERGY_COUNTER", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.TOTAL_INCREASING, ), diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index 493b5f1c0e3..68b1f4588a8 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -15,7 +15,7 @@ from homeassistant.const import ( ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_WATT, - VOLUME_CUBIC_METERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -115,7 +115,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = ( SensorEntityDescription( key="total_gas_m3", name="Total gas", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.TOTAL_INCREASING, ), @@ -129,7 +129,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = ( SensorEntityDescription( key="total_liter_m3", name="Total water usage", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, icon="mdi:gauge", device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL_INCREASING, diff --git a/homeassistant/components/justnimbus/sensor.py b/homeassistant/components/justnimbus/sensor.py index 41f1e81d5b3..96e0b47cace 100644 --- a/homeassistant/components/justnimbus/sensor.py +++ b/homeassistant/components/justnimbus/sensor.py @@ -17,7 +17,7 @@ from homeassistant.const import ( PRESSURE_BAR, TEMP_CELSIUS, TIME_HOURS, - VOLUME_LITERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -102,7 +102,7 @@ SENSOR_TYPES = ( key="reservoir_content", name="Reservoir content", icon="mdi:car-coolant-level", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, @@ -112,7 +112,7 @@ SENSOR_TYPES = ( key="total_saved", name="Total saved", icon="mdi:water-opacity", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, entity_category=EntityCategory.DIAGNOSTIC, @@ -122,7 +122,7 @@ SENSOR_TYPES = ( key="total_replenished", name="Total replenished", icon="mdi:water", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, entity_category=EntityCategory.DIAGNOSTIC, @@ -140,7 +140,7 @@ SENSOR_TYPES = ( key="totver", name="Total use", icon="mdi:chart-donut", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, entity_category=EntityCategory.DIAGNOSTIC, @@ -150,7 +150,7 @@ SENSOR_TYPES = ( key="reservoir_content_max", name="Max reservoir content", icon="mdi:waves", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL, entity_category=EntityCategory.DIAGNOSTIC, diff --git a/homeassistant/components/kegtron/sensor.py b/homeassistant/components/kegtron/sensor.py index b9386dd9bb4..c80788d2503 100644 --- a/homeassistant/components/kegtron/sensor.py +++ b/homeassistant/components/kegtron/sensor.py @@ -22,7 +22,7 @@ from homeassistant.components.sensor import ( SensorEntityDescription, SensorStateClass, ) -from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, VOLUME_LITERS +from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfVolume from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -39,7 +39,7 @@ SENSOR_DESCRIPTIONS = { KegtronSensorDeviceClass.KEG_SIZE: SensorEntityDescription( key=KegtronSensorDeviceClass.KEG_SIZE, icon="mdi:keg", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, ), @@ -50,14 +50,14 @@ SENSOR_DESCRIPTIONS = { KegtronSensorDeviceClass.VOLUME_START: SensorEntityDescription( key=KegtronSensorDeviceClass.VOLUME_START, icon="mdi:keg", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, ), KegtronSensorDeviceClass.VOLUME_DISPENSED: SensorEntityDescription( key=KegtronSensorDeviceClass.VOLUME_DISPENSED, icon="mdi:keg", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL, ), diff --git a/homeassistant/components/nsw_fuel_station/sensor.py b/homeassistant/components/nsw_fuel_station/sensor.py index 0bc2cf12be2..6ebbccc4466 100644 --- a/homeassistant/components/nsw_fuel_station/sensor.py +++ b/homeassistant/components/nsw_fuel_station/sensor.py @@ -6,7 +6,7 @@ import logging import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity -from homeassistant.const import CURRENCY_CENT, VOLUME_LITERS +from homeassistant.const import CURRENCY_CENT, UnitOfVolume from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -127,7 +127,7 @@ class StationPriceSensor( @property def native_unit_of_measurement(self) -> str: """Return the units of measurement.""" - return f"{CURRENCY_CENT}/{VOLUME_LITERS}" + return f"{CURRENCY_CENT}/{UnitOfVolume.LITERS}" def _get_station_name(self): default_name = f"station {self._station_id}" diff --git a/homeassistant/components/omnilogic/sensor.py b/homeassistant/components/omnilogic/sensor.py index 04bb1abf3e8..ba661c8cbd5 100644 --- a/homeassistant/components/omnilogic/sensor.py +++ b/homeassistant/components/omnilogic/sensor.py @@ -10,7 +10,7 @@ from homeassistant.const import ( PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT, - VOLUME_LITERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -174,7 +174,7 @@ class OmniLogicSaltLevelSensor(OmnilogicSensor): if self._unit_type == "Metric": salt_return = round(int(salt_return) / 1000, 2) - unit_of_measurement = f"{MASS_GRAMS}/{VOLUME_LITERS}" + unit_of_measurement = f"{MASS_GRAMS}/{UnitOfVolume.LITERS}" self._unit = unit_of_measurement diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index c100005e59e..108978b8521 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -17,9 +17,8 @@ from homeassistant.const import ( ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, POWER_WATT, - VOLUME_CUBIC_METERS, - VOLUME_LITERS, UnitOfElectricCurrent, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceEntryType @@ -42,7 +41,7 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = ( key="gas_consumption", name="Gas Consumption", entity_registry_enabled_default=False, - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.TOTAL_INCREASING, ), @@ -188,7 +187,7 @@ SENSORS_SETTINGS: tuple[SensorEntityDescription, ...] = ( name="Gas Consumption Price", entity_registry_enabled_default=False, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=f"{CURRENCY_EURO}/{VOLUME_CUBIC_METERS}", + native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfVolume.CUBIC_METERS}", ), SensorEntityDescription( key="energy_consumption_price_low", @@ -221,14 +220,14 @@ SENSORS_WATERMETER: tuple[SensorEntityDescription, ...] = ( key="consumption_day", name="Consumption Day", state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, device_class=SensorDeviceClass.WATER, ), SensorEntityDescription( key="consumption_total", name="Consumption Total", state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.WATER, ), SensorEntityDescription( diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index a59eb0cfc39..19b98085dcd 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -15,7 +15,7 @@ from homeassistant.const import ( POWER_WATT, PRESSURE_BAR, TEMP_CELSIUS, - VOLUME_CUBIC_METERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -222,14 +222,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="gas_consumed_interval", name="Gas consumed interval", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.TOTAL, ), SensorEntityDescription( key="gas_consumed_cumulative", name="Gas consumed cumulative", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, device_class=SensorDeviceClass.GAS, state_class=SensorStateClass.TOTAL, ), diff --git a/homeassistant/components/renault/sensor.py b/homeassistant/components/renault/sensor.py index b8b7f3d6a6c..c12587078bd 100644 --- a/homeassistant/components/renault/sensor.py +++ b/homeassistant/components/renault/sensor.py @@ -29,7 +29,7 @@ from homeassistant.const import ( POWER_KILO_WATT, TEMP_CELSIUS, TIME_MINUTES, - VOLUME_LITERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -312,7 +312,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = ( entity_class=RenaultSensor[KamereonVehicleCockpitData], icon="mdi:fuel", name="Fuel quantity", - native_unit_of_measurement=VOLUME_LITERS, + native_unit_of_measurement=UnitOfVolume.LITERS, state_class=SensorStateClass.MEASUREMENT, requires_fuel=True, value_lambda=_get_rounded_value, diff --git a/homeassistant/components/starline/sensor.py b/homeassistant/components/starline/sensor.py index 588b9f93e08..5b4954dcb05 100644 --- a/homeassistant/components/starline/sensor.py +++ b/homeassistant/components/starline/sensor.py @@ -14,7 +14,7 @@ from homeassistant.const import ( LENGTH_KILOMETERS, PERCENTAGE, TEMP_CELSIUS, - VOLUME_LITERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -160,7 +160,7 @@ class StarlineSensor(StarlineEntity, SensorEntity): if type_value == "percents": return PERCENTAGE if type_value == "litres": - return VOLUME_LITERS + return UnitOfVolume.LITERS return self.entity_description.native_unit_of_measurement @property diff --git a/homeassistant/components/subaru/sensor.py b/homeassistant/components/subaru/sensor.py index 9db2d329210..e8ca6b41e88 100644 --- a/homeassistant/components/subaru/sensor.py +++ b/homeassistant/components/subaru/sensor.py @@ -18,8 +18,7 @@ from homeassistant.const import ( LENGTH_MILES, PERCENTAGE, PRESSURE_HPA, - VOLUME_GALLONS, - VOLUME_LITERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity_registry as er @@ -55,7 +54,7 @@ _LOGGER = logging.getLogger(__name__) FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS = "L/100km" FUEL_CONSUMPTION_MILES_PER_GALLON = "mi/gal" -L_PER_GAL = VolumeConverter.convert(1, VOLUME_GALLONS, VOLUME_LITERS) +L_PER_GAL = VolumeConverter.convert(1, UnitOfVolume.GALLONS, UnitOfVolume.LITERS) KM_PER_MI = DistanceConverter.convert(1, LENGTH_MILES, LENGTH_KILOMETERS) # Sensor available to "Subaru Safety Plus" subscribers with Gen1 or Gen2 vehicles diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index 1ae22710060..5779fffef50 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -9,7 +9,7 @@ from surepy.enums import EntityType from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_VOLTAGE, PERCENTAGE, VOLUME_MILLILITERS +from homeassistant.const import ATTR_VOLTAGE, PERCENTAGE, UnitOfVolume from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -88,7 +88,7 @@ class Felaqua(SurePetcareEntity, SensorEntity): """Sure Petcare Felaqua.""" _attr_device_class = SensorDeviceClass.VOLUME - _attr_native_unit_of_measurement = VOLUME_MILLILITERS + _attr_native_unit_of_measurement = UnitOfVolume.MILLILITERS def __init__( self, surepetcare_id: int, coordinator: SurePetcareDataCoordinator diff --git a/homeassistant/components/toon/sensor.py b/homeassistant/components/toon/sensor.py index 9178cc6c01a..0fceb1a8a0a 100644 --- a/homeassistant/components/toon/sensor.py +++ b/homeassistant/components/toon/sensor.py @@ -15,7 +15,7 @@ from homeassistant.const import ( PERCENTAGE, POWER_WATT, TEMP_CELSIUS, - VOLUME_CUBIC_METERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -164,7 +164,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="gas_usage", measurement="day_average", device_class=SensorDeviceClass.GAS, - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, entity_registry_enabled_default=False, cls=ToonGasMeterDeviceSensor, ), @@ -174,7 +174,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( section="gas_usage", measurement="day_usage", device_class=SensorDeviceClass.GAS, - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, cls=ToonGasMeterDeviceSensor, ), ToonSensorEntityDescription( @@ -193,7 +193,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Gas Meter", section="gas_usage", measurement="meter", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, state_class=SensorStateClass.TOTAL_INCREASING, device_class=SensorDeviceClass.GAS, cls=ToonGasMeterDeviceSensor, @@ -312,7 +312,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Average Daily Water Usage", section="water_usage", measurement="day_average", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, icon="mdi:water", entity_registry_enabled_default=False, cls=ToonWaterMeterDeviceSensor, @@ -323,7 +323,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Water Usage Today", section="water_usage", measurement="day_usage", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, icon="mdi:water", entity_registry_enabled_default=False, cls=ToonWaterMeterDeviceSensor, @@ -334,7 +334,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Water Meter", section="water_usage", measurement="meter", - native_unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=UnitOfVolume.CUBIC_METERS, icon="mdi:water", entity_registry_enabled_default=False, state_class=SensorStateClass.TOTAL_INCREASING, diff --git a/homeassistant/components/youless/sensor.py b/homeassistant/components/youless/sensor.py index 53ffb223939..cb79d4606a7 100644 --- a/homeassistant/components/youless/sensor.py +++ b/homeassistant/components/youless/sensor.py @@ -13,7 +13,7 @@ from homeassistant.const import ( CONF_DEVICE, ENERGY_KILO_WATT_HOUR, POWER_WATT, - VOLUME_CUBIC_METERS, + UnitOfVolume, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -98,7 +98,7 @@ class YoulessBaseSensor(CoordinatorEntity, SensorEntity): class GasSensor(YoulessBaseSensor): """The Youless gas sensor.""" - _attr_native_unit_of_measurement = VOLUME_CUBIC_METERS + _attr_native_unit_of_measurement = UnitOfVolume.CUBIC_METERS _attr_device_class = SensorDeviceClass.GAS _attr_state_class = SensorStateClass.TOTAL_INCREASING