Use UnitOfTemperature in integrations (i-m) (#84307)
parent
9580c4f1ec
commit
a6ddac9004
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN, SensorDeviceClass, SensorEntity
|
from homeassistant.components.sensor import DOMAIN, SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import 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
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ class HassAqualinkSensor(AqualinkEntity, SensorEntity):
|
||||||
"""Return the measurement unit for the sensor."""
|
"""Return the measurement unit for the sensor."""
|
||||||
if self.dev.name.endswith("_temp"):
|
if self.dev.name.endswith("_temp"):
|
||||||
if self.dev.system.temp_unit == "F":
|
if self.dev.system.temp_unit == "F":
|
||||||
return TEMP_FAHRENHEIT
|
return UnitOfTemperature.FAHRENHEIT
|
||||||
return TEMP_CELSIUS
|
return UnitOfTemperature.CELSIUS
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -6,7 +6,7 @@ from defusedxml import ElementTree
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config import load_yaml_config_file
|
from homeassistant.config import load_yaml_config_file
|
||||||
from homeassistant.const import CONF_TYPE, CONF_UNIT_OF_MEASUREMENT, TEMP_CELSIUS
|
from homeassistant.const import CONF_TYPE, CONF_UNIT_OF_MEASUREMENT, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -63,7 +63,7 @@ AUTO_SETUP_SCHEMA = vol.Schema(
|
||||||
vol.Required(CONF_NODE): cv.string,
|
vol.Required(CONF_NODE): cv.string,
|
||||||
vol.Required(CONF_XPATH): cv.string,
|
vol.Required(CONF_XPATH): cv.string,
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_UNIT_OF_MEASUREMENT, default=TEMP_CELSIUS
|
CONF_UNIT_OF_MEASUREMENT, default=UnitOfTemperature.CELSIUS
|
||||||
): cv.string,
|
): cv.string,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
||||||
CONF_UNIT_OF_MEASUREMENT,
|
CONF_UNIT_OF_MEASUREMENT,
|
||||||
CONF_URL,
|
CONF_URL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
@ -81,7 +81,11 @@ LIGHT_SCHEMA = DEVICE_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
SENSOR_SCHEMA = DEVICE_SCHEMA.extend(
|
SENSOR_SCHEMA = DEVICE_SCHEMA.extend(
|
||||||
{vol.Optional(CONF_UNIT_OF_MEASUREMENT, default=TEMP_CELSIUS): cv.string}
|
{
|
||||||
|
vol.Optional(
|
||||||
|
CONF_UNIT_OF_MEASUREMENT, default=UnitOfTemperature.CELSIUS
|
||||||
|
): cv.string
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
IHC_SCHEMA = vol.Schema(
|
IHC_SCHEMA = vol.Schema(
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.const import TEMP_CELSIUS, UnitOfPressure
|
from homeassistant.const import 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
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
@ -41,14 +41,14 @@ SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
|
||||||
key="heater_temp",
|
key="heater_temp",
|
||||||
name=INCOMFORT_HEATER_TEMP,
|
name=INCOMFORT_HEATER_TEMP,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
extra_key="is_pumping",
|
extra_key="is_pumping",
|
||||||
),
|
),
|
||||||
IncomfortSensorEntityDescription(
|
IncomfortSensorEntityDescription(
|
||||||
key="tap_temp",
|
key="tap_temp",
|
||||||
name=INCOMFORT_TAP_TEMP,
|
name=INCOMFORT_TAP_TEMP,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
extra_key="is_tapping",
|
extra_key="is_tapping",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,7 @@ from homeassistant.components.sensor import (
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
TEMP_CELSIUS,
|
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
|
||||||
|
@ -34,7 +34,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
(DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
(DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
||||||
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,
|
||||||
),
|
),
|
||||||
(DeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
(DeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
||||||
|
|
|
@ -14,7 +14,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
|
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
|
||||||
|
@ -68,7 +68,7 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_fn=lambda data: data.temperature_c,
|
value_fn=lambda data: data.temperature_c,
|
||||||
),
|
),
|
||||||
IntellifireSensorEntityDescription(
|
IntellifireSensorEntityDescription(
|
||||||
|
@ -76,7 +76,7 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
|
||||||
name="Target Temperature",
|
name="Target Temperature",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_fn=lambda data: data.thermostat_setpoint_c,
|
value_fn=lambda data: data.thermostat_setpoint_c,
|
||||||
),
|
),
|
||||||
IntellifireSensorEntityDescription(
|
IntellifireSensorEntityDescription(
|
||||||
|
|
|
@ -27,7 +27,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, TEMP_FAHRENHEIT
|
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
|
||||||
|
@ -173,7 +173,7 @@ class ISYSensorEntity(ISYNodeEntity, SensorEntity):
|
||||||
value = convert_isy_value_to_hass(value, uom, self.target.prec)
|
value = convert_isy_value_to_hass(value, uom, self.target.prec)
|
||||||
|
|
||||||
# Convert temperatures to Home Assistant's unit
|
# Convert temperatures to Home Assistant's unit
|
||||||
if uom in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
if uom in (UnitOfTemperature.CELSIUS, UnitOfTemperature.FAHRENHEIT):
|
||||||
value = self.hass.config.units.temperature(value, uom)
|
value = self.hass.config.units.temperature(value, uom)
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
|
@ -189,7 +189,11 @@ class ISYSensorEntity(ISYNodeEntity, SensorEntity):
|
||||||
# Check if this is a known index pair UOM
|
# Check if this is a known index pair UOM
|
||||||
if isinstance(raw_units, dict) or raw_units in (UOM_ON_OFF, UOM_INDEX):
|
if isinstance(raw_units, dict) or raw_units in (UOM_ON_OFF, UOM_INDEX):
|
||||||
return None
|
return None
|
||||||
if raw_units in (TEMP_FAHRENHEIT, TEMP_CELSIUS, UOM_DOUBLE_TEMP):
|
if raw_units in (
|
||||||
|
UnitOfTemperature.FAHRENHEIT,
|
||||||
|
UnitOfTemperature.CELSIUS,
|
||||||
|
UOM_DOUBLE_TEMP,
|
||||||
|
):
|
||||||
return self.hass.config.units.temperature_unit
|
return self.hass.config.units.temperature_unit
|
||||||
return raw_units
|
return raw_units
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ 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 (
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfElectricCurrent,
|
UnitOfElectricCurrent,
|
||||||
UnitOfElectricPotential,
|
UnitOfElectricPotential,
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
UnitOfTime,
|
UnitOfTime,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -30,7 +30,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
name="Temperature",
|
name="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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -14,8 +14,8 @@ 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 (
|
||||||
CONF_CLIENT_ID,
|
CONF_CLIENT_ID,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
UnitOfTime,
|
UnitOfTime,
|
||||||
UnitOfVolume,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
|
@ -92,7 +92,7 @@ SENSOR_TYPES = (
|
||||||
JustNimbusEntityDescription(
|
JustNimbusEntityDescription(
|
||||||
key="reservoir_temp",
|
key="reservoir_temp",
|
||||||
name="Reservoir Temperature",
|
name="Reservoir 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,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_DEVICE_ID, CONF_NAME, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import CONF_DEVICE_ID, CONF_NAME, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -105,9 +105,9 @@ class KaiterraSensor(SensorEntity):
|
||||||
value = self._sensor["units"].value
|
value = self._sensor["units"].value
|
||||||
|
|
||||||
if value == "F":
|
if value == "F":
|
||||||
return TEMP_FAHRENHEIT
|
return UnitOfTemperature.FAHRENHEIT
|
||||||
if value == "C":
|
if value == "C":
|
||||||
return TEMP_CELSIUS
|
return UnitOfTemperature.CELSIUS
|
||||||
return value
|
return value
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.const import (
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
CONF_ZONE,
|
CONF_ZONE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
@ -27,7 +27,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
||||||
"temperature": SensorEntityDescription(
|
"temperature": SensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
"humidity": SensorEntityDescription(
|
"humidity": SensorEntityDescription(
|
||||||
|
|
|
@ -23,7 +23,7 @@ from homeassistant.const import (
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -187,7 +187,7 @@ class LaCrosseTemperature(LaCrosseSensor):
|
||||||
|
|
||||||
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
|
|
@ -17,8 +17,7 @@ from homeassistant.const import (
|
||||||
CONF_SWITCHES,
|
CONF_SWITCHES,
|
||||||
CONF_UNIT_OF_MEASUREMENT,
|
CONF_UNIT_OF_MEASUREMENT,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
TEMP_FAHRENHEIT,
|
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -74,8 +73,8 @@ DOMAIN_DATA_CLIMATE = {
|
||||||
vol.Optional(CONF_MAX_TEMP, default=DEFAULT_MAX_TEMP): vol.Coerce(float),
|
vol.Optional(CONF_MAX_TEMP, default=DEFAULT_MAX_TEMP): vol.Coerce(float),
|
||||||
vol.Optional(CONF_MIN_TEMP, default=DEFAULT_MIN_TEMP): vol.Coerce(float),
|
vol.Optional(CONF_MIN_TEMP, default=DEFAULT_MIN_TEMP): vol.Coerce(float),
|
||||||
vol.Optional(CONF_LOCKABLE, default=False): vol.Coerce(bool),
|
vol.Optional(CONF_LOCKABLE, default=False): vol.Coerce(bool),
|
||||||
vol.Optional(CONF_UNIT_OF_MEASUREMENT, default=TEMP_CELSIUS): vol.In(
|
vol.Optional(CONF_UNIT_OF_MEASUREMENT, default=UnitOfTemperature.CELSIUS): vol.In(
|
||||||
TEMP_CELSIUS, TEMP_FAHRENHEIT
|
UnitOfTemperature.CELSIUS, UnitOfTemperature.FAHRENHEIT
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,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
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
name="Temperature",
|
name="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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -16,8 +16,8 @@ from homeassistant.const import (
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
CONF_SHOW_ON_MAP,
|
CONF_SHOW_ON_MAP,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -33,7 +33,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
name="Temperature",
|
name="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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -14,7 +14,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
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
|
@ -65,7 +65,7 @@ SENSOR_TYPES = (
|
||||||
key="ambient",
|
key="ambient",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
name="Ambient",
|
name="Ambient",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
available=lambda probe: probe is not None,
|
available=lambda probe: probe is not None,
|
||||||
value=lambda probe: probe.ambient_temperature,
|
value=lambda probe: probe.ambient_temperature,
|
||||||
|
@ -75,7 +75,7 @@ SENSOR_TYPES = (
|
||||||
key="internal",
|
key="internal",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
name="Internal",
|
name="Internal",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
available=lambda probe: probe is not None,
|
available=lambda probe: probe is not None,
|
||||||
value=lambda probe: probe.internal_temperature,
|
value=lambda probe: probe.internal_temperature,
|
||||||
|
@ -100,7 +100,7 @@ SENSOR_TYPES = (
|
||||||
key="cook_target_temp",
|
key="cook_target_temp",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
name="Target",
|
name="Target",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
available=lambda probe: probe is not None and probe.cook is not None,
|
available=lambda probe: probe is not None and probe.cook is not None,
|
||||||
value=lambda probe: probe.cook.target_temperature
|
value=lambda probe: probe.cook.target_temperature
|
||||||
|
@ -112,7 +112,7 @@ SENSOR_TYPES = (
|
||||||
key="cook_peak_temp",
|
key="cook_peak_temp",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
name="Peak",
|
name="Peak",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
available=lambda probe: probe is not None and probe.cook is not None,
|
available=lambda probe: probe is not None and probe.cook is not None,
|
||||||
value=lambda probe: probe.cook.peak_temperature
|
value=lambda probe: probe.cook.peak_temperature
|
||||||
|
|
|
@ -21,7 +21,7 @@ from homeassistant.const import (
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -136,7 +136,7 @@ class MfiSensor(SensorEntity):
|
||||||
return "State"
|
return "State"
|
||||||
|
|
||||||
if tag == "temperature":
|
if tag == "temperature":
|
||||||
return TEMP_CELSIUS
|
return UnitOfTemperature.CELSIUS
|
||||||
if tag == "active_pwr":
|
if tag == "active_pwr":
|
||||||
return "Watts"
|
return "Watts"
|
||||||
if self._port.model == "Input Digital":
|
if self._port.model == "Input Digital":
|
||||||
|
|
|
@ -16,9 +16,9 @@ from homeassistant.const import (
|
||||||
CONF_IP_ADDRESS,
|
CONF_IP_ADDRESS,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
|
@ -62,7 +62,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=TEMPERATURE,
|
key=TEMPERATURE,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
|
@ -112,7 +112,7 @@ LOCAL_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="raw_ambient_temperature",
|
key="raw_ambient_temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
name="Uncalibrated temperature",
|
name="Uncalibrated temperature",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
|
|
@ -22,8 +22,8 @@ from homeassistant.components.sensor import (
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfElectricPotential,
|
UnitOfElectricPotential,
|
||||||
|
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
|
||||||
|
@ -35,7 +35,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
(DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
(DeviceClass.TEMPERATURE, Units.TEMP_CELSIUS): SensorEntityDescription(
|
||||||
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
key=f"{DeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
||||||
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,
|
||||||
),
|
),
|
||||||
(DeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
(DeviceClass.HUMIDITY, Units.PERCENTAGE): SensorEntityDescription(
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.sensor import RestoreSensor, SensorDeviceClass
|
from homeassistant.components.sensor import RestoreSensor, SensorDeviceClass
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_WEBHOOK_ID, STATE_UNKNOWN, TEMP_CELSIUS
|
from homeassistant.const import CONF_WEBHOOK_ID, STATE_UNKNOWN, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
@ -92,7 +92,7 @@ class MobileAppSensor(MobileAppEntity, RestoreSensor):
|
||||||
self.device_class == SensorDeviceClass.TEMPERATURE
|
self.device_class == SensorDeviceClass.TEMPERATURE
|
||||||
and sensor_unique_id == "battery_temperature"
|
and sensor_unique_id == "battery_temperature"
|
||||||
):
|
):
|
||||||
self._config[ATTR_SENSOR_UOM] = TEMP_CELSIUS
|
self._config[ATTR_SENSOR_UOM] = UnitOfTemperature.CELSIUS
|
||||||
return
|
return
|
||||||
|
|
||||||
self._config[ATTR_SENSOR_STATE] = last_sensor_data.native_value
|
self._config[ATTR_SENSOR_STATE] = last_sensor_data.native_value
|
||||||
|
|
Loading…
Reference in New Issue