diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index 0e8b968ca7c..f91e0f45b75 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -16,7 +16,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -213,7 +213,7 @@ def create_climate_entity(tado, name: str, zone_id: int, device_info: dict): class TadoClimate(TadoZoneEntity, ClimateEntity): """Representation of a Tado climate entity.""" - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__( self, diff --git a/homeassistant/components/tfiac/climate.py b/homeassistant/components/tfiac/climate.py index 73e52ca1584..2e764b5c637 100644 --- a/homeassistant/components/tfiac/climate.py +++ b/homeassistant/components/tfiac/climate.py @@ -23,7 +23,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, TEMP_FAHRENHEIT +from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, UnitOfTemperature from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -84,7 +84,7 @@ class TfiacClimate(ClimateEntity): | ClimateEntityFeature.SWING_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ) - _attr_temperature_unit = TEMP_FAHRENHEIT + _attr_temperature_unit = UnitOfTemperature.FAHRENHEIT def __init__(self, hass, client): """Init class.""" diff --git a/homeassistant/components/tolo/climate.py b/homeassistant/components/tolo/climate.py index e82fe34ab84..3afc641ba22 100644 --- a/homeassistant/components/tolo/climate.py +++ b/homeassistant/components/tolo/climate.py @@ -14,7 +14,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -55,7 +55,7 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity): | ClimateEntityFeature.FAN_MODE ) _attr_target_temperature_step = 1 - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__( self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry diff --git a/homeassistant/components/toon/climate.py b/homeassistant/components/toon/climate.py index 4216d1c13fa..cc51bb03fec 100644 --- a/homeassistant/components/toon/climate.py +++ b/homeassistant/components/toon/climate.py @@ -21,7 +21,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -50,7 +50,7 @@ class ToonThermostatDevice(ToonDisplayDeviceEntity, ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__( self, diff --git a/homeassistant/components/touchline/climate.py b/homeassistant/components/touchline/climate.py index 4ce1c4553cb..ed3d4500db1 100644 --- a/homeassistant/components/touchline/climate.py +++ b/homeassistant/components/touchline/climate.py @@ -12,7 +12,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, UnitOfTemperature from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -68,7 +68,7 @@ class Touchline(ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, touchline_thermostat): """Initialize the Touchline device.""" diff --git a/homeassistant/components/tuya/climate.py b/homeassistant/components/tuya/climate.py index 20e36028dba..1dce6ddad92 100644 --- a/homeassistant/components/tuya/climate.py +++ b/homeassistant/components/tuya/climate.py @@ -18,7 +18,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -147,16 +147,16 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity): ) or all( dpcode in device.status for dpcode in (DPCode.TEMP_SET, DPCode.TEMP_SET_F) ): - prefered_temperature_unit = TEMP_CELSIUS + prefered_temperature_unit = UnitOfTemperature.CELSIUS if any( "f" in device.status[dpcode].lower() for dpcode in (DPCode.C_F, DPCode.TEMP_UNIT_CONVERT) if isinstance(device.status.get(dpcode), str) ): - prefered_temperature_unit = TEMP_FAHRENHEIT + prefered_temperature_unit = UnitOfTemperature.FAHRENHEIT # Default to Celsius - self._attr_temperature_unit = TEMP_CELSIUS + self._attr_temperature_unit = UnitOfTemperature.CELSIUS # Figure out current temperature, use preferred unit or what is available celsius_type = self.find_dpcode( @@ -166,13 +166,16 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity): (DPCode.TEMP_CURRENT_F, DPCode.UPPER_TEMP_F), dptype=DPType.INTEGER ) if farhenheit_type and ( - prefered_temperature_unit == TEMP_FAHRENHEIT - or (prefered_temperature_unit == TEMP_CELSIUS and not celsius_type) + prefered_temperature_unit == UnitOfTemperature.FAHRENHEIT + or ( + prefered_temperature_unit == UnitOfTemperature.CELSIUS + and not celsius_type + ) ): - self._attr_temperature_unit = TEMP_FAHRENHEIT + self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT self._current_temperature = farhenheit_type elif celsius_type: - self._attr_temperature_unit = TEMP_CELSIUS + self._attr_temperature_unit = UnitOfTemperature.CELSIUS self._current_temperature = celsius_type # Figure out setting temperature, use preferred unit or what is available @@ -183,8 +186,11 @@ class TuyaClimateEntity(TuyaEntity, ClimateEntity): DPCode.TEMP_SET_F, dptype=DPType.INTEGER, prefer_function=True ) if farhenheit_type and ( - prefered_temperature_unit == TEMP_FAHRENHEIT - or (prefered_temperature_unit == TEMP_CELSIUS and not celsius_type) + prefered_temperature_unit == UnitOfTemperature.FAHRENHEIT + or ( + prefered_temperature_unit == UnitOfTemperature.CELSIUS + and not celsius_type + ) ): self._set_temperature = farhenheit_type elif celsius_type: diff --git a/homeassistant/components/velbus/climate.py b/homeassistant/components/velbus/climate.py index 76eb3e30fa0..ccdfb3b073b 100644 --- a/homeassistant/components/velbus/climate.py +++ b/homeassistant/components/velbus/climate.py @@ -11,7 +11,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -40,7 +40,7 @@ class VelbusClimate(VelbusEntity, ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_hvac_mode = HVACMode.HEAT _attr_hvac_modes = [HVACMode.HEAT] _attr_preset_modes = list(PRESET_MODES) diff --git a/homeassistant/components/venstar/climate.py b/homeassistant/components/venstar/climate.py index 2a921fe3731..1d310052327 100644 --- a/homeassistant/components/venstar/climate.py +++ b/homeassistant/components/venstar/climate.py @@ -28,8 +28,7 @@ from homeassistant.const import ( CONF_USERNAME, PRECISION_HALVES, STATE_ON, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -145,8 +144,8 @@ class VenstarThermostat(VenstarEntity, ClimateEntity): def temperature_unit(self) -> str: """Return the unit of measurement, as defined by the API.""" if self._client.tempunits == self._client.TEMPUNITS_F: - return TEMP_FAHRENHEIT - return TEMP_CELSIUS + return UnitOfTemperature.FAHRENHEIT + return UnitOfTemperature.CELSIUS @property def current_temperature(self): diff --git a/homeassistant/components/vera/climate.py b/homeassistant/components/vera/climate.py index 924acbe6243..164da079ac1 100644 --- a/homeassistant/components/vera/climate.py +++ b/homeassistant/components/vera/climate.py @@ -14,12 +14,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_TEMPERATURE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, - Platform, -) +from homeassistant.const import ATTR_TEMPERATURE, Platform, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -104,9 +99,9 @@ class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity): vera_temp_units = self.vera_device.vera_controller.temperature_units if vera_temp_units == "F": - return TEMP_FAHRENHEIT + return UnitOfTemperature.FAHRENHEIT - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS @property def current_temperature(self) -> float | None: diff --git a/homeassistant/components/vicare/climate.py b/homeassistant/components/vicare/climate.py index 9d507ab9913..c8a4781fa0a 100644 --- a/homeassistant/components/vicare/climate.py +++ b/homeassistant/components/vicare/climate.py @@ -27,7 +27,7 @@ from homeassistant.const import ( ATTR_TEMPERATURE, PRECISION_TENTHS, PRECISION_WHOLE, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_platform @@ -147,7 +147,7 @@ class ViCareClimate(ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, name, api, circuit, device_config, heating_type): """Initialize the climate device.""" diff --git a/homeassistant/components/whirlpool/climate.py b/homeassistant/components/whirlpool/climate.py index 729746a0bcf..ad4cd2ea389 100644 --- a/homeassistant/components/whirlpool/climate.py +++ b/homeassistant/components/whirlpool/climate.py @@ -22,7 +22,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import generate_entity_id from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -102,7 +102,7 @@ class AirConEntity(ClimateEntity): ) _attr_swing_modes = SUPPORTED_SWING_MODES _attr_target_temperature_step = SUPPORTED_TARGET_TEMPERATURE_STEP - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_should_poll = False def __init__(self, hass, said, name, backend_selector: BackendSelector, auth: Auth): diff --git a/homeassistant/components/yolink/climate.py b/homeassistant/components/yolink/climate.py index d79c7d0fa15..a151e30062d 100644 --- a/homeassistant/components/yolink/climate.py +++ b/homeassistant/components/yolink/climate.py @@ -16,7 +16,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -67,7 +67,7 @@ class YoLinkClimateEntity(YoLinkEntity, ClimateEntity): super().__init__(config_entry, coordinator) self._attr_unique_id = f"{coordinator.device.device_id}_climate" self._attr_name = f"{coordinator.device.device_name} (Thermostat)" - self._attr_temperature_unit = TEMP_CELSIUS + self._attr_temperature_unit = UnitOfTemperature.CELSIUS self._attr_fan_modes = [FAN_ON, FAN_AUTO] self._attr_min_temp = -10 self._attr_max_temp = 50 diff --git a/homeassistant/components/zha/climate.py b/homeassistant/components/zha/climate.py index 4de07bf0d74..05b0528b330 100644 --- a/homeassistant/components/zha/climate.py +++ b/homeassistant/components/zha/climate.py @@ -33,8 +33,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_TEMPERATURE, PRECISION_TENTHS, - TEMP_CELSIUS, Platform, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -139,7 +139,7 @@ class Thermostat(ZhaEntity, ClimateEntity): DEFAULT_MIN_TEMP = 7 _attr_precision = PRECISION_TENTHS - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, unique_id, zha_device, channels, **kwargs): """Initialize ZHA Thermostat instance.""" diff --git a/homeassistant/components/zhong_hong/climate.py b/homeassistant/components/zhong_hong/climate.py index 265d4d15506..1364dbe107a 100644 --- a/homeassistant/components/zhong_hong/climate.py +++ b/homeassistant/components/zhong_hong/climate.py @@ -20,7 +20,7 @@ from homeassistant.const import ( CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -130,7 +130,7 @@ class ZhongHongClimate(ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, hub, addr_out, addr_in): """Set up the ZhongHong climate devices."""