From d60fe7e7cd4a9633db8f6ae3f775d5efb66be3b7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:39:09 +0100 Subject: [PATCH] Use UnitOfTemperature in integrations (n-o) (#84306) --- homeassistant/components/nam/sensor.py | 14 +++++++------- homeassistant/components/nest/climate_sdm.py | 4 ++-- homeassistant/components/nest/legacy/climate.py | 11 +++-------- homeassistant/components/nest/legacy/sensor.py | 7 +++---- homeassistant/components/nest/sensor_sdm.py | 4 ++-- homeassistant/components/nobo_hub/sensor.py | 4 ++-- homeassistant/components/notion/sensor.py | 4 ++-- homeassistant/components/number/__init__.py | 10 +++------- homeassistant/components/octoprint/sensor.py | 4 ++-- homeassistant/components/oncue/sensor.py | 7 +++---- homeassistant/components/onewire/sensor.py | 16 ++++++++-------- homeassistant/components/openevse/sensor.py | 8 ++++---- homeassistant/components/opengarage/sensor.py | 4 ++-- .../openweathermap/weather_update_coordinator.py | 7 +++++-- .../atlantic_electrical_heater.py | 4 ++-- ...eater_with_adjustable_temperature_setpoint.py | 4 ++-- .../atlantic_electrical_towel_dryer.py | 4 ++-- .../atlantic_heat_recovery_ventilation.py | 4 ++-- .../atlantic_pass_apc_heating_zone.py | 4 ++-- .../atlantic_pass_apc_zone_control.py | 4 ++-- .../overkiz/climate_entities/somfy_thermostat.py | 4 ++-- homeassistant/components/overkiz/number.py | 8 ++++---- .../atlantic_pass_apc_dhw.py | 4 ++-- .../domestic_hot_water_production.py | 4 ++-- .../overkiz/water_heater_entities/hitachi_dhw.py | 4 ++-- 25 files changed, 72 insertions(+), 80 deletions(-) diff --git a/homeassistant/components/nam/sensor.py b/homeassistant/components/nam/sensor.py index 1fc1017e1d9..13ed5675b3c 100644 --- a/homeassistant/components/nam/sensor.py +++ b/homeassistant/components/nam/sensor.py @@ -18,8 +18,8 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry @@ -88,7 +88,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=ATTR_BME280_TEMPERATURE, name="BME280 temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), @@ -102,7 +102,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=ATTR_BMP180_TEMPERATURE, name="BMP180 temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), @@ -116,7 +116,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=ATTR_BMP280_TEMPERATURE, name="BMP280 temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), @@ -130,7 +130,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=ATTR_HECA_TEMPERATURE, name="HECA temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), @@ -212,7 +212,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=ATTR_SHT3X_TEMPERATURE, name="SHT3X temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), @@ -267,7 +267,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key=ATTR_DHT22_TEMPERATURE, name="DHT22 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/nest/climate_sdm.py b/homeassistant/components/nest/climate_sdm.py index 4a453c5fd38..7f7d22ae604 100644 --- a/homeassistant/components/nest/climate_sdm.py +++ b/homeassistant/components/nest/climate_sdm.py @@ -29,7 +29,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.exceptions import HomeAssistantError from homeassistant.helpers.entity import DeviceInfo @@ -131,7 +131,7 @@ class ThermostatEntity(ClimateEntity): @property def temperature_unit(self) -> str: """Return the unit of temperature measurement for the system.""" - return TEMP_CELSIUS + return UnitOfTemperature.CELSIUS @property def current_temperature(self) -> float | None: diff --git a/homeassistant/components/nest/legacy/climate.py b/homeassistant/components/nest/legacy/climate.py index de6bd0e3b26..5f066e3bc0e 100644 --- a/homeassistant/components/nest/legacy/climate.py +++ b/homeassistant/components/nest/legacy/climate.py @@ -20,12 +20,7 @@ from homeassistant.components.climate import ( HVACAction, HVACMode, ) -from homeassistant.const import ( - ATTR_TEMPERATURE, - CONF_SCAN_INTERVAL, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, -) +from homeassistant.const import ATTR_TEMPERATURE, CONF_SCAN_INTERVAL, UnitOfTemperature from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import DeviceInfo @@ -341,6 +336,6 @@ class NestThermostat(ClimateEntity): self._max_temperature = self.device.max_temperature self._is_locked = self.device.is_locked if self.device.temperature_scale == "C": - self._temperature_scale = TEMP_CELSIUS + self._temperature_scale = UnitOfTemperature.CELSIUS else: - self._temperature_scale = TEMP_FAHRENHEIT + self._temperature_scale = UnitOfTemperature.FAHRENHEIT diff --git a/homeassistant/components/nest/legacy/sensor.py b/homeassistant/components/nest/legacy/sensor.py index bb09a40b15e..86e73114568 100644 --- a/homeassistant/components/nest/legacy/sensor.py +++ b/homeassistant/components/nest/legacy/sensor.py @@ -9,8 +9,7 @@ from homeassistant.const import ( CONF_SENSORS, PERCENTAGE, STATE_OFF, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from . import NestSensorDevice @@ -206,9 +205,9 @@ class NestTempSensor(NestSensorDevice, SensorEntity): def update(self): """Retrieve latest state.""" if self.device.temperature_scale == "C": - self._unit = TEMP_CELSIUS + self._unit = UnitOfTemperature.CELSIUS else: - self._unit = TEMP_FAHRENHEIT + self._unit = UnitOfTemperature.FAHRENHEIT if (temp := getattr(self.device, self.variable)) is None: self._state = None diff --git a/homeassistant/components/nest/sensor_sdm.py b/homeassistant/components/nest/sensor_sdm.py index b36e9103196..187ac0ee8c2 100644 --- a/homeassistant/components/nest/sensor_sdm.py +++ b/homeassistant/components/nest/sensor_sdm.py @@ -13,7 +13,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_platform import AddEntitiesCallback @@ -78,7 +78,7 @@ class TemperatureSensor(SensorBase): """Representation of a Temperature Sensor.""" _attr_device_class = SensorDeviceClass.TEMPERATURE - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS _attr_name = "Temperature" @property diff --git a/homeassistant/components/nobo_hub/sensor.py b/homeassistant/components/nobo_hub/sensor.py index fe33c6ee83e..3bb1fa373a5 100644 --- a/homeassistant/components/nobo_hub/sensor.py +++ b/homeassistant/components/nobo_hub/sensor.py @@ -16,7 +16,7 @@ from homeassistant.const import ( ATTR_NAME, ATTR_SUGGESTED_AREA, ATTR_VIA_DEVICE, - TEMP_CELSIUS, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo @@ -47,7 +47,7 @@ class NoboTemperatureSensor(SensorEntity): """A Nobø device with a temperature sensor.""" _attr_device_class = SensorDeviceClass.TEMPERATURE - _attr_native_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS _attr_state_class = SensorStateClass.MEASUREMENT _attr_should_poll = False diff --git a/homeassistant/components/notion/sensor.py b/homeassistant/components/notion/sensor.py index ff7ac7d23a6..7881780c4ed 100644 --- a/homeassistant/components/notion/sensor.py +++ b/homeassistant/components/notion/sensor.py @@ -6,7 +6,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) 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 @@ -18,7 +18,7 @@ SENSOR_DESCRIPTIONS = ( key=SENSOR_TEMPERATURE, name="Temperature", 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/number/__init__.py b/homeassistant/components/number/__init__.py index 2fb9442b08c..fb90d373113 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -14,12 +14,7 @@ import voluptuous as vol from homeassistant.backports.enum import StrEnum from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_MODE, - CONF_UNIT_OF_MEASUREMENT, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, -) +from homeassistant.const import ATTR_MODE, CONF_UNIT_OF_MEASUREMENT, UnitOfTemperature from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers.config_validation import ( # noqa: F401 PLATFORM_SCHEMA, @@ -674,7 +669,8 @@ class NumberEntity(Entity): if ( self.device_class == NumberDeviceClass.TEMPERATURE - and native_unit_of_measurement in (TEMP_CELSIUS, TEMP_FAHRENHEIT) + and native_unit_of_measurement + in (UnitOfTemperature.CELSIUS, UnitOfTemperature.FAHRENHEIT) ): return self.hass.config.units.temperature_unit diff --git a/homeassistant/components/octoprint/sensor.py b/homeassistant/components/octoprint/sensor.py index fd140d5c00e..17bea7b8ac5 100644 --- a/homeassistant/components/octoprint/sensor.py +++ b/homeassistant/components/octoprint/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, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -224,7 +224,7 @@ class OctoPrintStartTimeSensor(OctoPrintSensorBase): class OctoPrintTemperatureSensor(OctoPrintSensorBase): """Representation of an OctoPrint 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 diff --git a/homeassistant/components/oncue/sensor.py b/homeassistant/components/oncue/sensor.py index 8bc6ae8bc7f..0a7f8910775 100644 --- a/homeassistant/components/oncue/sensor.py +++ b/homeassistant/components/oncue/sensor.py @@ -12,14 +12,13 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfFrequency, UnitOfPower, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory @@ -173,8 +172,8 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SENSOR_MAP = {description.key: description for description in SENSOR_TYPES} UNIT_MAPPINGS = { - "C": TEMP_CELSIUS, - "F": TEMP_FAHRENHEIT, + "C": UnitOfTemperature.CELSIUS, + "F": UnitOfTemperature.FAHRENHEIT, } diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index 0dab56c2ba4..89a01496b1f 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -19,9 +19,9 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( LIGHT_LUX, PERCENTAGE, - TEMP_CELSIUS, UnitOfElectricPotential, UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -69,7 +69,7 @@ SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION = OneWireSensorEntityDescription( key="temperature", device_class=SensorDeviceClass.TEMPERATURE, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ) @@ -85,7 +85,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.TEMPERATURE, entity_registry_enabled_default=False, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -198,7 +198,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { key="temperature", device_class=SensorDeviceClass.TEMPERATURE, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, override_key=_get_sensor_precision_family_28, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, @@ -211,7 +211,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { device_class=SensorDeviceClass.TEMPERATURE, entity_registry_enabled_default=False, name="Thermocouple temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, read_mode=READ_MODE_FLOAT, override_key=lambda d, o: "typeK/temperature", state_class=SensorStateClass.MEASUREMENT, @@ -273,7 +273,7 @@ HOBBYBOARD_EF: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { key="humidity/temperature", device_class=SensorDeviceClass.TEMPERATURE, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -299,7 +299,7 @@ EDS_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { key="EDS0066/temperature", device_class=SensorDeviceClass.TEMPERATURE, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), @@ -317,7 +317,7 @@ EDS_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = { key="EDS0068/temperature", device_class=SensorDeviceClass.TEMPERATURE, name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, read_mode=READ_MODE_FLOAT, state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/openevse/sensor.py b/homeassistant/components/openevse/sensor.py index 409425982b4..d7a47b97594 100644 --- a/homeassistant/components/openevse/sensor.py +++ b/homeassistant/components/openevse/sensor.py @@ -17,8 +17,8 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( CONF_HOST, CONF_MONITORED_VARIABLES, - TEMP_CELSIUS, UnitOfEnergy, + UnitOfTemperature, UnitOfTime, ) from homeassistant.core import HomeAssistant @@ -43,21 +43,21 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="ambient_temp", name="Ambient Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="ir_temp", name="IR Temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="rtc_temp", name="RTC 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/opengarage/sensor.py b/homeassistant/components/opengarage/sensor.py index f3eb7b2a522..386955dfd47 100644 --- a/homeassistant/components/opengarage/sensor.py +++ b/homeassistant/components/opengarage/sensor.py @@ -13,8 +13,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - TEMP_CELSIUS, UnitOfLength, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import EntityCategory @@ -43,7 +43,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="temp", 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/openweathermap/weather_update_coordinator.py b/homeassistant/components/openweathermap/weather_update_coordinator.py index 630250b4701..cedc33c1a8e 100644 --- a/homeassistant/components/openweathermap/weather_update_coordinator.py +++ b/homeassistant/components/openweathermap/weather_update_coordinator.py @@ -9,7 +9,7 @@ from homeassistant.components.weather import ( ATTR_CONDITION_CLEAR_NIGHT, ATTR_CONDITION_SUNNY, ) -from homeassistant.const import TEMP_CELSIUS, TEMP_KELVIN +from homeassistant.const import UnitOfTemperature from homeassistant.helpers import sun from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.util import dt @@ -193,7 +193,10 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator): """Format the dewpoint data.""" if dewpoint is not None: return round( - TemperatureConverter.convert(dewpoint, TEMP_KELVIN, TEMP_CELSIUS), 1 + TemperatureConverter.convert( + dewpoint, UnitOfTemperature.KELVIN, UnitOfTemperature.CELSIUS + ), + 1, ) return None diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater.py b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater.py index 36d657d5846..bb095436054 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater.py @@ -13,7 +13,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import UnitOfTemperature from ..entity import OverkizEntity @@ -46,7 +46,7 @@ class AtlanticElectricalHeater(OverkizEntity, ClimateEntity): _attr_hvac_modes = [*HVAC_MODES_TO_OVERKIZ] _attr_preset_modes = [*PRESET_MODES_TO_OVERKIZ] _attr_supported_features = ClimateEntityFeature.PRESET_MODE - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS @property def hvac_mode(self) -> HVACMode: diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py index 80c2f418331..a3a2be171c7 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_heater_with_adjustable_temperature_setpoint.py @@ -14,7 +14,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from ..coordinator import OverkizDataUpdateCoordinator from ..entity import OverkizEntity @@ -63,7 +63,7 @@ class AtlanticElectricalHeaterWithAdjustableTemperatureSetpoint( _attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ] _attr_preset_modes = [*PRESET_MODE_TO_OVERKIZ] - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ) diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_towel_dryer.py b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_towel_dryer.py index 374d7e1164d..c9885ada421 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_electrical_towel_dryer.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_electrical_towel_dryer.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 ..coordinator import OverkizDataUpdateCoordinator from ..entity import OverkizEntity @@ -42,7 +42,7 @@ class AtlanticElectricalTowelDryer(OverkizEntity, ClimateEntity): _attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ] _attr_preset_modes = [*PRESET_MODE_TO_OVERKIZ] - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__( self, device_url: str, coordinator: OverkizDataUpdateCoordinator diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_heat_recovery_ventilation.py b/homeassistant/components/overkiz/climate_entities/atlantic_heat_recovery_ventilation.py index 3627aa21c43..7c469518f86 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_heat_recovery_ventilation.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_heat_recovery_ventilation.py @@ -11,7 +11,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import UnitOfTemperature from ..coordinator import OverkizDataUpdateCoordinator from ..entity import OverkizEntity @@ -45,7 +45,7 @@ class AtlanticHeatRecoveryVentilation(OverkizEntity, ClimateEntity): _attr_hvac_mode = HVACMode.FAN_ONLY _attr_hvac_modes = [HVACMode.FAN_ONLY] _attr_preset_modes = [PRESET_AUTO, PRESET_PROG, PRESET_MANUAL] - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.FAN_MODE ) diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_heating_zone.py b/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_heating_zone.py index 3d1f9038356..dae8229ec9c 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_heating_zone.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_heating_zone.py @@ -15,7 +15,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from ..coordinator import OverkizDataUpdateCoordinator from ..entity import OverkizEntity @@ -69,7 +69,7 @@ class AtlanticPassAPCHeatingZone(OverkizEntity, ClimateEntity): _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ) - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__( self, device_url: str, coordinator: OverkizDataUpdateCoordinator diff --git a/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_zone_control.py b/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_zone_control.py index ba95785fbc7..33c1f0c4a2a 100644 --- a/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_zone_control.py +++ b/homeassistant/components/overkiz/climate_entities/atlantic_pass_apc_zone_control.py @@ -4,7 +4,7 @@ from typing import cast from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState from homeassistant.components.climate import ClimateEntity, HVACMode -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import UnitOfTemperature from ..entity import OverkizEntity @@ -22,7 +22,7 @@ class AtlanticPassAPCZoneControl(OverkizEntity, ClimateEntity): """Representation of Atlantic Pass APC Zone Control.""" _attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ] - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS @property def hvac_mode(self) -> str: diff --git a/homeassistant/components/overkiz/climate_entities/somfy_thermostat.py b/homeassistant/components/overkiz/climate_entities/somfy_thermostat.py index 608b26b8c9d..c3fd7cd964d 100644 --- a/homeassistant/components/overkiz/climate_entities/somfy_thermostat.py +++ b/homeassistant/components/overkiz/climate_entities/somfy_thermostat.py @@ -13,7 +13,7 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from ..coordinator import OverkizDataUpdateCoordinator from ..entity import OverkizEntity @@ -54,7 +54,7 @@ TEMPERATURE_SENSOR_DEVICE_INDEX = 2 class SomfyThermostat(OverkizEntity, ClimateEntity): """Representation of Somfy Smart Thermostat.""" - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ) diff --git a/homeassistant/components/overkiz/number.py b/homeassistant/components/overkiz/number.py index 3b4107256a5..5937367b951 100644 --- a/homeassistant/components/overkiz/number.py +++ b/homeassistant/components/overkiz/number.py @@ -14,7 +14,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 @@ -106,7 +106,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [ device_class=NumberDeviceClass.TEMPERATURE, native_min_value=6, native_max_value=29, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, entity_category=EntityCategory.CONFIG, ), OverkizNumberDescription( @@ -117,7 +117,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [ device_class=NumberDeviceClass.TEMPERATURE, native_min_value=7, native_max_value=30, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, entity_category=EntityCategory.CONFIG, ), OverkizNumberDescription( @@ -128,7 +128,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [ device_class=NumberDeviceClass.TEMPERATURE, native_min_value=5, native_max_value=15, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, entity_category=EntityCategory.CONFIG, ), # DimmerExteriorHeating (Somfy Terrace Heater) (0 - 100) diff --git a/homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py b/homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py index 7c2ea6ff2d8..d977dd67e4e 100644 --- a/homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py +++ b/homeassistant/components/overkiz/water_heater_entities/atlantic_pass_apc_dhw.py @@ -12,7 +12,7 @@ from homeassistant.components.water_heater import ( WaterHeaterEntity, WaterHeaterEntityFeature, ) -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from ..entity import OverkizEntity @@ -20,7 +20,7 @@ from ..entity import OverkizEntity class AtlanticPassAPCDHW(OverkizEntity, WaterHeaterEntity): """Representation of Atlantic Pass APC DHW.""" - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.OPERATION_MODE diff --git a/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py b/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py index cdc1ae11bdd..001247b346d 100644 --- a/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py +++ b/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py @@ -12,7 +12,7 @@ from homeassistant.components.water_heater import ( WaterHeaterEntity, WaterHeaterEntityFeature, ) -from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, STATE_ON, TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, STATE_ON, UnitOfTemperature from ..coordinator import OverkizDataUpdateCoordinator from ..entity import OverkizEntity @@ -44,7 +44,7 @@ DEFAULT_MAX_TEMP: float = 70 class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity): """Representation of a DomesticHotWaterProduction Water Heater.""" - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.OPERATION_MODE diff --git a/homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py b/homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py index cd87dded72b..0dd5b70feb6 100644 --- a/homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py +++ b/homeassistant/components/overkiz/water_heater_entities/hitachi_dhw.py @@ -15,7 +15,7 @@ from homeassistant.const import ( PRECISION_WHOLE, STATE_OFF, STATE_ON, - TEMP_CELSIUS, + UnitOfTemperature, ) from ..entity import OverkizEntity @@ -36,7 +36,7 @@ class HitachiDHW(OverkizEntity, WaterHeaterEntity): _attr_max_temp = 70.0 _attr_precision = PRECISION_WHOLE - _attr_temperature_unit = TEMP_CELSIUS + _attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_supported_features = ( WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.OPERATION_MODE