diff --git a/homeassistant/components/gree/climate.py b/homeassistant/components/gree/climate.py index 976cc31761d..6afbca7789b 100644 --- a/homeassistant/components/gree/climate.py +++ b/homeassistant/components/gree/climate.py @@ -35,12 +35,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_TEMPERATURE, - PRECISION_WHOLE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, -) +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -151,7 +146,9 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity): def temperature_unit(self) -> str: """Return the temperature units for the device.""" units = self.coordinator.device.temperature_units - return TEMP_CELSIUS if units == TemperatureUnits.C else TEMP_FAHRENHEIT + if units == TemperatureUnits.C: + return UnitOfTemperature.CELSIUS + return UnitOfTemperature.FAHRENHEIT @property def current_temperature(self) -> float: @@ -182,12 +179,16 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity): @property def min_temp(self) -> float: """Return the minimum temperature supported by the device.""" - return TEMP_MIN if self.temperature_unit == TEMP_CELSIUS else TEMP_MIN_F + if self.temperature_unit == UnitOfTemperature.CELSIUS: + return TEMP_MIN + return TEMP_MIN_F @property def max_temp(self) -> float: """Return the maximum temperature supported by the device.""" - return TEMP_MAX if self.temperature_unit == TEMP_CELSIUS else TEMP_MAX_F + if self.temperature_unit == UnitOfTemperature.CELSIUS: + return TEMP_MAX + return TEMP_MAX_F @property def target_temperature_step(self) -> float: diff --git a/homeassistant/components/heatmiser/climate.py b/homeassistant/components/heatmiser/climate.py index 7f6bd0ccf9c..24a0c88b45a 100644 --- a/homeassistant/components/heatmiser/climate.py +++ b/homeassistant/components/heatmiser/climate.py @@ -19,8 +19,7 @@ from homeassistant.const import ( CONF_ID, CONF_NAME, CONF_PORT, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -120,9 +119,9 @@ class HeatmiserV3Thermostat(ClimateEntity): return self.dcb = self.therm.read_dcb() self._attr_temperature_unit = ( - TEMP_CELSIUS + UnitOfTemperature.CELSIUS if (self.therm.get_temperature_format() == "C") - else TEMP_FAHRENHEIT + else UnitOfTemperature.FAHRENHEIT ) self._current_temperature = int(self.therm.get_floor_temp()) self._target_temperature = int(self.therm.get_target_temp()) diff --git a/homeassistant/components/hisense_aehw4a1/climate.py b/homeassistant/components/hisense_aehw4a1/climate.py index fc956ec8760..113a0c622b9 100644 --- a/homeassistant/components/hisense_aehw4a1/climate.py +++ b/homeassistant/components/hisense_aehw4a1/climate.py @@ -25,12 +25,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_TEMPERATURE, - PRECISION_WHOLE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, -) +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_WHOLE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -184,9 +179,9 @@ class ClimateAehW4a1(ClimateEntity): self._on = status["run_status"] if status["temperature_Fahrenheit"] == "0": - self._attr_temperature_unit = TEMP_CELSIUS + self._attr_temperature_unit = UnitOfTemperature.CELSIUS else: - self._attr_temperature_unit = TEMP_FAHRENHEIT + self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT self._current_temperature = int(status["indoor_temperature_status"], 2) @@ -274,14 +269,14 @@ class ClimateAehW4a1(ClimateEntity): @property def min_temp(self): """Return the minimum temperature.""" - if self.temperature_unit == TEMP_CELSIUS: + if self.temperature_unit == UnitOfTemperature.CELSIUS: return MIN_TEMP_C return MIN_TEMP_F @property def max_temp(self): """Return the maximum temperature.""" - if self.temperature_unit == TEMP_CELSIUS: + if self.temperature_unit == UnitOfTemperature.CELSIUS: return MAX_TEMP_C return MAX_TEMP_F @@ -301,7 +296,7 @@ class ClimateAehW4a1(ClimateEntity): _LOGGER.debug("Setting temp of %s to %s", self._unique_id, temp) if self._preset_mode != PRESET_NONE: await self.async_set_preset_mode(PRESET_NONE) - if self.temperature_unit == TEMP_CELSIUS: + if self.temperature_unit == UnitOfTemperature.CELSIUS: await self._device.command(f"temp_{int(temp)}_C") else: await self._device.command(f"temp_{int(temp)}_F") diff --git a/homeassistant/components/hive/climate.py b/homeassistant/components/hive/climate.py index 620d679fe1c..4dc8d921cd3 100644 --- a/homeassistant/components/hive/climate.py +++ b/homeassistant/components/hive/climate.py @@ -14,7 +14,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -45,7 +45,7 @@ HIVE_TO_HASS_HVAC_ACTION = { True: HVACAction.HEATING, } -TEMP_UNIT = {"C": TEMP_CELSIUS, "F": TEMP_FAHRENHEIT} +TEMP_UNIT = {"C": UnitOfTemperature.CELSIUS, "F": UnitOfTemperature.FAHRENHEIT} PARALLEL_UPDATES = 0 SCAN_INTERVAL = timedelta(seconds=15) _LOGGER = logging.getLogger() diff --git a/homeassistant/components/homekit_controller/climate.py b/homeassistant/components/homekit_controller/climate.py index 2dc998200a4..524847d46fe 100644 --- a/homeassistant/components/homekit_controller/climate.py +++ b/homeassistant/components/homekit_controller/climate.py @@ -32,7 +32,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, Platform +from homeassistant.const import ATTR_TEMPERATURE, Platform, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -114,7 +114,7 @@ async def async_setup_entry( class HomeKitBaseClimateEntity(HomeKitEntity, ClimateEntity): """The base HomeKit Controller climate entity.""" - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def get_characteristic_types(self) -> list[str]: """Define the homekit characteristics the entity cares about.""" diff --git a/homeassistant/components/homematic/climate.py b/homeassistant/components/homematic/climate.py index d597eca30cd..998113f1bcf 100644 --- a/homeassistant/components/homematic/climate.py +++ b/homeassistant/components/homematic/climate.py @@ -12,7 +12,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -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 from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -58,7 +58,7 @@ class HMThermostat(HMDevice, ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS @property def hvac_mode(self) -> HVACMode: diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index b6ac23b5c71..737ffaf8c19 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -24,7 +24,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 DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -69,7 +69,7 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, hap: HomematicipHAP, device: AsyncHeatingGroup) -> None: """Initialize heating group.""" diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 64f87fd19ae..3bc5e0e7ef8 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/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, TEMP_FAHRENHEIT +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -103,9 +103,9 @@ class HoneywellUSThermostat(ClimateEntity): self._attr_unique_id = device.deviceid self._attr_name = device.name - self._attr_temperature_unit = ( - TEMP_CELSIUS if device.temperature_unit == "C" else TEMP_FAHRENHEIT - ) + self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT + if device.temperature_unit == "C": + self._attr_temperature_unit = UnitOfTemperature.CELSIUS self._attr_preset_modes = [PRESET_NONE, PRESET_AWAY, PRESET_HOLD] self._attr_is_aux_heat = device.system_mode == "emheat" diff --git a/homeassistant/components/iaqualink/climate.py b/homeassistant/components/iaqualink/climate.py index 408bd56778e..7c67dbdea4b 100644 --- a/homeassistant/components/iaqualink/climate.py +++ b/homeassistant/components/iaqualink/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, TEMP_FAHRENHEIT +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -68,8 +68,8 @@ class HassAqualinkThermostat(AqualinkEntity, ClimateEntity): def temperature_unit(self) -> str: """Return the unit of measurement.""" if self.dev.unit == "F": - return TEMP_FAHRENHEIT - return TEMP_CELSIUS + return UnitOfTemperature.FAHRENHEIT + return UnitOfTemperature.CELSIUS @property def min_temp(self) -> int: diff --git a/homeassistant/components/incomfort/climate.py b/homeassistant/components/incomfort/climate.py index 1d3c18fa608..cae73495438 100644 --- a/homeassistant/components/incomfort/climate.py +++ b/homeassistant/components/incomfort/climate.py @@ -9,7 +9,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -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 from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -41,7 +41,7 @@ class InComfortClimate(IncomfortChild, ClimateEntity): _attr_hvac_mode = HVACMode.HEAT _attr_hvac_modes = [HVACMode.HEAT] _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, client, heater, room) -> None: """Initialize the climate device.""" diff --git a/homeassistant/components/insteon/climate.py b/homeassistant/components/insteon/climate.py index 0211b316b96..f88dadf1223 100644 --- a/homeassistant/components/insteon/climate.py +++ b/homeassistant/components/insteon/climate.py @@ -17,7 +17,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -89,8 +89,8 @@ class InsteonClimateEntity(InsteonEntity, ClimateEntity): def temperature_unit(self) -> str: """Return the unit of measurement.""" if self._insteon_device.configuration[CELSIUS].value: - return TEMP_CELSIUS - return TEMP_FAHRENHEIT + return UnitOfTemperature.CELSIUS + return UnitOfTemperature.FAHRENHEIT @property def current_humidity(self) -> int | None: diff --git a/homeassistant/components/intellifire/climate.py b/homeassistant/components/intellifire/climate.py index cf36e6b48a0..649234d7568 100644 --- a/homeassistant/components/intellifire/climate.py +++ b/homeassistant/components/intellifire/climate.py @@ -10,7 +10,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 @@ -51,7 +51,7 @@ class IntellifireClimate(IntellifireEntity, ClimateEntity): _attr_max_temp = 37 _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE _attr_target_temperature_step = 1.0 - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS last_temp = DEFAULT_THERMOSTAT_TEMP def __init__( diff --git a/homeassistant/components/intesishome/climate.py b/homeassistant/components/intesishome/climate.py index bfdf406ee1a..16cf62627f1 100644 --- a/homeassistant/components/intesishome/climate.py +++ b/homeassistant/components/intesishome/climate.py @@ -27,7 +27,7 @@ from homeassistant.const import ( CONF_DEVICE, CONF_PASSWORD, CONF_USERNAME, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import PlatformNotReady @@ -145,7 +145,7 @@ class IntesisAC(ClimateEntity): """Represents an Intesishome air conditioning device.""" _attr_should_poll = False - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, ih_device_id, ih_device, controller): """Initialize the thermostat.""" diff --git a/homeassistant/components/isy994/climate.py b/homeassistant/components/isy994/climate.py index c141f856408..5267dbff48d 100644 --- a/homeassistant/components/isy994/climate.py +++ b/homeassistant/components/isy994/climate.py @@ -29,12 +29,7 @@ from homeassistant.components.climate import ( HVACMode, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_TEMPERATURE, - PRECISION_TENTHS, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, -) +from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -103,10 +98,10 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity): if not (uom := self._node.aux_properties.get(PROP_UOM)): return self.hass.config.units.temperature_unit if uom.value == UOM_ISY_CELSIUS: - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS if uom.value == UOM_ISY_FAHRENHEIT: - return TEMP_FAHRENHEIT - return TEMP_FAHRENHEIT + return UnitOfTemperature.FAHRENHEIT + return UnitOfTemperature.FAHRENHEIT @property def current_humidity(self) -> int | None: diff --git a/homeassistant/components/izone/climate.py b/homeassistant/components/izone/climate.py index c94ccada5b3..59b57f888a7 100644 --- a/homeassistant/components/izone/climate.py +++ b/homeassistant/components/izone/climate.py @@ -25,7 +25,7 @@ from homeassistant.const import ( CONF_EXCLUDE, PRECISION_HALVES, PRECISION_TENTHS, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity_platform @@ -129,7 +129,7 @@ class ControllerDevice(ClimateEntity): _attr_precision = PRECISION_TENTHS _attr_should_poll = False - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, controller: Controller) -> None: """Initialise ControllerDevice.""" @@ -437,7 +437,7 @@ class ZoneDevice(ClimateEntity): _attr_precision = PRECISION_TENTHS _attr_should_poll = False - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, controller: ControllerDevice, zone: Zone) -> None: """Initialise ZoneDevice.""" diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py index bb2fe7dfbcc..72039e1300f 100644 --- a/homeassistant/components/knx/climate.py +++ b/homeassistant/components/knx/climate.py @@ -19,8 +19,8 @@ from homeassistant.const import ( ATTR_TEMPERATURE, CONF_ENTITY_CATEGORY, CONF_NAME, - TEMP_CELSIUS, Platform, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -133,7 +133,7 @@ class KNXClimate(KnxEntity, ClimateEntity): """Representation of a KNX climate device.""" _device: XknxClimate - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, xknx: XKNX, config: ConfigType) -> None: """Initialize of a KNX climate device.""" diff --git a/homeassistant/components/lcn/climate.py b/homeassistant/components/lcn/climate.py index 8d701fbfa2f..4f40bcd25cd 100644 --- a/homeassistant/components/lcn/climate.py +++ b/homeassistant/components/lcn/climate.py @@ -19,8 +19,7 @@ from homeassistant.const import ( CONF_ENTITIES, CONF_SOURCE, CONF_UNIT_OF_MEASUREMENT, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -114,10 +113,10 @@ class LcnClimate(LcnEntity, ClimateEntity): @property def temperature_unit(self) -> str: """Return the unit of measurement.""" - # Config schema only allows for: TEMP_CELSIUS and TEMP_FAHRENHEIT + # Config schema only allows for: UnitOfTemperature.CELSIUS and UnitOfTemperature.FAHRENHEIT if self.unit == pypck.lcn_defs.VarUnit.FAHRENHEIT: - return TEMP_FAHRENHEIT - return TEMP_CELSIUS + return UnitOfTemperature.FAHRENHEIT + return UnitOfTemperature.CELSIUS @property def current_temperature(self) -> float | None: diff --git a/homeassistant/components/lightwave/climate.py b/homeassistant/components/lightwave/climate.py index 834fc7eaeca..60108aba024 100644 --- a/homeassistant/components/lightwave/climate.py +++ b/homeassistant/components/lightwave/climate.py @@ -11,7 +11,7 @@ from homeassistant.components.climate import ( HVACAction, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, CONF_NAME, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, CONF_NAME, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -49,7 +49,7 @@ class LightwaveTrv(ClimateEntity): _attr_max_temp = DEFAULT_MAX_TEMP _attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE _attr_target_temperature_step = 0.5 - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, name, device_id, lwlink, serial): """Initialize LightwaveTrv entity.""" diff --git a/homeassistant/components/lookin/climate.py b/homeassistant/components/lookin/climate.py index 46c6623e5b7..349f03de4c3 100644 --- a/homeassistant/components/lookin/climate.py +++ b/homeassistant/components/lookin/climate.py @@ -23,8 +23,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( ATTR_TEMPERATURE, PRECISION_WHOLE, - TEMP_CELSIUS, Platform, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -92,7 +92,7 @@ class ConditionerEntity(LookinCoordinatorEntity, ClimateEntity): """An aircon or heat pump.""" _attr_current_humidity: float | None = None # type: ignore[assignment] - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE