Remove deprecated temperature conversion of non temperature sensors (#69069)

This commit is contained in:
Erik Montnemery 2022-04-04 20:02:40 +02:00 committed by GitHub
parent 04dd7c3f7c
commit e830032b33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 48 deletions

View file

@ -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."""