diff --git a/homeassistant/components/tado/sensor.py b/homeassistant/components/tado/sensor.py index 6d11e15a9fd..fdcc9c7db3e 100644 --- a/homeassistant/components/tado/sensor.py +++ b/homeassistant/components/tado/sensor.py @@ -7,7 +7,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import PERCENTAGE, TEMP_CELSIUS +from homeassistant.const import PERCENTAGE, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -139,7 +139,7 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity): def native_unit_of_measurement(self): """Return the unit of measurement.""" if self.home_variable in ["temperature", "outdoor temperature"]: - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS if self.home_variable == "solar percentage": return PERCENTAGE if self.home_variable == "weather condition": @@ -248,7 +248,7 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity): def native_unit_of_measurement(self): """Return the unit of measurement.""" if self.zone_variable == "temperature": - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS if self.zone_variable == "humidity": return PERCENTAGE if self.zone_variable == "heating": diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index b5296b5efd2..1375fd13338 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -26,9 +26,6 @@ from homeassistant.const import ( SPEED_KILOMETERS_PER_HOUR, SPEED_METERS_PER_SECOND, SPEED_MILES_PER_HOUR, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, - TEMP_KELVIN, UnitOfApparentPower, UnitOfElectricCurrent, UnitOfElectricPotential, @@ -38,6 +35,7 @@ from homeassistant.const import ( UnitOfMass, UnitOfPower, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -228,9 +226,9 @@ SENSOR_UNIT_MAP = { hc.SPEED_KILOMETERS_PER_HOUR: SPEED_KILOMETERS_PER_HOUR, hc.SPEED_METERS_PER_SECOND: SPEED_METERS_PER_SECOND, hc.SPEED_MILES_PER_HOUR: SPEED_MILES_PER_HOUR, - hc.TEMP_CELSIUS: TEMP_CELSIUS, - hc.TEMP_FAHRENHEIT: TEMP_FAHRENHEIT, - hc.TEMP_KELVIN: TEMP_KELVIN, + hc.TEMP_CELSIUS: UnitOfTemperature.CELSIUS, + hc.TEMP_FAHRENHEIT: UnitOfTemperature.FAHRENHEIT, + hc.TEMP_KELVIN: UnitOfTemperature.KELVIN, hc.VOLT: UnitOfElectricPotential.VOLT, } diff --git a/homeassistant/components/tellstick/sensor.py b/homeassistant/components/tellstick/sensor.py index bfd433e1674..cef118e721d 100644 --- a/homeassistant/components/tellstick/sensor.py +++ b/homeassistant/components/tellstick/sensor.py @@ -19,7 +19,7 @@ from homeassistant.const import ( CONF_NAME, CONF_PROTOCOL, PERCENTAGE, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -37,7 +37,7 @@ CONF_ONLY_NAMED = "only_named" CONF_TEMPERATURE_SCALE = "temperature_scale" DEFAULT_DATATYPE_MASK = 127 -DEFAULT_TEMPERATURE_SCALE = TEMP_CELSIUS +DEFAULT_TEMPERATURE_SCALE = UnitOfTemperature.CELSIUS PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { diff --git a/homeassistant/components/temper/sensor.py b/homeassistant/components/temper/sensor.py index 606227ee7f5..fd867527153 100644 --- a/homeassistant/components/temper/sensor.py +++ b/homeassistant/components/temper/sensor.py @@ -15,7 +15,7 @@ from homeassistant.const import ( CONF_NAME, CONF_OFFSET, DEVICE_DEFAULT_NAME, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -74,7 +74,7 @@ class TemperSensor(SensorEntity): """Representation of a Temper temperature sensor.""" _attr_device_class = SensorDeviceClass.TEMPERATURE - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS def __init__(self, temper_device, name, scaling): """Initialize the sensor.""" diff --git a/homeassistant/components/thermobeacon/sensor.py b/homeassistant/components/thermobeacon/sensor.py index 0faccd6b638..b651fb2cea0 100644 --- a/homeassistant/components/thermobeacon/sensor.py +++ b/homeassistant/components/thermobeacon/sensor.py @@ -25,8 +25,8 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, UnitOfElectricPotential, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -67,7 +67,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{ThermoBeaconSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), ( diff --git a/homeassistant/components/thermopro/sensor.py b/homeassistant/components/thermopro/sensor.py index 22a6e2f086a..8a2e68f1625 100644 --- a/homeassistant/components/thermopro/sensor.py +++ b/homeassistant/components/thermopro/sensor.py @@ -27,7 +27,7 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -42,7 +42,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{ThermoProSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), (ThermoProSensorDeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription( diff --git a/homeassistant/components/thermoworks_smoke/sensor.py b/homeassistant/components/thermoworks_smoke/sensor.py index 2297883ec6d..d5621c661d2 100644 --- a/homeassistant/components/thermoworks_smoke/sensor.py +++ b/homeassistant/components/thermoworks_smoke/sensor.py @@ -24,7 +24,7 @@ from homeassistant.const import ( CONF_EXCLUDE, CONF_MONITORED_CONDITIONS, CONF_PASSWORD, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -115,7 +115,7 @@ class ThermoworksSmokeSensor(SensorEntity): self._attr_name = "{name} {sensor}".format( name=mgr.name(serial), sensor=SENSOR_TYPES[sensor_type] ) - self._attr_native_unit_of_measurement = TEMP_FAHRENHEIT + self._attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT self._attr_unique_id = f"{serial}-{sensor_type}" self._attr_device_class = SensorDeviceClass.TEMPERATURE self.update_unit() diff --git a/homeassistant/components/tilt_ble/sensor.py b/homeassistant/components/tilt_ble/sensor.py index bddae2ca027..be0e9e66037 100644 --- a/homeassistant/components/tilt_ble/sensor.py +++ b/homeassistant/components/tilt_ble/sensor.py @@ -19,7 +19,7 @@ from homeassistant.components.sensor import ( SensorEntityDescription, SensorStateClass, ) -from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_FAHRENHEIT +from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.sensor import sensor_device_info_to_hass_device_info @@ -30,7 +30,7 @@ SENSOR_DESCRIPTIONS = { (DeviceClass.TEMPERATURE, Units.TEMP_FAHRENHEIT): SensorEntityDescription( key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_FAHRENHEIT}", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_FAHRENHEIT, + native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT, state_class=SensorStateClass.MEASUREMENT, ), (DeviceClass.SPECIFIC_GRAVITY, Units.SPECIFIC_GRAVITY): SensorEntityDescription( diff --git a/homeassistant/components/tolo/sensor.py b/homeassistant/components/tolo/sensor.py index e53351d6de4..6d496b416ff 100644 --- a/homeassistant/components/tolo/sensor.py +++ b/homeassistant/components/tolo/sensor.py @@ -13,7 +13,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, UnitOfTime +from homeassistant.const import PERCENTAGE, UnitOfTemperature, UnitOfTime from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -54,7 +54,7 @@ SENSORS = ( device_class=SensorDeviceClass.TEMPERATURE, entity_category=EntityCategory.DIAGNOSTIC, name="Tank Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, getter=lambda status: status.tank_temperature, availability_checker=None, ), diff --git a/homeassistant/components/toon/sensor.py b/homeassistant/components/toon/sensor.py index 2ac413b57a5..3b06f5d38b9 100644 --- a/homeassistant/components/toon/sensor.py +++ b/homeassistant/components/toon/sensor.py @@ -12,9 +12,9 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, - TEMP_CELSIUS, UnitOfEnergy, UnitOfPower, + UnitOfTemperature, UnitOfVolume, ) from homeassistant.core import HomeAssistant @@ -132,7 +132,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( name="Temperature", section="thermostat", measurement="current_display_temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, entity_registry_enabled_default=False, state_class=SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/unifiprotect/sensor.py b/homeassistant/components/unifiprotect/sensor.py index bb0669f0815..1851b1ea776 100644 --- a/homeassistant/components/unifiprotect/sensor.py +++ b/homeassistant/components/unifiprotect/sensor.py @@ -29,10 +29,10 @@ from homeassistant.const import ( LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, UnitOfDataRate, UnitOfElectricPotential, UnitOfInformation, + UnitOfTemperature, UnitOfTime, ) from homeassistant.core import HomeAssistant, callback @@ -320,7 +320,7 @@ SENSE_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( ProtectSensorEntityDescription( key="temperature_level", name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ufp_value="stats.temperature.value", @@ -504,7 +504,7 @@ NVR_DISABLED_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( ProtectSensorEntityDescription( key="cpu_temperature", name="CPU Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, entity_registry_enabled_default=False, entity_category=EntityCategory.DIAGNOSTIC, diff --git a/homeassistant/components/vallox/number.py b/homeassistant/components/vallox/number.py index 5be91fe66e6..81d1557f938 100644 --- a/homeassistant/components/vallox/number.py +++ b/homeassistant/components/vallox/number.py @@ -11,7 +11,7 @@ from homeassistant.components.number import ( NumberEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -80,7 +80,7 @@ NUMBER_ENTITIES: tuple[ValloxNumberEntityDescription, ...] = ( name="Supply air temperature (Home)", metric_key="A_CYC_HOME_AIR_TEMP_TARGET", device_class=NumberDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, icon="mdi:thermometer", native_min_value=5.0, native_max_value=25.0, @@ -91,7 +91,7 @@ NUMBER_ENTITIES: tuple[ValloxNumberEntityDescription, ...] = ( name="Supply air temperature (Away)", metric_key="A_CYC_AWAY_AIR_TEMP_TARGET", device_class=NumberDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, icon="mdi:thermometer", native_min_value=5.0, native_max_value=25.0, @@ -102,7 +102,7 @@ NUMBER_ENTITIES: tuple[ValloxNumberEntityDescription, ...] = ( name="Supply air temperature (Boost)", metric_key="A_CYC_BOOST_AIR_TEMP_TARGET", device_class=NumberDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, icon="mdi:thermometer", native_min_value=5.0, native_max_value=25.0, diff --git a/homeassistant/components/vallox/sensor.py b/homeassistant/components/vallox/sensor.py index c0cc5150ef2..da3df00af50 100644 --- a/homeassistant/components/vallox/sensor.py +++ b/homeassistant/components/vallox/sensor.py @@ -15,7 +15,7 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, REVOLUTIONS_PER_MINUTE, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -190,7 +190,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = ( metric_key="A_CYC_TEMP_EXTRACT_AIR", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ValloxSensorEntityDescription( key="exhaust_air", @@ -198,7 +198,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = ( metric_key="A_CYC_TEMP_EXHAUST_AIR", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ValloxSensorEntityDescription( key="outdoor_air", @@ -206,7 +206,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = ( metric_key="A_CYC_TEMP_OUTDOOR_AIR", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ValloxSensorEntityDescription( key="supply_air", @@ -214,7 +214,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = ( metric_key="A_CYC_TEMP_SUPPLY_AIR", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ValloxSensorEntityDescription( key="supply_cell_air", @@ -222,7 +222,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = ( metric_key="A_CYC_TEMP_SUPPLY_CELL_AIR", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ValloxSensorEntityDescription( key="optional_air", @@ -230,7 +230,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = ( metric_key="A_CYC_TEMP_OPTIONAL", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, entity_registry_enabled_default=False, ), ValloxSensorEntityDescription( diff --git a/homeassistant/components/venstar/sensor.py b/homeassistant/components/venstar/sensor.py index 80e600f6890..0bb2c7d2bc0 100644 --- a/homeassistant/components/venstar/sensor.py +++ b/homeassistant/components/venstar/sensor.py @@ -15,8 +15,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, UnitOfTime, ) from homeassistant.core import HomeAssistant @@ -106,9 +105,9 @@ async def async_setup_entry( def temperature_unit(coordinator: VenstarDataUpdateCoordinator) -> str: """Return the correct unit for temperature.""" - unit = TEMP_CELSIUS + unit = UnitOfTemperature.CELSIUS if coordinator.client.tempunits == coordinator.client.TEMPUNITS_F: - unit = TEMP_FAHRENHEIT + unit = UnitOfTemperature.FAHRENHEIT return unit diff --git a/homeassistant/components/vera/sensor.py b/homeassistant/components/vera/sensor.py index 532e44f4a43..b493f9aac3d 100644 --- a/homeassistant/components/vera/sensor.py +++ b/homeassistant/components/vera/sensor.py @@ -15,10 +15,9 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( LIGHT_LUX, PERCENTAGE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, Platform, UnitOfPower, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -102,9 +101,9 @@ class VeraSensor(VeraDevice[veraApi.VeraSensor], SensorEntity): vera_temp_units = self.vera_device.vera_controller.temperature_units if vera_temp_units == "F": - self._temperature_units = TEMP_FAHRENHEIT + self._temperature_units = UnitOfTemperature.FAHRENHEIT else: - self._temperature_units = TEMP_CELSIUS + self._temperature_units = UnitOfTemperature.CELSIUS elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR: self.current_value = self.vera_device.light diff --git a/homeassistant/components/verisure/sensor.py b/homeassistant/components/verisure/sensor.py index 676082e4cda..bbc1c15159c 100644 --- a/homeassistant/components/verisure/sensor.py +++ b/homeassistant/components/verisure/sensor.py @@ -7,7 +7,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import PERCENTAGE, TEMP_CELSIUS +from homeassistant.const import PERCENTAGE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -53,7 +53,7 @@ class VerisureThermometer( _attr_device_class = SensorDeviceClass.TEMPERATURE _attr_has_entity_name = True _attr_name = "Temperature" - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS _attr_state_class = SensorStateClass.MEASUREMENT def __init__( diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index c821824d279..3cd9378cfca 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -21,8 +21,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_OFF, STATE_ON, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, ServiceCall import homeassistant.helpers.config_validation as cv @@ -184,7 +183,7 @@ class WaterHeaterEntity(Entity): """Return the precision of the system.""" if hasattr(self, "_attr_precision"): return self._attr_precision - if self.hass.config.units.temperature_unit == TEMP_CELSIUS: + if self.hass.config.units.temperature_unit == UnitOfTemperature.CELSIUS: return PRECISION_TENTHS return PRECISION_WHOLE @@ -325,7 +324,7 @@ class WaterHeaterEntity(Entity): if hasattr(self, "_attr_min_temp"): return self._attr_min_temp return TemperatureConverter.convert( - DEFAULT_MIN_TEMP, TEMP_FAHRENHEIT, self.temperature_unit + DEFAULT_MIN_TEMP, UnitOfTemperature.FAHRENHEIT, self.temperature_unit ) @property @@ -334,7 +333,7 @@ class WaterHeaterEntity(Entity): if hasattr(self, "_attr_max_temp"): return self._attr_max_temp return TemperatureConverter.convert( - DEFAULT_MAX_TEMP, TEMP_FAHRENHEIT, self.temperature_unit + DEFAULT_MAX_TEMP, UnitOfTemperature.FAHRENHEIT, self.temperature_unit ) @property diff --git a/homeassistant/components/wiffi/sensor.py b/homeassistant/components/wiffi/sensor.py index 5c39fbe1e8a..b53a9140857 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, TEMP_CELSIUS, UnitOfPressure +from homeassistant.const import DEGREE, UnitOfPressure, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -31,7 +31,7 @@ UOM_TO_DEVICE_CLASS_MAP = { # map to convert wiffi unit of measurements to common HA uom's UOM_MAP = { WIFFI_UOM_DEGREE: DEGREE, - WIFFI_UOM_TEMP_CELSIUS: TEMP_CELSIUS, + WIFFI_UOM_TEMP_CELSIUS: UnitOfTemperature.CELSIUS, WIFFI_UOM_MILLI_BAR: UnitOfPressure.MBAR, } diff --git a/homeassistant/components/wolflink/sensor.py b/homeassistant/components/wolflink/sensor.py index ef55baadf53..3da12b65d5f 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 TEMP_CELSIUS, UnitOfPressure, UnitOfTime +from homeassistant.const import UnitOfPressure, UnitOfTemperature, UnitOfTime from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -114,7 +114,7 @@ class WolfLinkTemperature(WolfLinkSensor): @property def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS class WolfLinkPressure(WolfLinkSensor): diff --git a/homeassistant/components/xiaomi_aqara/sensor.py b/homeassistant/components/xiaomi_aqara/sensor.py index 6e2f17d7408..54ac3db120f 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, - TEMP_CELSIUS, UnitOfPower, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -29,7 +29,7 @@ _LOGGER = logging.getLogger(__name__) SENSOR_TYPES: dict[str, SensorEntityDescription] = { "temperature": SensorEntityDescription( key="temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/xiaomi_ble/sensor.py b/homeassistant/components/xiaomi_ble/sensor.py index a17a6e97483..334099cdbb6 100644 --- a/homeassistant/components/xiaomi_ble/sensor.py +++ b/homeassistant/components/xiaomi_ble/sensor.py @@ -24,9 +24,9 @@ from homeassistant.const import ( LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, UnitOfElectricPotential, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -96,7 +96,7 @@ SENSOR_DESCRIPTIONS = { (DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription( key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), (DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription( diff --git a/homeassistant/components/zwave_me/sensor.py b/homeassistant/components/zwave_me/sensor.py index d31af5bd9da..89048f4fec9 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, - TEMP_CELSIUS, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -103,7 +103,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = { "temperature": ZWaveMeSensorEntityDescription( key="temperature", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), "generic": ZWaveMeSensorEntityDescription(