diff --git a/homeassistant/components/advantage_air/sensor.py b/homeassistant/components/advantage_air/sensor.py index 60e640d36e9..270f2efbc6e 100644 --- a/homeassistant/components/advantage_air/sensor.py +++ b/homeassistant/components/advantage_air/sensor.py @@ -12,7 +12,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 import config_validation as cv, entity_platform from homeassistant.helpers.entity import EntityCategory @@ -155,7 +155,7 @@ class AdvantageAirZoneSignal(AdvantageAirZoneEntity, SensorEntity): class AdvantageAirZoneTemp(AdvantageAirZoneEntity, SensorEntity): """Representation of Advantage Air Zone temperature sensor.""" - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS _attr_device_class = SensorDeviceClass.TEMPERATURE _attr_state_class = SensorStateClass.MEASUREMENT _attr_entity_registry_enabled_default = False diff --git a/homeassistant/components/airly/sensor.py b/homeassistant/components/airly/sensor.py index 38c3cf69e89..c85db155a55 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, - TEMP_CELSIUS, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceEntryType @@ -112,7 +112,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = ( key=ATTR_API_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE, name=ATTR_API_TEMPERATURE.capitalize(), - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, value=lambda value: round(value, 1), ), diff --git a/homeassistant/components/airthings/sensor.py b/homeassistant/components/airthings/sensor.py index 2f28574796f..481150f77dd 100644 --- a/homeassistant/components/airthings/sensor.py +++ b/homeassistant/components/airthings/sensor.py @@ -16,8 +16,8 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, - TEMP_CELSIUS, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo, EntityCategory @@ -39,7 +39,7 @@ SENSORS: dict[str, SensorEntityDescription] = { "temp": SensorEntityDescription( key="temp", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, name="Temperature", ), "humidity": SensorEntityDescription( diff --git a/homeassistant/components/airthings_ble/sensor.py b/homeassistant/components/airthings_ble/sensor.py index 90e953383ac..57a8c3827d2 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, - TEMP_CELSIUS, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH @@ -63,7 +63,7 @@ SENSORS_MAPPING_TEMPLATE: dict[str, SensorEntityDescription] = { "temperature": SensorEntityDescription( key="temperature", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, name="Temperature", ), "humidity": SensorEntityDescription( diff --git a/homeassistant/components/airvisual/sensor.py b/homeassistant/components/airvisual/sensor.py index a522677be2a..c52eb9a2334 100644 --- a/homeassistant/components/airvisual/sensor.py +++ b/homeassistant/components/airvisual/sensor.py @@ -20,7 +20,7 @@ from homeassistant.const import ( CONF_SHOW_ON_MAP, CONF_STATE, PERCENTAGE, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory @@ -136,7 +136,7 @@ NODE_PRO_SENSOR_DESCRIPTIONS = ( key=SENSOR_KIND_TEMPERATURE, name="Temperature", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( diff --git a/homeassistant/components/airzone/const.py b/homeassistant/components/airzone/const.py index 345a07692c5..2263d5ab4a3 100644 --- a/homeassistant/components/airzone/const.py +++ b/homeassistant/components/airzone/const.py @@ -4,7 +4,7 @@ from typing import Final from aioairzone.common import TemperatureUnit -from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import UnitOfTemperature DOMAIN: Final = "airzone" MANUFACTURER: Final = "Airzone" @@ -13,6 +13,6 @@ AIOAIRZONE_DEVICE_TIMEOUT_SEC: Final = 10 API_TEMPERATURE_STEP: Final = 0.5 TEMP_UNIT_LIB_TO_HASS: Final[dict[TemperatureUnit, str]] = { - TemperatureUnit.CELSIUS: TEMP_CELSIUS, - TemperatureUnit.FAHRENHEIT: TEMP_FAHRENHEIT, + TemperatureUnit.CELSIUS: UnitOfTemperature.CELSIUS, + TemperatureUnit.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT, } diff --git a/homeassistant/components/airzone/sensor.py b/homeassistant/components/airzone/sensor.py index 86d88aa5a55..ed07b5a0764 100644 --- a/homeassistant/components/airzone/sensor.py +++ b/homeassistant/components/airzone/sensor.py @@ -23,7 +23,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory @@ -50,7 +50,7 @@ ZONE_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = ( device_class=SensorDeviceClass.TEMPERATURE, key=AZD_TEMP, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( diff --git a/homeassistant/components/aranet/sensor.py b/homeassistant/components/aranet/sensor.py index f3794e87e7a..512748fef8d 100644 --- a/homeassistant/components/aranet/sensor.py +++ b/homeassistant/components/aranet/sensor.py @@ -25,8 +25,8 @@ from homeassistant.const import ( ATTR_SW_VERSION, CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, - TEMP_CELSIUS, UnitOfPressure, + UnitOfTemperature, UnitOfTime, ) from homeassistant.core import HomeAssistant @@ -40,7 +40,7 @@ SENSOR_DESCRIPTIONS = { key="temperature", name="Temperature", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), "humidity": SensorEntityDescription( diff --git a/homeassistant/components/atag/sensor.py b/homeassistant/components/atag/sensor.py index 32e931b5d45..a006d1dfe05 100644 --- a/homeassistant/components/atag/sensor.py +++ b/homeassistant/components/atag/sensor.py @@ -3,9 +3,8 @@ from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, UnitOfPressure, + UnitOfTemperature, UnitOfTime, ) from homeassistant.core import HomeAssistant @@ -49,8 +48,8 @@ class AtagSensor(AtagEntity, SensorEntity): self._attr_device_class = coordinator.data.report[self._id].sensorclass if coordinator.data.report[self._id].measure in ( UnitOfPressure.BAR, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature.CELSIUS, + UnitOfTemperature.FAHRENHEIT, PERCENTAGE, UnitOfTime.HOURS, ): diff --git a/homeassistant/components/aurora_abb_powerone/sensor.py b/homeassistant/components/aurora_abb_powerone/sensor.py index 77d78eac4d6..2502f808e51 100644 --- a/homeassistant/components/aurora_abb_powerone/sensor.py +++ b/homeassistant/components/aurora_abb_powerone/sensor.py @@ -14,7 +14,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS, UnitOfEnergy, UnitOfPower +from homeassistant.const import UnitOfEnergy, UnitOfPower, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -36,7 +36,7 @@ SENSOR_TYPES = [ key="temp", device_class=SensorDeviceClass.TEMPERATURE, entity_category=EntityCategory.DIAGNOSTIC, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, name="Temperature", ), diff --git a/homeassistant/components/baf/sensor.py b/homeassistant/components/baf/sensor.py index 79ae320969b..81b48ae59d7 100644 --- a/homeassistant/components/baf/sensor.py +++ b/homeassistant/components/baf/sensor.py @@ -14,7 +14,7 @@ from homeassistant.components.sensor import ( SensorEntityDescription, SensorStateClass, ) -from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS +from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -43,7 +43,7 @@ AUTO_COMFORT_SENSORS = ( BAFSensorDescription( key="temperature", name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda device: cast(Optional[float], device.temperature), diff --git a/homeassistant/components/beewi_smartclim/sensor.py b/homeassistant/components/beewi_smartclim/sensor.py index 4d8936859f5..0bb3a5bbb69 100644 --- a/homeassistant/components/beewi_smartclim/sensor.py +++ b/homeassistant/components/beewi_smartclim/sensor.py @@ -9,7 +9,7 @@ from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, ) -from homeassistant.const import CONF_MAC, CONF_NAME, PERCENTAGE, TEMP_CELSIUS +from homeassistant.const import CONF_MAC, CONF_NAME, PERCENTAGE, UnitOfTemperature from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -20,7 +20,7 @@ DEFAULT_NAME = "BeeWi SmartClim" # Sensor config SENSOR_TYPES = [ - [SensorDeviceClass.TEMPERATURE, "Temperature", TEMP_CELSIUS], + [SensorDeviceClass.TEMPERATURE, "Temperature", UnitOfTemperature.CELSIUS], [SensorDeviceClass.HUMIDITY, "Humidity", PERCENTAGE], [SensorDeviceClass.BATTERY, "Battery", PERCENTAGE], ] diff --git a/homeassistant/components/blebox/sensor.py b/homeassistant/components/blebox/sensor.py index 471f8c6eb86..82c9bb876d7 100644 --- a/homeassistant/components/blebox/sensor.py +++ b/homeassistant/components/blebox/sensor.py @@ -9,7 +9,10 @@ from homeassistant.components.sensor import ( SensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, TEMP_CELSIUS +from homeassistant.const import ( + CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + UnitOfTemperature, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -35,7 +38,7 @@ SENSOR_TYPES = ( SensorEntityDescription( key="temperature", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ) diff --git a/homeassistant/components/blink/sensor.py b/homeassistant/components/blink/sensor.py index 3940522074b..bc52f484243 100644 --- a/homeassistant/components/blink/sensor.py +++ b/homeassistant/components/blink/sensor.py @@ -9,7 +9,7 @@ from homeassistant.components.sensor import ( SensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -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 import DeviceInfo, EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -22,7 +22,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=TYPE_TEMPERATURE, name="Temperature", - native_unit_of_measurement=TEMP_FAHRENHEIT, + native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT, device_class=SensorDeviceClass.TEMPERATURE, entity_category=EntityCategory.DIAGNOSTIC, ), diff --git a/homeassistant/components/bluemaestro/sensor.py b/homeassistant/components/bluemaestro/sensor.py index 399f662d264..d3776d418e5 100644 --- a/homeassistant/components/bluemaestro/sensor.py +++ b/homeassistant/components/bluemaestro/sensor.py @@ -25,8 +25,8 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -67,7 +67,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{BlueMaestroSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), ( @@ -76,7 +76,7 @@ SENSOR_DESCRIPTIONS = { ): SensorEntityDescription( key=f"{BlueMaestroSensorDeviceClass.DEW_POINT}_{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/bosch_shc/sensor.py b/homeassistant/components/bosch_shc/sensor.py index ae9c5692445..dad816a0908 100644 --- a/homeassistant/components/bosch_shc/sensor.py +++ b/homeassistant/components/bosch_shc/sensor.py @@ -13,9 +13,9 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, - TEMP_CELSIUS, UnitOfEnergy, UnitOfPower, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -164,7 +164,7 @@ class TemperatureSensor(SHCEntity, SensorEntity): """Representation of an SHC temperature reporting sensor.""" _attr_device_class = SensorDeviceClass.TEMPERATURE - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC temperature reporting sensor.""" diff --git a/homeassistant/components/broadlink/sensor.py b/homeassistant/components/broadlink/sensor.py index a9218f8308c..c86662963a2 100644 --- a/homeassistant/components/broadlink/sensor.py +++ b/homeassistant/components/broadlink/sensor.py @@ -10,11 +10,11 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, - TEMP_CELSIUS, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -26,7 +26,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="temperature", name="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/canary/sensor.py b/homeassistant/components/canary/sensor.py index 95204550af7..0b77815ce42 100644 --- a/homeassistant/components/canary/sensor.py +++ b/homeassistant/components/canary/sensor.py @@ -10,7 +10,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -37,7 +37,13 @@ CANARY_FLEX: Final = "Canary Flex" # Sensor types are defined like so: # sensor type name, unit_of_measurement, icon, device class, products supported SENSOR_TYPES: Final[list[SensorTypeItem]] = [ - ("temperature", TEMP_CELSIUS, None, SensorDeviceClass.TEMPERATURE, [CANARY_PRO]), + ( + "temperature", + UnitOfTemperature.CELSIUS, + None, + SensorDeviceClass.TEMPERATURE, + [CANARY_PRO], + ), ("humidity", PERCENTAGE, None, SensorDeviceClass.HUMIDITY, [CANARY_PRO]), ("air_quality", None, "mdi:weather-windy", None, [CANARY_PRO]), ( diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index 68338819421..ed0f8f2a4aa 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -18,7 +18,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_OFF, STATE_ON, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, ServiceCall import homeassistant.helpers.config_validation as cv @@ -250,7 +250,7 @@ class ClimateEntity(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 @@ -561,7 +561,7 @@ class ClimateEntity(Entity): """Return the minimum temperature.""" if not hasattr(self, "_attr_min_temp"): return TemperatureConverter.convert( - DEFAULT_MIN_TEMP, TEMP_CELSIUS, self.temperature_unit + DEFAULT_MIN_TEMP, UnitOfTemperature.CELSIUS, self.temperature_unit ) return self._attr_min_temp @@ -570,7 +570,7 @@ class ClimateEntity(Entity): """Return the maximum temperature.""" if not hasattr(self, "_attr_max_temp"): return TemperatureConverter.convert( - DEFAULT_MAX_TEMP, TEMP_CELSIUS, self.temperature_unit + DEFAULT_MAX_TEMP, UnitOfTemperature.CELSIUS, self.temperature_unit ) return self._attr_max_temp diff --git a/homeassistant/components/comfoconnect/sensor.py b/homeassistant/components/comfoconnect/sensor.py index 7194b0a812d..cb5ed561e6e 100644 --- a/homeassistant/components/comfoconnect/sensor.py +++ b/homeassistant/components/comfoconnect/sensor.py @@ -40,10 +40,10 @@ from homeassistant.const import ( CONF_RESOURCES, PERCENTAGE, REVOLUTIONS_PER_MINUTE, - TEMP_CELSIUS, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, UnitOfEnergy, UnitOfPower, + UnitOfTemperature, UnitOfTime, ) from homeassistant.core import HomeAssistant @@ -101,7 +101,7 @@ SENSOR_TYPES = ( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, name="Inside temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, sensor_id=SENSOR_TEMPERATURE_EXTRACT, multiplier=0.1, ), @@ -118,7 +118,7 @@ SENSOR_TYPES = ( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, name="Current RMOT", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, sensor_id=SENSOR_CURRENT_RMOT, multiplier=0.1, ), @@ -127,7 +127,7 @@ SENSOR_TYPES = ( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, name="Outside temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, sensor_id=SENSOR_TEMPERATURE_OUTDOOR, multiplier=0.1, ), @@ -144,7 +144,7 @@ SENSOR_TYPES = ( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, name="Supply temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, sensor_id=SENSOR_TEMPERATURE_SUPPLY, multiplier=0.1, ), @@ -193,7 +193,7 @@ SENSOR_TYPES = ( device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, name="Exhaust temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, sensor_id=SENSOR_TEMPERATURE_EXHAUST, multiplier=0.1, ), diff --git a/homeassistant/components/daikin/sensor.py b/homeassistant/components/daikin/sensor.py index 58e084df3d4..2660a1a9d3a 100644 --- a/homeassistant/components/daikin/sensor.py +++ b/homeassistant/components/daikin/sensor.py @@ -15,10 +15,10 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, - TEMP_CELSIUS, UnitOfEnergy, UnitOfFrequency, UnitOfPower, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -58,7 +58,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( name="Inside temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, value_func=lambda device: device.inside_temperature, ), DaikinSensorEntityDescription( @@ -66,7 +66,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = ( name="Outside temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, value_func=lambda device: device.outside_temperature, ), DaikinSensorEntityDescription( diff --git a/homeassistant/components/danfoss_air/sensor.py b/homeassistant/components/danfoss_air/sensor.py index 51eab3e471c..024bb50ba34 100644 --- a/homeassistant/components/danfoss_air/sensor.py +++ b/homeassistant/components/danfoss_air/sensor.py @@ -10,7 +10,7 @@ from homeassistant.components.sensor import ( SensorEntity, SensorStateClass, ) -from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS +from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -32,28 +32,28 @@ def setup_platform( sensors = [ [ "Danfoss Air Exhaust Temperature", - TEMP_CELSIUS, + UnitOfTemperature.CELSIUS, ReadCommand.exhaustTemperature, SensorDeviceClass.TEMPERATURE, SensorStateClass.MEASUREMENT, ], [ "Danfoss Air Outdoor Temperature", - TEMP_CELSIUS, + UnitOfTemperature.CELSIUS, ReadCommand.outdoorTemperature, SensorDeviceClass.TEMPERATURE, SensorStateClass.MEASUREMENT, ], [ "Danfoss Air Supply Temperature", - TEMP_CELSIUS, + UnitOfTemperature.CELSIUS, ReadCommand.supplyTemperature, SensorDeviceClass.TEMPERATURE, SensorStateClass.MEASUREMENT, ], [ "Danfoss Air Extract Temperature", - TEMP_CELSIUS, + UnitOfTemperature.CELSIUS, ReadCommand.extractTemperature, SensorDeviceClass.TEMPERATURE, SensorStateClass.MEASUREMENT, diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index f24c2438c7d..29b2842fd91 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, - TEMP_CELSIUS, UnitOfEnergy, UnitOfPower, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory @@ -200,7 +200,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = ( instance_check=Temperature, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), DeconzSensorDescription[Time]( key="last_set", @@ -231,7 +231,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = ( old_unique_id_suffix="temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), ) diff --git a/homeassistant/components/dlink/switch.py b/homeassistant/components/dlink/switch.py index f1ca99c51f2..b38460ddb8f 100644 --- a/homeassistant/components/dlink/switch.py +++ b/homeassistant/components/dlink/switch.py @@ -16,7 +16,7 @@ from homeassistant.const import ( CONF_NAME, CONF_PASSWORD, CONF_USERNAME, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -85,7 +85,9 @@ class SmartPlugSwitch(SwitchEntity): def extra_state_attributes(self): """Return the state attributes of the device.""" try: - ui_temp = self.units.temperature(int(self.data.temperature), TEMP_CELSIUS) + ui_temp = self.units.temperature( + int(self.data.temperature), UnitOfTemperature.CELSIUS + ) temperature = ui_temp except (ValueError, TypeError): temperature = None