Remove deprecated temperature conversion of non temperature sensors (#69069)
This commit is contained in:
parent
04dd7c3f7c
commit
e830032b33
4 changed files with 34 additions and 48 deletions
|
@ -6,7 +6,11 @@ from typing import cast
|
|||
|
||||
import pyvera as veraApi
|
||||
|
||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT, SensorEntity
|
||||
from homeassistant.components.sensor import (
|
||||
ENTITY_ID_FORMAT,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
|
@ -60,6 +64,19 @@ class VeraSensor(VeraDevice[veraApi.VeraSensor], SensorEntity):
|
|||
"""Return the name of the sensor."""
|
||||
return self.current_value
|
||||
|
||||
@property
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this entity."""
|
||||
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
|
||||
return SensorDeviceClass.TEMPERATURE
|
||||
if self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
|
||||
return SensorDeviceClass.ILLUMINANCE
|
||||
if self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
|
||||
return SensorDeviceClass.HUMIDITY
|
||||
if self.vera_device.category == veraApi.CATEGORY_POWER_METER:
|
||||
return SensorDeviceClass.POWER
|
||||
return None
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self) -> str | None:
|
||||
"""Return the unit of measurement of this entity, if any."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue