Use UnitOfTemperature in integrations (p-s) (#84308)

This commit is contained in:
epenet 2022-12-20 18:47:27 +01:00 committed by GitHub
parent d60fe7e7cd
commit ba043c9ebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 93 additions and 86 deletions

View File

@ -18,7 +18,7 @@ from homeassistant.const import (
STATE_PROBLEM, STATE_PROBLEM,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
TEMP_CELSIUS, UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
@ -138,7 +138,7 @@ class Plant(Entity):
"min": CONF_MIN_BATTERY_LEVEL, "min": CONF_MIN_BATTERY_LEVEL,
}, },
READING_TEMPERATURE: { READING_TEMPERATURE: {
ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS, ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
"min": CONF_MIN_TEMPERATURE, "min": CONF_MIN_TEMPERATURE,
"max": CONF_MAX_TEMPERATURE, "max": CONF_MAX_TEMPERATURE,
}, },

View File

@ -13,7 +13,7 @@ from homeassistant.components.number import (
NumberMode, NumberMode,
) )
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
@ -51,7 +51,7 @@ NUMBER_TYPES = (
native_max_value_key="upper_bound", native_max_value_key="upper_bound",
native_min_value_key="lower_bound", native_min_value_key="lower_bound",
native_step_key="resolution", native_step_key="resolution",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
native_value_key="setpoint", native_value_key="setpoint",
), ),
) )

View File

@ -10,10 +10,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,
UnitOfPower, UnitOfPower,
UnitOfPressure, UnitOfPressure,
UnitOfTemperature,
UnitOfVolume, UnitOfVolume,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -28,7 +28,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="setpoint", key="setpoint",
name="Setpoint", name="Setpoint",
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,
@ -36,7 +36,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="setpoint_high", key="setpoint_high",
name="Cooling setpoint", name="Cooling setpoint",
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,
@ -44,7 +44,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="setpoint_low", key="setpoint_low",
name="Heating setpoint", name="Heating setpoint",
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,
@ -52,7 +52,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,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -60,7 +60,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="intended_boiler_temperature", key="intended_boiler_temperature",
name="Intended boiler temperature", name="Intended boiler temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -68,7 +68,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="temperature_difference", key="temperature_difference",
name="Temperature difference", name="Temperature difference",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -76,14 +76,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="outdoor_temperature", key="outdoor_temperature",
name="Outdoor temperature", name="Outdoor 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="outdoor_air_temperature", key="outdoor_air_temperature",
name="Outdoor air temperature", name="Outdoor air temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -91,7 +91,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="water_temperature", key="water_temperature",
name="Water temperature", name="Water temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -99,7 +99,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="return_temperature", key="return_temperature",
name="Return temperature", name="Return temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -295,7 +295,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="dhw_temperature", key="dhw_temperature",
name="DHW temperature", name="DHW temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -303,7 +303,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="domestic_hot_water_setpoint", key="domestic_hot_water_setpoint",
name="DHW setpoint", name="DHW setpoint",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -311,7 +311,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="maximum_boiler_temperature", key="maximum_boiler_temperature",
name="Maximum boiler temperature", name="Maximum boiler temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View File

@ -31,8 +31,7 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
TEMP_CELSIUS, UnitOfTemperature,
TEMP_FAHRENHEIT,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entityfilter, state as state_helper from homeassistant.helpers import entityfilter, state as state_helper
@ -347,9 +346,12 @@ class PrometheusMetrics:
with suppress(ValueError): with suppress(ValueError):
value = self.state_as_number(state) value = self.state_as_number(state)
if state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_FAHRENHEIT: if (
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== UnitOfTemperature.FAHRENHEIT
):
value = TemperatureConverter.convert( value = TemperatureConverter.convert(
value, TEMP_FAHRENHEIT, TEMP_CELSIUS value, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS
) )
metric.labels(**self._labels(state)).set(value) metric.labels(**self._labels(state)).set(value)
@ -395,8 +397,10 @@ class PrometheusMetrics:
def _handle_climate_temp(self, state, attr, metric_name, metric_description): def _handle_climate_temp(self, state, attr, metric_name, metric_description):
if temp := state.attributes.get(attr): if temp := state.attributes.get(attr):
if self._climate_units == TEMP_FAHRENHEIT: if self._climate_units == UnitOfTemperature.FAHRENHEIT:
temp = TemperatureConverter.convert(temp, TEMP_FAHRENHEIT, TEMP_CELSIUS) temp = TemperatureConverter.convert(
temp, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS
)
metric = self._metric( metric = self._metric(
metric_name, metric_name,
self.prometheus_cli.Gauge, self.prometheus_cli.Gauge,
@ -508,9 +512,12 @@ class PrometheusMetrics:
try: try:
value = self.state_as_number(state) value = self.state_as_number(state)
if state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TEMP_FAHRENHEIT: if (
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== UnitOfTemperature.FAHRENHEIT
):
value = TemperatureConverter.convert( value = TemperatureConverter.convert(
value, TEMP_FAHRENHEIT, TEMP_CELSIUS value, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS
) )
_metric.labels(**self._labels(state)).set(value) _metric.labels(**self._labels(state)).set(value)
except ValueError: except ValueError:
@ -559,8 +566,8 @@ class PrometheusMetrics:
return return
units = { units = {
TEMP_CELSIUS: "celsius", UnitOfTemperature.CELSIUS: "celsius",
TEMP_FAHRENHEIT: "celsius", # F should go into C metric UnitOfTemperature.FAHRENHEIT: "celsius", # F should go into C metric
PERCENTAGE: "percent", PERCENTAGE: "percent",
} }
default = unit.replace("/", "_per_") default = unit.replace("/", "_per_")

View File

@ -15,7 +15,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
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
@ -66,7 +66,7 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
PrusaLinkSensorEntityDescription[PrinterInfo]( PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.temp-bed", key="printer.telemetry.temp-bed",
name="Heatbed", name="Heatbed",
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 data: cast(float, data["telemetry"]["temp-bed"]), value_fn=lambda data: cast(float, data["telemetry"]["temp-bed"]),
@ -75,7 +75,7 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
PrusaLinkSensorEntityDescription[PrinterInfo]( PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.temp-nozzle", key="printer.telemetry.temp-nozzle",
name="Nozzle Temperature", name="Nozzle 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 data: cast(float, data["telemetry"]["temp-nozzle"]), value_fn=lambda data: cast(float, data["telemetry"]["temp-nozzle"]),

View File

@ -14,10 +14,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 (
TEMP_CELSIUS,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
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
@ -85,7 +85,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = (
PVOutputSensorEntityDescription( PVOutputSensorEntityDescription(
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 status: status.temperature, value_fn=lambda status: status.temperature,

View File

@ -28,8 +28,8 @@ from homeassistant.const import (
LIGHT_LUX, LIGHT_LUX,
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
@ -109,7 +109,7 @@ SENSOR_DESCRIPTIONS = {
): SensorEntityDescription( ): SensorEntityDescription(
key=f"{QingpingSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}", key=f"{QingpingSensorDeviceClass.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,
), ),
} }

View File

@ -24,9 +24,9 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS,
UnitOfDataRate, UnitOfDataRate,
UnitOfInformation, UnitOfInformation,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -74,7 +74,7 @@ _SYSTEM_MON_COND: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="system_temp", key="system_temp",
name="System Temperature", name="System Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
) )
@ -82,7 +82,7 @@ _CPU_MON_COND: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="cpu_temp", key="cpu_temp",
name="CPU Temperature", name="CPU Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
SensorEntityDescription( SensorEntityDescription(
@ -144,7 +144,7 @@ _DRIVE_MON_COND: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="drive_temp", key="drive_temp",
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
) )

View File

@ -32,9 +32,9 @@ 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,
UnitOfDataRate, UnitOfDataRate,
UnitOfInformation, UnitOfInformation,
UnitOfTemperature,
UnitOfTime, UnitOfTime,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -117,7 +117,7 @@ SENSOR_TYPES: Final[tuple[QswSensorEntityDescription, ...]] = (
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
key=QSD_SYSTEM_SENSOR, key=QSD_SYSTEM_SENSOR,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
subkey=QSD_TEMP, subkey=QSD_TEMP,
), ),

View File

@ -24,10 +24,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,
UnitOfLength, UnitOfLength,
UnitOfPower, UnitOfPower,
UnitOfTemperature,
UnitOfTime, UnitOfTime,
UnitOfVolume, UnitOfVolume,
) )
@ -266,7 +266,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = (
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_class=RenaultSensor[KamereonVehicleBatteryStatusData], entity_class=RenaultSensor[KamereonVehicleBatteryStatusData],
name="Battery temperature", name="Battery temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
RenaultSensorEntityDescription( RenaultSensorEntityDescription(
@ -324,7 +324,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = (
data_key="externalTemperature", data_key="externalTemperature",
entity_class=RenaultSensor[KamereonVehicleHvacStatusData], entity_class=RenaultSensor[KamereonVehicleHvacStatusData],
name="Outside temperature", name="Outside temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
RenaultSensorEntityDescription( RenaultSensorEntityDescription(

View File

@ -17,7 +17,7 @@ from homeassistant.const import (
CONF_PORT, CONF_PORT,
CONF_SENSORS, CONF_SENSORS,
PERCENTAGE, PERCENTAGE,
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
@ -142,21 +142,21 @@ SENSOR_TYPES: dict[str, RepetierSensorEntityDescription] = {
"bed_temperature": RepetierSensorEntityDescription( "bed_temperature": RepetierSensorEntityDescription(
key="bed_temperature", key="bed_temperature",
type="temperature", type="temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
name="_bed_", name="_bed_",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
"extruder_temperature": RepetierSensorEntityDescription( "extruder_temperature": RepetierSensorEntityDescription(
key="extruder_temperature", key="extruder_temperature",
type="temperature", type="temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
name="_extruder_", name="_extruder_",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
"chamber_temperature": RepetierSensorEntityDescription( "chamber_temperature": RepetierSensorEntityDescription(
key="chamber_temperature", key="chamber_temperature",
type="temperature", type="temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
name="_chamber_", name="_chamber_",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),

View File

@ -21,8 +21,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,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -311,7 +311,7 @@ class SensiboMotionSensor(SensiboMotionBaseEntity, SensorEntity):
def native_unit_of_measurement(self) -> str | None: def native_unit_of_measurement(self) -> str | None:
"""Add native unit of measurement.""" """Add native unit of measurement."""
if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE: if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE:
return TEMP_CELSIUS return UnitOfTemperature.CELSIUS
return self.entity_description.native_unit_of_measurement return self.entity_description.native_unit_of_measurement
@property @property
@ -345,7 +345,7 @@ class SensiboDeviceSensor(SensiboDeviceBaseEntity, SensorEntity):
def native_unit_of_measurement(self) -> str | None: def native_unit_of_measurement(self) -> str | None:
"""Add native unit of measurement.""" """Add native unit of measurement."""
if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE: if self.entity_description.device_class == SensorDeviceClass.TEMPERATURE:
return TEMP_CELSIUS return UnitOfTemperature.CELSIUS
return self.entity_description.native_unit_of_measurement return self.entity_description.native_unit_of_measurement
@property @property

View File

@ -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,
UnitOfElectricPotential, UnitOfElectricPotential,
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"{SensorProSensorDeviceClass.TEMPERATURE}_{Units.TEMP_CELSIUS}", key=f"{SensorProSensorDeviceClass.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,
), ),
( (

View File

@ -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,
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
@ -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(

View File

@ -20,11 +20,11 @@ from homeassistant.const import (
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
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 import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -79,7 +79,7 @@ SENSORS: Final = {
("device", "deviceTemp"): BlockSensorDescription( ("device", "deviceTemp"): BlockSensorDescription(
key="device|deviceTemp", key="device|deviceTemp",
name="Device Temperature", name="Device Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value=lambda value: round(value, 1), value=lambda value: round(value, 1),
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -221,7 +221,7 @@ SENSORS: Final = {
("sensor", "temp"): BlockSensorDescription( ("sensor", "temp"): BlockSensorDescription(
key="sensor|temp", key="sensor|temp",
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value=lambda value: round(value, 1), value=lambda value: round(value, 1),
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -230,7 +230,7 @@ SENSORS: Final = {
("sensor", "extTemp"): BlockSensorDescription( ("sensor", "extTemp"): BlockSensorDescription(
key="sensor|extTemp", key="sensor|extTemp",
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value=lambda value: round(value, 1), value=lambda value: round(value, 1),
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -345,7 +345,7 @@ RPC_SENSORS: Final = {
key="switch", key="switch",
sub_key="temperature", sub_key="temperature",
name="Device Temperature", name="Device Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value=lambda status, _: round(status["tC"], 1), value=lambda status, _: round(status["tC"], 1),
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -357,7 +357,7 @@ RPC_SENSORS: Final = {
key="temperature", key="temperature",
sub_key="tC", sub_key="tC",
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
value=lambda status, _: round(status, 1), value=lambda status, _: round(status, 1),
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View File

@ -11,7 +11,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_FAHRENHEIT 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
@ -42,7 +42,7 @@ class SimplisafeFreezeSensor(SimpliSafeEntity, SensorEntity):
"""Define a SimpliSafe freeze sensor entity.""" """Define a SimpliSafe freeze sensor entity."""
_attr_device_class = SensorDeviceClass.TEMPERATURE _attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_native_unit_of_measurement = TEMP_FAHRENHEIT _attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT
_attr_state_class = SensorStateClass.MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT
def __init__( def __init__(

View File

@ -21,7 +21,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
PERCENTAGE, PERCENTAGE,
STATE_UNKNOWN, STATE_UNKNOWN,
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
@ -105,7 +105,7 @@ class SkybeaconTemp(SensorEntity):
"""Representation of a Skybeacon temperature sensor.""" """Representation of a Skybeacon 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
def __init__(self, name, mon): def __init__(self, name, mon):
"""Initialize a sensor.""" """Initialize a sensor."""

View File

@ -7,7 +7,7 @@ import logging
from pysmarty import Smarty from pysmarty import Smarty
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
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.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
@ -78,7 +78,7 @@ class SupplyAirTemperatureSensor(SmartySensor):
super().__init__( super().__init__(
name=f"{name} Supply Air Temperature", name=f"{name} Supply Air Temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
unit_of_measurement=TEMP_CELSIUS, unit_of_measurement=UnitOfTemperature.CELSIUS,
smarty=smarty, smarty=smarty,
) )
@ -96,7 +96,7 @@ class ExtractAirTemperatureSensor(SmartySensor):
super().__init__( super().__init__(
name=f"{name} Extract Air Temperature", name=f"{name} Extract Air Temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
unit_of_measurement=TEMP_CELSIUS, unit_of_measurement=UnitOfTemperature.CELSIUS,
smarty=smarty, smarty=smarty,
) )
@ -114,7 +114,7 @@ class OutdoorAirTemperatureSensor(SmartySensor):
super().__init__( super().__init__(
name=f"{name} Outdoor Air Temperature", name=f"{name} Outdoor Air Temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
unit_of_measurement=TEMP_CELSIUS, unit_of_measurement=UnitOfTemperature.CELSIUS,
smarty=smarty, smarty=smarty,
) )

View File

@ -17,12 +17,12 @@ 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,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
@ -40,7 +40,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = {
(Units.C, False): SensorEntityDescription( (Units.C, False): SensorEntityDescription(
key=f"{Units.C}_{False}", key=f"{Units.C}_{False}",
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,
), ),
(Units.KWH, False): SensorEntityDescription( (Units.KWH, False): SensorEntityDescription(

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 TEMP_CELSIUS, TEMP_FAHRENHEIT, UnitOfTime from homeassistant.const import UnitOfTemperature, UnitOfTime
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,8 +25,8 @@ _KEY_MINUTES_REMAIN = "minutes_remain"
_KEY_TEMP = "temp" _KEY_TEMP = "temp"
UNIT_MAPPINGS = { UNIT_MAPPINGS = {
"C": TEMP_CELSIUS, "C": UnitOfTemperature.CELSIUS,
"F": TEMP_FAHRENHEIT, "F": UnitOfTemperature.FAHRENHEIT,
} }

View File

@ -12,8 +12,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,
UnitOfPower, UnitOfPower,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -69,7 +69,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,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),

View File

@ -19,9 +19,9 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_DISKS, CONF_DISKS,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS,
UnitOfDataRate, UnitOfDataRate,
UnitOfInformation, UnitOfInformation,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -223,7 +223,7 @@ STORAGE_VOL_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
api_key=SynoStorage.API_KEY, api_key=SynoStorage.API_KEY,
key="volume_disk_temp_avg", key="volume_disk_temp_avg",
name="Average Disk Temp", name="Average Disk Temp",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
@ -231,7 +231,7 @@ STORAGE_VOL_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
api_key=SynoStorage.API_KEY, api_key=SynoStorage.API_KEY,
key="volume_disk_temp_max", key="volume_disk_temp_max",
name="Maximum Disk Temp", name="Maximum Disk Temp",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
@ -257,7 +257,7 @@ STORAGE_DISK_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
api_key=SynoStorage.API_KEY, api_key=SynoStorage.API_KEY,
key="disk_temp", key="disk_temp",
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,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
@ -269,7 +269,7 @@ INFORMATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
api_key=SynoDSMInformation.API_KEY, api_key=SynoDSMInformation.API_KEY,
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,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,

View File

@ -17,11 +17,11 @@ from homeassistant.const import (
CONF_PORT, CONF_PORT,
PERCENTAGE, PERCENTAGE,
REVOLUTIONS_PER_MINUTE, REVOLUTIONS_PER_MINUTE,
TEMP_CELSIUS,
UnitOfElectricPotential, UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfInformation, UnitOfInformation,
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
@ -147,7 +147,7 @@ BASE_SENSOR_TYPES: tuple[SystemBridgeSensorEntityDescription, ...] = (
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
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=lambda data: data.cpu.temperature, value=lambda data: data.cpu.temperature,
), ),
SystemBridgeSensorEntityDescription( SystemBridgeSensorEntityDescription(
@ -474,7 +474,7 @@ async def async_setup_entry(
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
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=lambda data, k=gpu["key"]: getattr( value=lambda data, k=gpu["key"]: getattr(
data.gpu, f"{k}_temperature" data.gpu, f"{k}_temperature"
), ),

View File

@ -29,9 +29,9 @@ from homeassistant.const import (
PERCENTAGE, PERCENTAGE,
STATE_OFF, STATE_OFF,
STATE_ON, STATE_ON,
TEMP_CELSIUS,
UnitOfDataRate, UnitOfDataRate,
UnitOfInformation, UnitOfInformation,
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
@ -218,7 +218,7 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
"processor_temperature": SysMonitorSensorEntityDescription( "processor_temperature": SysMonitorSensorEntityDescription(
key="processor_temperature", key="processor_temperature",
name="Processor temperature", name="Processor 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,
), ),