Use UnitOfTemperature in integrations (n-o) (#84306)

This commit is contained in:
epenet 2022-12-20 18:39:09 +01:00 committed by GitHub
parent a6ddac9004
commit d60fe7e7cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 72 additions and 80 deletions

View file

@ -18,8 +18,8 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfPressure, UnitOfPressure,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry
@ -88,7 +88,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=ATTR_BME280_TEMPERATURE, key=ATTR_BME280_TEMPERATURE,
name="BME280 temperature", name="BME280 temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -102,7 +102,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=ATTR_BMP180_TEMPERATURE, key=ATTR_BMP180_TEMPERATURE,
name="BMP180 temperature", name="BMP180 temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -116,7 +116,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=ATTR_BMP280_TEMPERATURE, key=ATTR_BMP280_TEMPERATURE,
name="BMP280 temperature", name="BMP280 temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -130,7 +130,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=ATTR_HECA_TEMPERATURE, key=ATTR_HECA_TEMPERATURE,
name="HECA temperature", name="HECA temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -212,7 +212,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=ATTR_SHT3X_TEMPERATURE, key=ATTR_SHT3X_TEMPERATURE,
name="SHT3X temperature", name="SHT3X temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -267,7 +267,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=ATTR_DHT22_TEMPERATURE, key=ATTR_DHT22_TEMPERATURE,
name="DHT22 temperature", name="DHT22 temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View file

@ -29,7 +29,7 @@ from homeassistant.components.climate import (
HVACMode, HVACMode,
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -131,7 +131,7 @@ class ThermostatEntity(ClimateEntity):
@property @property
def temperature_unit(self) -> str: def temperature_unit(self) -> str:
"""Return the unit of temperature measurement for the system.""" """Return the unit of temperature measurement for the system."""
return TEMP_CELSIUS return UnitOfTemperature.CELSIUS
@property @property
def current_temperature(self) -> float | None: def current_temperature(self) -> float | None:

View file

@ -20,12 +20,7 @@ from homeassistant.components.climate import (
HVACAction, HVACAction,
HVACMode, HVACMode,
) )
from homeassistant.const import ( from homeassistant.const import ATTR_TEMPERATURE, CONF_SCAN_INTERVAL, UnitOfTemperature
ATTR_TEMPERATURE,
CONF_SCAN_INTERVAL,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
)
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -341,6 +336,6 @@ class NestThermostat(ClimateEntity):
self._max_temperature = self.device.max_temperature self._max_temperature = self.device.max_temperature
self._is_locked = self.device.is_locked self._is_locked = self.device.is_locked
if self.device.temperature_scale == "C": if self.device.temperature_scale == "C":
self._temperature_scale = TEMP_CELSIUS self._temperature_scale = UnitOfTemperature.CELSIUS
else: else:
self._temperature_scale = TEMP_FAHRENHEIT self._temperature_scale = UnitOfTemperature.FAHRENHEIT

View file

@ -9,8 +9,7 @@ from homeassistant.const import (
CONF_SENSORS, CONF_SENSORS,
PERCENTAGE, PERCENTAGE,
STATE_OFF, STATE_OFF,
TEMP_CELSIUS, UnitOfTemperature,
TEMP_FAHRENHEIT,
) )
from . import NestSensorDevice from . import NestSensorDevice
@ -206,9 +205,9 @@ class NestTempSensor(NestSensorDevice, SensorEntity):
def update(self): def update(self):
"""Retrieve latest state.""" """Retrieve latest state."""
if self.device.temperature_scale == "C": if self.device.temperature_scale == "C":
self._unit = TEMP_CELSIUS self._unit = UnitOfTemperature.CELSIUS
else: else:
self._unit = TEMP_FAHRENHEIT self._unit = UnitOfTemperature.FAHRENHEIT
if (temp := getattr(self.device, self.variable)) is None: if (temp := getattr(self.device, self.variable)) is None:
self._state = None self._state = None

View file

@ -13,7 +13,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -78,7 +78,7 @@ class TemperatureSensor(SensorBase):
"""Representation of a Temperature Sensor.""" """Representation of a Temperature Sensor."""
_attr_device_class = SensorDeviceClass.TEMPERATURE _attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_native_unit_of_measurement = TEMP_CELSIUS _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
_attr_name = "Temperature" _attr_name = "Temperature"
@property @property

View file

@ -16,7 +16,7 @@ from homeassistant.const import (
ATTR_NAME, ATTR_NAME,
ATTR_SUGGESTED_AREA, ATTR_SUGGESTED_AREA,
ATTR_VIA_DEVICE, ATTR_VIA_DEVICE,
TEMP_CELSIUS, UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -47,7 +47,7 @@ class NoboTemperatureSensor(SensorEntity):
"""A Nobø device with a temperature sensor.""" """A Nobø device with a temperature sensor."""
_attr_device_class = SensorDeviceClass.TEMPERATURE _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_state_class = SensorStateClass.MEASUREMENT
_attr_should_poll = False _attr_should_poll = False

View file

@ -6,7 +6,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -18,7 +18,7 @@ SENSOR_DESCRIPTIONS = (
key=SENSOR_TEMPERATURE, key=SENSOR_TEMPERATURE,
name="Temperature", name="Temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
) )

View file

@ -14,12 +14,7 @@ import voluptuous as vol
from homeassistant.backports.enum import StrEnum from homeassistant.backports.enum import StrEnum
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import ATTR_MODE, CONF_UNIT_OF_MEASUREMENT, UnitOfTemperature
ATTR_MODE,
CONF_UNIT_OF_MEASUREMENT,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
)
from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers.config_validation import ( # noqa: F401 from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
@ -674,7 +669,8 @@ class NumberEntity(Entity):
if ( if (
self.device_class == NumberDeviceClass.TEMPERATURE 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 return self.hass.config.units.temperature_unit

View file

@ -12,7 +12,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -224,7 +224,7 @@ class OctoPrintStartTimeSensor(OctoPrintSensorBase):
class OctoPrintTemperatureSensor(OctoPrintSensorBase): class OctoPrintTemperatureSensor(OctoPrintSensorBase):
"""Representation of an OctoPrint sensor.""" """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_device_class = SensorDeviceClass.TEMPERATURE
_attr_state_class = SensorStateClass.MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT

View file

@ -12,14 +12,13 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
UnitOfPressure, UnitOfPressure,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -173,8 +172,8 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SENSOR_MAP = {description.key: description for description in SENSOR_TYPES} SENSOR_MAP = {description.key: description for description in SENSOR_TYPES}
UNIT_MAPPINGS = { UNIT_MAPPINGS = {
"C": TEMP_CELSIUS, "C": UnitOfTemperature.CELSIUS,
"F": TEMP_FAHRENHEIT, "F": UnitOfTemperature.FAHRENHEIT,
} }

View file

@ -19,9 +19,9 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfPressure, UnitOfPressure,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -69,7 +69,7 @@ SIMPLE_TEMPERATURE_SENSOR_DESCRIPTION = OneWireSensorEntityDescription(
key="temperature", key="temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
) )
@ -85,7 +85,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -198,7 +198,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key="temperature", key="temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
override_key=_get_sensor_precision_family_28, override_key=_get_sensor_precision_family_28,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -211,7 +211,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="Thermocouple temperature", name="Thermocouple temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
override_key=lambda d, o: "typeK/temperature", override_key=lambda d, o: "typeK/temperature",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -273,7 +273,7 @@ HOBBYBOARD_EF: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key="humidity/temperature", key="humidity/temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -299,7 +299,7 @@ EDS_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key="EDS0066/temperature", key="EDS0066/temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -317,7 +317,7 @@ EDS_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
key="EDS0068/temperature", key="EDS0068/temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View file

@ -17,8 +17,8 @@ from homeassistant.components.sensor import (
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_MONITORED_VARIABLES, CONF_MONITORED_VARIABLES,
TEMP_CELSIUS,
UnitOfEnergy, UnitOfEnergy,
UnitOfTemperature,
UnitOfTime, UnitOfTime,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -43,21 +43,21 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="ambient_temp", key="ambient_temp",
name="Ambient Temperature", name="Ambient Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="ir_temp", key="ir_temp",
name="IR Temperature", name="IR Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="rtc_temp", key="rtc_temp",
name="RTC Temperature", name="RTC Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View file

@ -13,8 +13,8 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS,
UnitOfLength, UnitOfLength,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -43,7 +43,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="temp", key="temp",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(

View file

@ -9,7 +9,7 @@ from homeassistant.components.weather import (
ATTR_CONDITION_CLEAR_NIGHT, ATTR_CONDITION_CLEAR_NIGHT,
ATTR_CONDITION_SUNNY, ATTR_CONDITION_SUNNY,
) )
from homeassistant.const import TEMP_CELSIUS, TEMP_KELVIN from homeassistant.const import UnitOfTemperature
from homeassistant.helpers import sun from homeassistant.helpers import sun
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util import dt from homeassistant.util import dt
@ -193,7 +193,10 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
"""Format the dewpoint data.""" """Format the dewpoint data."""
if dewpoint is not None: if dewpoint is not None:
return round( return round(
TemperatureConverter.convert(dewpoint, TEMP_KELVIN, TEMP_CELSIUS), 1 TemperatureConverter.convert(
dewpoint, UnitOfTemperature.KELVIN, UnitOfTemperature.CELSIUS
),
1,
) )
return None return None

View file

@ -13,7 +13,7 @@ from homeassistant.components.climate import (
ClimateEntityFeature, ClimateEntityFeature,
HVACMode, HVACMode,
) )
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import UnitOfTemperature
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -46,7 +46,7 @@ class AtlanticElectricalHeater(OverkizEntity, ClimateEntity):
_attr_hvac_modes = [*HVAC_MODES_TO_OVERKIZ] _attr_hvac_modes = [*HVAC_MODES_TO_OVERKIZ]
_attr_preset_modes = [*PRESET_MODES_TO_OVERKIZ] _attr_preset_modes = [*PRESET_MODES_TO_OVERKIZ]
_attr_supported_features = ClimateEntityFeature.PRESET_MODE _attr_supported_features = ClimateEntityFeature.PRESET_MODE
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
@property @property
def hvac_mode(self) -> HVACMode: def hvac_mode(self) -> HVACMode:

View file

@ -14,7 +14,7 @@ from homeassistant.components.climate import (
ClimateEntityFeature, ClimateEntityFeature,
HVACMode, HVACMode,
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from ..coordinator import OverkizDataUpdateCoordinator from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -63,7 +63,7 @@ class AtlanticElectricalHeaterWithAdjustableTemperatureSetpoint(
_attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ] _attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ]
_attr_preset_modes = [*PRESET_MODE_TO_OVERKIZ] _attr_preset_modes = [*PRESET_MODE_TO_OVERKIZ]
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = ( _attr_supported_features = (
ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
) )

View file

@ -12,7 +12,7 @@ from homeassistant.components.climate import (
ClimateEntityFeature, ClimateEntityFeature,
HVACMode, HVACMode,
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from ..coordinator import OverkizDataUpdateCoordinator from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -42,7 +42,7 @@ class AtlanticElectricalTowelDryer(OverkizEntity, ClimateEntity):
_attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ] _attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ]
_attr_preset_modes = [*PRESET_MODE_TO_OVERKIZ] _attr_preset_modes = [*PRESET_MODE_TO_OVERKIZ]
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
def __init__( def __init__(
self, device_url: str, coordinator: OverkizDataUpdateCoordinator self, device_url: str, coordinator: OverkizDataUpdateCoordinator

View file

@ -11,7 +11,7 @@ from homeassistant.components.climate import (
ClimateEntityFeature, ClimateEntityFeature,
HVACMode, HVACMode,
) )
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import UnitOfTemperature
from ..coordinator import OverkizDataUpdateCoordinator from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -45,7 +45,7 @@ class AtlanticHeatRecoveryVentilation(OverkizEntity, ClimateEntity):
_attr_hvac_mode = HVACMode.FAN_ONLY _attr_hvac_mode = HVACMode.FAN_ONLY
_attr_hvac_modes = [HVACMode.FAN_ONLY] _attr_hvac_modes = [HVACMode.FAN_ONLY]
_attr_preset_modes = [PRESET_AUTO, PRESET_PROG, PRESET_MANUAL] _attr_preset_modes = [PRESET_AUTO, PRESET_PROG, PRESET_MANUAL]
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = ( _attr_supported_features = (
ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.FAN_MODE ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.FAN_MODE
) )

View file

@ -15,7 +15,7 @@ from homeassistant.components.climate import (
ClimateEntityFeature, ClimateEntityFeature,
HVACMode, HVACMode,
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from ..coordinator import OverkizDataUpdateCoordinator from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -69,7 +69,7 @@ class AtlanticPassAPCHeatingZone(OverkizEntity, ClimateEntity):
_attr_supported_features = ( _attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
) )
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
def __init__( def __init__(
self, device_url: str, coordinator: OverkizDataUpdateCoordinator self, device_url: str, coordinator: OverkizDataUpdateCoordinator

View file

@ -4,7 +4,7 @@ from typing import cast
from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState
from homeassistant.components.climate import ClimateEntity, HVACMode from homeassistant.components.climate import ClimateEntity, HVACMode
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import UnitOfTemperature
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -22,7 +22,7 @@ class AtlanticPassAPCZoneControl(OverkizEntity, ClimateEntity):
"""Representation of Atlantic Pass APC Zone Control.""" """Representation of Atlantic Pass APC Zone Control."""
_attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ] _attr_hvac_modes = [*HVAC_MODE_TO_OVERKIZ]
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
@property @property
def hvac_mode(self) -> str: def hvac_mode(self) -> str:

View file

@ -13,7 +13,7 @@ from homeassistant.components.climate import (
ClimateEntityFeature, ClimateEntityFeature,
HVACMode, HVACMode,
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from ..coordinator import OverkizDataUpdateCoordinator from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -54,7 +54,7 @@ TEMPERATURE_SENSOR_DEVICE_INDEX = 2
class SomfyThermostat(OverkizEntity, ClimateEntity): class SomfyThermostat(OverkizEntity, ClimateEntity):
"""Representation of Somfy Smart Thermostat.""" """Representation of Somfy Smart Thermostat."""
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = ( _attr_supported_features = (
ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
) )

View file

@ -14,7 +14,7 @@ from homeassistant.components.number import (
NumberEntityDescription, NumberEntityDescription,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -106,7 +106,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
device_class=NumberDeviceClass.TEMPERATURE, device_class=NumberDeviceClass.TEMPERATURE,
native_min_value=6, native_min_value=6,
native_max_value=29, native_max_value=29,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
), ),
OverkizNumberDescription( OverkizNumberDescription(
@ -117,7 +117,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
device_class=NumberDeviceClass.TEMPERATURE, device_class=NumberDeviceClass.TEMPERATURE,
native_min_value=7, native_min_value=7,
native_max_value=30, native_max_value=30,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
), ),
OverkizNumberDescription( OverkizNumberDescription(
@ -128,7 +128,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
device_class=NumberDeviceClass.TEMPERATURE, device_class=NumberDeviceClass.TEMPERATURE,
native_min_value=5, native_min_value=5,
native_max_value=15, native_max_value=15,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
), ),
# DimmerExteriorHeating (Somfy Terrace Heater) (0 - 100) # DimmerExteriorHeating (Somfy Terrace Heater) (0 - 100)

View file

@ -12,7 +12,7 @@ from homeassistant.components.water_heater import (
WaterHeaterEntity, WaterHeaterEntity,
WaterHeaterEntityFeature, WaterHeaterEntityFeature,
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -20,7 +20,7 @@ from ..entity import OverkizEntity
class AtlanticPassAPCDHW(OverkizEntity, WaterHeaterEntity): class AtlanticPassAPCDHW(OverkizEntity, WaterHeaterEntity):
"""Representation of Atlantic Pass APC DHW.""" """Representation of Atlantic Pass APC DHW."""
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = ( _attr_supported_features = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE WaterHeaterEntityFeature.TARGET_TEMPERATURE
| WaterHeaterEntityFeature.OPERATION_MODE | WaterHeaterEntityFeature.OPERATION_MODE

View file

@ -12,7 +12,7 @@ from homeassistant.components.water_heater import (
WaterHeaterEntity, WaterHeaterEntity,
WaterHeaterEntityFeature, 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 ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -44,7 +44,7 @@ DEFAULT_MAX_TEMP: float = 70
class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity): class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity):
"""Representation of a DomesticHotWaterProduction Water Heater.""" """Representation of a DomesticHotWaterProduction Water Heater."""
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = ( _attr_supported_features = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE WaterHeaterEntityFeature.TARGET_TEMPERATURE
| WaterHeaterEntityFeature.OPERATION_MODE | WaterHeaterEntityFeature.OPERATION_MODE

View file

@ -15,7 +15,7 @@ from homeassistant.const import (
PRECISION_WHOLE, PRECISION_WHOLE,
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
TEMP_CELSIUS, UnitOfTemperature,
) )
from ..entity import OverkizEntity from ..entity import OverkizEntity
@ -36,7 +36,7 @@ class HitachiDHW(OverkizEntity, WaterHeaterEntity):
_attr_max_temp = 70.0 _attr_max_temp = 70.0
_attr_precision = PRECISION_WHOLE _attr_precision = PRECISION_WHOLE
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_supported_features = ( _attr_supported_features = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE WaterHeaterEntityFeature.TARGET_TEMPERATURE
| WaterHeaterEntityFeature.OPERATION_MODE | WaterHeaterEntityFeature.OPERATION_MODE