Setting device class and measurement unit for target humidity (#76)

This commit is contained in:
Steven Vondruska 2023-01-04 05:30:42 -05:00 committed by GitHub
parent 9bd52e9c1a
commit 3618961ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,9 @@
"""Support for number settings on VeSync devices."""
from homeassistant.components.number import NumberEntity
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import EntityCategory
@ -195,6 +197,23 @@ class VeSyncHumidifierTargetLevelHA(VeSyncNumberEntity):
"""Return the current target humidity level."""
return self.device.config["auto_target_humidity"]
@property
def native_unit_of_measurement(self):
"""Return the native unit of measurement for the target humidity level."""
return PERCENTAGE
@property
def device_class(self):
"""
Return the device class of the target humidity level.
Eventually this should become NumberDeviceClass but that was introduced in 2022.12.
For maximum compatibility, using SensorDeviceClass as recommended by deprecation notice.
Or hard code this to "humidity"
"""
return SensorDeviceClass.HUMIDITY
def set_native_value(self, value):
"""Set the target humidity level."""
self.device.set_humidity(int(value))