Use UnitOfTemperature in integrations (a-d) (#84304)
This commit is contained in:
parent
82efbee443
commit
d89ba40010
24 changed files with 73 additions and 63 deletions
|
@ -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
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
@ -155,7 +155,7 @@ class AdvantageAirZoneSignal(AdvantageAirZoneEntity, SensorEntity):
|
||||||
class AdvantageAirZoneTemp(AdvantageAirZoneEntity, SensorEntity):
|
class AdvantageAirZoneTemp(AdvantageAirZoneEntity, SensorEntity):
|
||||||
"""Representation of Advantage Air Zone temperature sensor."""
|
"""Representation of Advantage Air Zone temperature 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
|
||||||
_attr_entity_registry_enabled_default = False
|
_attr_entity_registry_enabled_default = False
|
||||||
|
|
|
@ -16,8 +16,8 @@ from homeassistant.const import (
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||||
|
@ -112,7 +112,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
|
||||||
key=ATTR_API_TEMPERATURE,
|
key=ATTR_API_TEMPERATURE,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
name=ATTR_API_TEMPERATURE.capitalize(),
|
name=ATTR_API_TEMPERATURE.capitalize(),
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value=lambda value: round(value, 1),
|
value=lambda value: round(value, 1),
|
||||||
),
|
),
|
||||||
|
|
|
@ -16,8 +16,8 @@ from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS,
|
SIGNAL_STRENGTH_DECIBELS,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
|
@ -39,7 +39,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
||||||
"temp": SensorEntityDescription(
|
"temp": 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,
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
),
|
),
|
||||||
"humidity": SensorEntityDescription(
|
"humidity": SensorEntityDescription(
|
||||||
|
|
|
@ -17,8 +17,8 @@ from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH
|
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH
|
||||||
|
@ -63,7 +63,7 @@ SENSORS_MAPPING_TEMPLATE: dict[str, SensorEntityDescription] = {
|
||||||
"temperature": SensorEntityDescription(
|
"temperature": 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",
|
||||||
),
|
),
|
||||||
"humidity": SensorEntityDescription(
|
"humidity": SensorEntityDescription(
|
||||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.const import (
|
||||||
CONF_SHOW_ON_MAP,
|
CONF_SHOW_ON_MAP,
|
||||||
CONF_STATE,
|
CONF_STATE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
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
|
||||||
|
@ -136,7 +136,7 @@ NODE_PRO_SENSOR_DESCRIPTIONS = (
|
||||||
key=SENSOR_KIND_TEMPERATURE,
|
key=SENSOR_KIND_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,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Final
|
||||||
|
|
||||||
from aioairzone.common import TemperatureUnit
|
from aioairzone.common import TemperatureUnit
|
||||||
|
|
||||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import UnitOfTemperature
|
||||||
|
|
||||||
DOMAIN: Final = "airzone"
|
DOMAIN: Final = "airzone"
|
||||||
MANUFACTURER: Final = "Airzone"
|
MANUFACTURER: Final = "Airzone"
|
||||||
|
@ -13,6 +13,6 @@ AIOAIRZONE_DEVICE_TIMEOUT_SEC: Final = 10
|
||||||
API_TEMPERATURE_STEP: Final = 0.5
|
API_TEMPERATURE_STEP: Final = 0.5
|
||||||
|
|
||||||
TEMP_UNIT_LIB_TO_HASS: Final[dict[TemperatureUnit, str]] = {
|
TEMP_UNIT_LIB_TO_HASS: Final[dict[TemperatureUnit, str]] = {
|
||||||
TemperatureUnit.CELSIUS: TEMP_CELSIUS,
|
TemperatureUnit.CELSIUS: UnitOfTemperature.CELSIUS,
|
||||||
TemperatureUnit.FAHRENHEIT: TEMP_FAHRENHEIT,
|
TemperatureUnit.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT,
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ 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,
|
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
|
||||||
|
@ -50,7 +50,7 @@ ZONE_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = (
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
key=AZD_TEMP,
|
key=AZD_TEMP,
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
|
|
|
@ -25,8 +25,8 @@ from homeassistant.const import (
|
||||||
ATTR_SW_VERSION,
|
ATTR_SW_VERSION,
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
UnitOfTime,
|
UnitOfTime,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -40,7 +40,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
key="temperature",
|
key="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,
|
||||||
),
|
),
|
||||||
"humidity": SensorEntityDescription(
|
"humidity": SensorEntityDescription(
|
||||||
|
|
|
@ -3,9 +3,8 @@ from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
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,
|
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
UnitOfTemperature,
|
||||||
UnitOfTime,
|
UnitOfTime,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -49,8 +48,8 @@ class AtagSensor(AtagEntity, SensorEntity):
|
||||||
self._attr_device_class = coordinator.data.report[self._id].sensorclass
|
self._attr_device_class = coordinator.data.report[self._id].sensorclass
|
||||||
if coordinator.data.report[self._id].measure in (
|
if coordinator.data.report[self._id].measure in (
|
||||||
UnitOfPressure.BAR,
|
UnitOfPressure.BAR,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature.CELSIUS,
|
||||||
TEMP_FAHRENHEIT,
|
UnitOfTemperature.FAHRENHEIT,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
UnitOfTime.HOURS,
|
UnitOfTime.HOURS,
|
||||||
):
|
):
|
||||||
|
|
|
@ -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, UnitOfEnergy, UnitOfPower
|
from homeassistant.const import UnitOfEnergy, UnitOfPower, 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
|
||||||
|
@ -36,7 +36,7 @@ SENSOR_TYPES = [
|
||||||
key="temp",
|
key="temp",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
),
|
),
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS
|
from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, 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
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -43,7 +43,7 @@ AUTO_COMFORT_SENSORS = (
|
||||||
BAFSensorDescription(
|
BAFSensorDescription(
|
||||||
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,
|
||||||
value_fn=lambda device: cast(Optional[float], device.temperature),
|
value_fn=lambda device: cast(Optional[float], device.temperature),
|
||||||
|
|
|
@ -9,7 +9,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_MAC, CONF_NAME, PERCENTAGE, TEMP_CELSIUS
|
from homeassistant.const import CONF_MAC, CONF_NAME, PERCENTAGE, 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
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -20,7 +20,7 @@ DEFAULT_NAME = "BeeWi SmartClim"
|
||||||
|
|
||||||
# Sensor config
|
# Sensor config
|
||||||
SENSOR_TYPES = [
|
SENSOR_TYPES = [
|
||||||
[SensorDeviceClass.TEMPERATURE, "Temperature", TEMP_CELSIUS],
|
[SensorDeviceClass.TEMPERATURE, "Temperature", UnitOfTemperature.CELSIUS],
|
||||||
[SensorDeviceClass.HUMIDITY, "Humidity", PERCENTAGE],
|
[SensorDeviceClass.HUMIDITY, "Humidity", PERCENTAGE],
|
||||||
[SensorDeviceClass.BATTERY, "Battery", PERCENTAGE],
|
[SensorDeviceClass.BATTERY, "Battery", PERCENTAGE],
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,7 +9,10 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, TEMP_CELSIUS
|
from homeassistant.const import (
|
||||||
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
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 +38,7 @@ SENSOR_TYPES = (
|
||||||
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,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -22,7 +22,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=TYPE_TEMPERATURE,
|
key=TYPE_TEMPERATURE,
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
native_unit_of_measurement=TEMP_FAHRENHEIT,
|
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
|
|
|
@ -25,8 +25,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,
|
|
||||||
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
|
||||||
|
@ -67,7 +67,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
): SensorEntityDescription(
|
): SensorEntityDescription(
|
||||||
key=f"{BlueMaestroSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}",
|
key=f"{BlueMaestroSensorDeviceClass.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,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -76,7 +76,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
): SensorEntityDescription(
|
): SensorEntityDescription(
|
||||||
key=f"{BlueMaestroSensorDeviceClass.DEW_POINT}_{Units.TEMP_CELSIUS}",
|
key=f"{BlueMaestroSensorDeviceClass.DEW_POINT}_{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,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
|
|
@ -13,9 +13,9 @@ from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
|
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
|
||||||
|
@ -164,7 +164,7 @@ class TemperatureSensor(SHCEntity, SensorEntity):
|
||||||
"""Representation of an SHC temperature reporting sensor."""
|
"""Representation of an SHC temperature reporting 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
|
||||||
|
|
||||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||||
"""Initialize an SHC temperature reporting sensor."""
|
"""Initialize an SHC temperature reporting sensor."""
|
||||||
|
|
|
@ -10,11 +10,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 (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfElectricCurrent,
|
UnitOfElectricCurrent,
|
||||||
UnitOfElectricPotential,
|
UnitOfElectricPotential,
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
|
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
|
||||||
|
@ -26,7 +26,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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -10,7 +10,7 @@ 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,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -37,7 +37,13 @@ CANARY_FLEX: Final = "Canary Flex"
|
||||||
# Sensor types are defined like so:
|
# Sensor types are defined like so:
|
||||||
# sensor type name, unit_of_measurement, icon, device class, products supported
|
# sensor type name, unit_of_measurement, icon, device class, products supported
|
||||||
SENSOR_TYPES: Final[list[SensorTypeItem]] = [
|
SENSOR_TYPES: Final[list[SensorTypeItem]] = [
|
||||||
("temperature", TEMP_CELSIUS, None, SensorDeviceClass.TEMPERATURE, [CANARY_PRO]),
|
(
|
||||||
|
"temperature",
|
||||||
|
UnitOfTemperature.CELSIUS,
|
||||||
|
None,
|
||||||
|
SensorDeviceClass.TEMPERATURE,
|
||||||
|
[CANARY_PRO],
|
||||||
|
),
|
||||||
("humidity", PERCENTAGE, None, SensorDeviceClass.HUMIDITY, [CANARY_PRO]),
|
("humidity", PERCENTAGE, None, SensorDeviceClass.HUMIDITY, [CANARY_PRO]),
|
||||||
("air_quality", None, "mdi:weather-windy", None, [CANARY_PRO]),
|
("air_quality", None, "mdi:weather-windy", None, [CANARY_PRO]),
|
||||||
(
|
(
|
||||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.const import (
|
||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -250,7 +250,7 @@ class ClimateEntity(Entity):
|
||||||
"""Return the precision of the system."""
|
"""Return the precision of the system."""
|
||||||
if hasattr(self, "_attr_precision"):
|
if hasattr(self, "_attr_precision"):
|
||||||
return 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_TENTHS
|
||||||
return PRECISION_WHOLE
|
return PRECISION_WHOLE
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ class ClimateEntity(Entity):
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature."""
|
||||||
if not hasattr(self, "_attr_min_temp"):
|
if not hasattr(self, "_attr_min_temp"):
|
||||||
return TemperatureConverter.convert(
|
return TemperatureConverter.convert(
|
||||||
DEFAULT_MIN_TEMP, TEMP_CELSIUS, self.temperature_unit
|
DEFAULT_MIN_TEMP, UnitOfTemperature.CELSIUS, self.temperature_unit
|
||||||
)
|
)
|
||||||
return self._attr_min_temp
|
return self._attr_min_temp
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ class ClimateEntity(Entity):
|
||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature."""
|
||||||
if not hasattr(self, "_attr_max_temp"):
|
if not hasattr(self, "_attr_max_temp"):
|
||||||
return TemperatureConverter.convert(
|
return TemperatureConverter.convert(
|
||||||
DEFAULT_MAX_TEMP, TEMP_CELSIUS, self.temperature_unit
|
DEFAULT_MAX_TEMP, UnitOfTemperature.CELSIUS, self.temperature_unit
|
||||||
)
|
)
|
||||||
return self._attr_max_temp
|
return self._attr_max_temp
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,10 @@ from homeassistant.const import (
|
||||||
CONF_RESOURCES,
|
CONF_RESOURCES,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
REVOLUTIONS_PER_MINUTE,
|
REVOLUTIONS_PER_MINUTE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
|
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
UnitOfTime,
|
UnitOfTime,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -101,7 +101,7 @@ SENSOR_TYPES = (
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Inside temperature",
|
name="Inside temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
sensor_id=SENSOR_TEMPERATURE_EXTRACT,
|
sensor_id=SENSOR_TEMPERATURE_EXTRACT,
|
||||||
multiplier=0.1,
|
multiplier=0.1,
|
||||||
),
|
),
|
||||||
|
@ -118,7 +118,7 @@ SENSOR_TYPES = (
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Current RMOT",
|
name="Current RMOT",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
sensor_id=SENSOR_CURRENT_RMOT,
|
sensor_id=SENSOR_CURRENT_RMOT,
|
||||||
multiplier=0.1,
|
multiplier=0.1,
|
||||||
),
|
),
|
||||||
|
@ -127,7 +127,7 @@ SENSOR_TYPES = (
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Outside temperature",
|
name="Outside temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
sensor_id=SENSOR_TEMPERATURE_OUTDOOR,
|
sensor_id=SENSOR_TEMPERATURE_OUTDOOR,
|
||||||
multiplier=0.1,
|
multiplier=0.1,
|
||||||
),
|
),
|
||||||
|
@ -144,7 +144,7 @@ SENSOR_TYPES = (
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Supply temperature",
|
name="Supply temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
sensor_id=SENSOR_TEMPERATURE_SUPPLY,
|
sensor_id=SENSOR_TEMPERATURE_SUPPLY,
|
||||||
multiplier=0.1,
|
multiplier=0.1,
|
||||||
),
|
),
|
||||||
|
@ -193,7 +193,7 @@ SENSOR_TYPES = (
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
name="Exhaust temperature",
|
name="Exhaust temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
sensor_id=SENSOR_TEMPERATURE_EXHAUST,
|
sensor_id=SENSOR_TEMPERATURE_EXHAUST,
|
||||||
multiplier=0.1,
|
multiplier=0.1,
|
||||||
),
|
),
|
||||||
|
|
|
@ -15,10 +15,10 @@ 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,
|
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfFrequency,
|
UnitOfFrequency,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -58,7 +58,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
name="Inside temperature",
|
name="Inside temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_func=lambda device: device.inside_temperature,
|
value_func=lambda device: device.inside_temperature,
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
|
@ -66,7 +66,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
||||||
name="Outside temperature",
|
name="Outside temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
value_func=lambda device: device.outside_temperature,
|
value_func=lambda device: device.outside_temperature,
|
||||||
),
|
),
|
||||||
DaikinSensorEntityDescription(
|
DaikinSensorEntityDescription(
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, TEMP_CELSIUS
|
from homeassistant.const import PERCENTAGE, REVOLUTIONS_PER_MINUTE, 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
|
||||||
|
@ -32,28 +32,28 @@ def setup_platform(
|
||||||
sensors = [
|
sensors = [
|
||||||
[
|
[
|
||||||
"Danfoss Air Exhaust Temperature",
|
"Danfoss Air Exhaust Temperature",
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature.CELSIUS,
|
||||||
ReadCommand.exhaustTemperature,
|
ReadCommand.exhaustTemperature,
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Danfoss Air Outdoor Temperature",
|
"Danfoss Air Outdoor Temperature",
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature.CELSIUS,
|
||||||
ReadCommand.outdoorTemperature,
|
ReadCommand.outdoorTemperature,
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Danfoss Air Supply Temperature",
|
"Danfoss Air Supply Temperature",
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature.CELSIUS,
|
||||||
ReadCommand.supplyTemperature,
|
ReadCommand.supplyTemperature,
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Danfoss Air Extract Temperature",
|
"Danfoss Air Extract Temperature",
|
||||||
TEMP_CELSIUS,
|
UnitOfTemperature.CELSIUS,
|
||||||
ReadCommand.extractTemperature,
|
ReadCommand.extractTemperature,
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
|
|
|
@ -36,10 +36,10 @@ from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_BILLION,
|
CONCENTRATION_PARTS_PER_BILLION,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
|
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
|
||||||
|
@ -200,7 +200,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (
|
||||||
instance_check=Temperature,
|
instance_check=Temperature,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
),
|
),
|
||||||
DeconzSensorDescription[Time](
|
DeconzSensorDescription[Time](
|
||||||
key="last_set",
|
key="last_set",
|
||||||
|
@ -231,7 +231,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (
|
||||||
old_unique_id_suffix="temperature",
|
old_unique_id_suffix="temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
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
|
||||||
|
@ -85,7 +85,9 @@ class SmartPlugSwitch(SwitchEntity):
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes of the device."""
|
"""Return the state attributes of the device."""
|
||||||
try:
|
try:
|
||||||
ui_temp = self.units.temperature(int(self.data.temperature), TEMP_CELSIUS)
|
ui_temp = self.units.temperature(
|
||||||
|
int(self.data.temperature), UnitOfTemperature.CELSIUS
|
||||||
|
)
|
||||||
temperature = ui_temp
|
temperature = ui_temp
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
temperature = None
|
temperature = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue