Set device_class on temperature sensors R-Z (#52920)

This commit is contained in:
Erik Montnemery 2021-07-12 18:53:52 +02:00 committed by GitHub
parent ad0ccc1b70
commit 1a74fd7a14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 123 additions and 36 deletions

View file

@ -1,6 +1,6 @@
"""Support for Z-Wave sensors."""
from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, DOMAIN, SensorEntity
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -79,6 +79,13 @@ class ZWaveMultilevelSensor(ZWaveSensor):
return self._state
@property
def device_class(self):
"""Return the class of this device."""
if self._units in ["C", "F"]:
return DEVICE_CLASS_TEMPERATURE
return None
@property
def unit_of_measurement(self):
"""Return the unit the value is expressed in."""