mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Use UnitOfTemperature in integrations (t-z) (#84309)
This commit is contained in:
parent
ba043c9ebb
commit
79d3d4ceae
@ -7,7 +7,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.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -139,7 +139,7 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity):
|
||||
def native_unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
if self.home_variable in ["temperature", "outdoor temperature"]:
|
||||
return TEMP_CELSIUS
|
||||
return UnitOfTemperature.CELSIUS
|
||||
if self.home_variable == "solar percentage":
|
||||
return PERCENTAGE
|
||||
if self.home_variable == "weather condition":
|
||||
@ -248,7 +248,7 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity):
|
||||
def native_unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
if self.zone_variable == "temperature":
|
||||
return TEMP_CELSIUS
|
||||
return UnitOfTemperature.CELSIUS
|
||||
if self.zone_variable == "humidity":
|
||||
return PERCENTAGE
|
||||
if self.zone_variable == "heating":
|
||||
|
@ -26,9 +26,6 @@ from homeassistant.const import (
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
SPEED_METERS_PER_SECOND,
|
||||
SPEED_MILES_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
TEMP_KELVIN,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
@ -38,6 +35,7 @@ from homeassistant.const import (
|
||||
UnitOfMass,
|
||||
UnitOfPower,
|
||||
UnitOfPressure,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@ -228,9 +226,9 @@ SENSOR_UNIT_MAP = {
|
||||
hc.SPEED_KILOMETERS_PER_HOUR: SPEED_KILOMETERS_PER_HOUR,
|
||||
hc.SPEED_METERS_PER_SECOND: SPEED_METERS_PER_SECOND,
|
||||
hc.SPEED_MILES_PER_HOUR: SPEED_MILES_PER_HOUR,
|
||||
hc.TEMP_CELSIUS: TEMP_CELSIUS,
|
||||
hc.TEMP_FAHRENHEIT: TEMP_FAHRENHEIT,
|
||||
hc.TEMP_KELVIN: TEMP_KELVIN,
|
||||
hc.TEMP_CELSIUS: UnitOfTemperature.CELSIUS,
|
||||
hc.TEMP_FAHRENHEIT: UnitOfTemperature.FAHRENHEIT,
|
||||
hc.TEMP_KELVIN: UnitOfTemperature.KELVIN,
|
||||
hc.VOLT: UnitOfElectricPotential.VOLT,
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
CONF_PROTOCOL,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -37,7 +37,7 @@ CONF_ONLY_NAMED = "only_named"
|
||||
CONF_TEMPERATURE_SCALE = "temperature_scale"
|
||||
|
||||
DEFAULT_DATATYPE_MASK = 127
|
||||
DEFAULT_TEMPERATURE_SCALE = TEMP_CELSIUS
|
||||
DEFAULT_TEMPERATURE_SCALE = UnitOfTemperature.CELSIUS
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
CONF_OFFSET,
|
||||
DEVICE_DEFAULT_NAME,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -74,7 +74,7 @@ class TemperSensor(SensorEntity):
|
||||
"""Representation of a Temper temperature sensor."""
|
||||
|
||||
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
|
||||
|
||||
def __init__(self, temper_device, name, scaling):
|
||||
"""Initialize the sensor."""
|
||||
|
@ -25,8 +25,8 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
@ -67,7 +67,7 @@ SENSOR_DESCRIPTIONS = {
|
||||
): SensorEntityDescription(
|
||||
key=f"{ThermoBeaconSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(
|
||||
|
@ -27,7 +27,7 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -42,7 +42,7 @@ SENSOR_DESCRIPTIONS = {
|
||||
): SensorEntityDescription(
|
||||
key=f"{ThermoProSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(ThermoProSensorDeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
||||
|
@ -24,7 +24,7 @@ from homeassistant.const import (
|
||||
CONF_EXCLUDE,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_PASSWORD,
|
||||
TEMP_FAHRENHEIT,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -115,7 +115,7 @@ class ThermoworksSmokeSensor(SensorEntity):
|
||||
self._attr_name = "{name} {sensor}".format(
|
||||
name=mgr.name(serial), sensor=SENSOR_TYPES[sensor_type]
|
||||
)
|
||||
self._attr_native_unit_of_measurement = TEMP_FAHRENHEIT
|
||||
self._attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT
|
||||
self._attr_unique_id = f"{serial}-{sensor_type}"
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
self.update_unit()
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, TEMP_FAHRENHEIT
|
||||
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.sensor import sensor_device_info_to_hass_device_info
|
||||
@ -30,7 +30,7 @@ SENSOR_DESCRIPTIONS = {
|
||||
(DeviceClass.TEMPERATURE, Units.TEMP_FAHRENHEIT): SensorEntityDescription(
|
||||
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_FAHRENHEIT}",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_FAHRENHEIT,
|
||||
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(DeviceClass.SPECIFIC_GRAVITY, Units.SPECIFIC_GRAVITY): SensorEntityDescription(
|
||||
|
@ -13,7 +13,7 @@ from homeassistant.components.sensor import (
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, UnitOfTime
|
||||
from homeassistant.const import PERCENTAGE, UnitOfTemperature, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -54,7 +54,7 @@ SENSORS = (
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
name="Tank Temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
getter=lambda status: status.tank_temperature,
|
||||
availability_checker=None,
|
||||
),
|
||||
|
@ -12,9 +12,9 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
UnitOfTemperature,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -132,7 +132,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||
name="Temperature",
|
||||
section="thermostat",
|
||||
measurement="current_display_temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -29,10 +29,10 @@ from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfDataRate,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfInformation,
|
||||
UnitOfTemperature,
|
||||
UnitOfTime,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -320,7 +320,7 @@ SENSE_SENSORS: tuple[ProtectSensorEntityDescription, ...] = (
|
||||
ProtectSensorEntityDescription(
|
||||
key="temperature_level",
|
||||
name="Temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
ufp_value="stats.temperature.value",
|
||||
@ -504,7 +504,7 @@ NVR_DISABLED_SENSORS: tuple[ProtectSensorEntityDescription, ...] = (
|
||||
ProtectSensorEntityDescription(
|
||||
key="cpu_temperature",
|
||||
name="CPU Temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
|
@ -11,7 +11,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
|
||||
@ -80,7 +80,7 @@ NUMBER_ENTITIES: tuple[ValloxNumberEntityDescription, ...] = (
|
||||
name="Supply air temperature (Home)",
|
||||
metric_key="A_CYC_HOME_AIR_TEMP_TARGET",
|
||||
device_class=NumberDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
icon="mdi:thermometer",
|
||||
native_min_value=5.0,
|
||||
native_max_value=25.0,
|
||||
@ -91,7 +91,7 @@ NUMBER_ENTITIES: tuple[ValloxNumberEntityDescription, ...] = (
|
||||
name="Supply air temperature (Away)",
|
||||
metric_key="A_CYC_AWAY_AIR_TEMP_TARGET",
|
||||
device_class=NumberDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
icon="mdi:thermometer",
|
||||
native_min_value=5.0,
|
||||
native_max_value=25.0,
|
||||
@ -102,7 +102,7 @@ NUMBER_ENTITIES: tuple[ValloxNumberEntityDescription, ...] = (
|
||||
name="Supply air temperature (Boost)",
|
||||
metric_key="A_CYC_BOOST_AIR_TEMP_TARGET",
|
||||
device_class=NumberDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
icon="mdi:thermometer",
|
||||
native_min_value=5.0,
|
||||
native_max_value=25.0,
|
||||
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
PERCENTAGE,
|
||||
REVOLUTIONS_PER_MINUTE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
@ -190,7 +190,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||
metric_key="A_CYC_TEMP_EXTRACT_AIR",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
),
|
||||
ValloxSensorEntityDescription(
|
||||
key="exhaust_air",
|
||||
@ -198,7 +198,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||
metric_key="A_CYC_TEMP_EXHAUST_AIR",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
),
|
||||
ValloxSensorEntityDescription(
|
||||
key="outdoor_air",
|
||||
@ -206,7 +206,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||
metric_key="A_CYC_TEMP_OUTDOOR_AIR",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
),
|
||||
ValloxSensorEntityDescription(
|
||||
key="supply_air",
|
||||
@ -214,7 +214,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||
metric_key="A_CYC_TEMP_SUPPLY_AIR",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
),
|
||||
ValloxSensorEntityDescription(
|
||||
key="supply_cell_air",
|
||||
@ -222,7 +222,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||
metric_key="A_CYC_TEMP_SUPPLY_CELL_AIR",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
),
|
||||
ValloxSensorEntityDescription(
|
||||
key="optional_air",
|
||||
@ -230,7 +230,7 @@ SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||
metric_key="A_CYC_TEMP_OPTIONAL",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
ValloxSensorEntityDescription(
|
||||
|
@ -15,8 +15,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UnitOfTemperature,
|
||||
UnitOfTime,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -106,9 +105,9 @@ async def async_setup_entry(
|
||||
|
||||
def temperature_unit(coordinator: VenstarDataUpdateCoordinator) -> str:
|
||||
"""Return the correct unit for temperature."""
|
||||
unit = TEMP_CELSIUS
|
||||
unit = UnitOfTemperature.CELSIUS
|
||||
if coordinator.client.tempunits == coordinator.client.TEMPUNITS_F:
|
||||
unit = TEMP_FAHRENHEIT
|
||||
unit = UnitOfTemperature.FAHRENHEIT
|
||||
return unit
|
||||
|
||||
|
||||
|
@ -15,10 +15,9 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
Platform,
|
||||
UnitOfPower,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -102,9 +101,9 @@ class VeraSensor(VeraDevice[veraApi.VeraSensor], SensorEntity):
|
||||
vera_temp_units = self.vera_device.vera_controller.temperature_units
|
||||
|
||||
if vera_temp_units == "F":
|
||||
self._temperature_units = TEMP_FAHRENHEIT
|
||||
self._temperature_units = UnitOfTemperature.FAHRENHEIT
|
||||
else:
|
||||
self._temperature_units = TEMP_CELSIUS
|
||||
self._temperature_units = UnitOfTemperature.CELSIUS
|
||||
|
||||
elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
|
||||
self.current_value = self.vera_device.light
|
||||
|
@ -7,7 +7,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 import DeviceInfo, Entity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -53,7 +53,7 @@ class VerisureThermometer(
|
||||
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = "Temperature"
|
||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
def __init__(
|
||||
|
@ -21,8 +21,7 @@ from homeassistant.const import (
|
||||
SERVICE_TURN_ON,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, ServiceCall
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -184,7 +183,7 @@ class WaterHeaterEntity(Entity):
|
||||
"""Return the precision of the system."""
|
||||
if hasattr(self, "_attr_precision"):
|
||||
return self._attr_precision
|
||||
if self.hass.config.units.temperature_unit == TEMP_CELSIUS:
|
||||
if self.hass.config.units.temperature_unit == UnitOfTemperature.CELSIUS:
|
||||
return PRECISION_TENTHS
|
||||
return PRECISION_WHOLE
|
||||
|
||||
@ -325,7 +324,7 @@ class WaterHeaterEntity(Entity):
|
||||
if hasattr(self, "_attr_min_temp"):
|
||||
return self._attr_min_temp
|
||||
return TemperatureConverter.convert(
|
||||
DEFAULT_MIN_TEMP, TEMP_FAHRENHEIT, self.temperature_unit
|
||||
DEFAULT_MIN_TEMP, UnitOfTemperature.FAHRENHEIT, self.temperature_unit
|
||||
)
|
||||
|
||||
@property
|
||||
@ -334,7 +333,7 @@ class WaterHeaterEntity(Entity):
|
||||
if hasattr(self, "_attr_max_temp"):
|
||||
return self._attr_max_temp
|
||||
return TemperatureConverter.convert(
|
||||
DEFAULT_MAX_TEMP, TEMP_FAHRENHEIT, self.temperature_unit
|
||||
DEFAULT_MAX_TEMP, UnitOfTemperature.FAHRENHEIT, self.temperature_unit
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -5,7 +5,7 @@ from homeassistant.components.sensor import (
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import DEGREE, TEMP_CELSIUS, UnitOfPressure
|
||||
from homeassistant.const import DEGREE, UnitOfPressure, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -31,7 +31,7 @@ UOM_TO_DEVICE_CLASS_MAP = {
|
||||
# map to convert wiffi unit of measurements to common HA uom's
|
||||
UOM_MAP = {
|
||||
WIFFI_UOM_DEGREE: DEGREE,
|
||||
WIFFI_UOM_TEMP_CELSIUS: TEMP_CELSIUS,
|
||||
WIFFI_UOM_TEMP_CELSIUS: UnitOfTemperature.CELSIUS,
|
||||
WIFFI_UOM_MILLI_BAR: UnitOfPressure.MBAR,
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ from wolf_smartset.models import (
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import TEMP_CELSIUS, UnitOfPressure, UnitOfTime
|
||||
from homeassistant.const import UnitOfPressure, UnitOfTemperature, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
@ -114,7 +114,7 @@ class WolfLinkTemperature(WolfLinkSensor):
|
||||
@property
|
||||
def native_unit_of_measurement(self):
|
||||
"""Return the unit the value is expressed in."""
|
||||
return TEMP_CELSIUS
|
||||
return UnitOfTemperature.CELSIUS
|
||||
|
||||
|
||||
class WolfLinkPressure(WolfLinkSensor):
|
||||
|
@ -14,9 +14,9 @@ from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
UnitOfPressure,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -29,7 +29,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||
"temperature": SensorEntityDescription(
|
||||
key="temperature",
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
@ -24,9 +24,9 @@ from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfPressure,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
@ -96,7 +96,7 @@ SENSOR_DESCRIPTIONS = {
|
||||
(DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
||||
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription(
|
||||
|
@ -16,12 +16,12 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
UnitOfPressure,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@ -103,7 +103,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = {
|
||||
"temperature": ZWaveMeSensorEntityDescription(
|
||||
key="temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
"generic": ZWaveMeSensorEntityDescription(
|
||||
|
Loading…
x
Reference in New Issue
Block a user