mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-02-10 09:08:58 +01:00
Fix deprecation warning in number entity (#44)
* Fix deprecation warning in number entity * fix style * fix style
This commit is contained in:
parent
95a8c624b0
commit
ed79d94efb
@ -75,6 +75,13 @@ class VeSyncNumberEntity(VeSyncBaseEntity, NumberEntity):
|
||||
class VeSyncFanSpeedLevelHA(VeSyncNumberEntity):
|
||||
"""Representation of the fan speed level of a VeSync fan."""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the number entity."""
|
||||
super().__init__(device)
|
||||
self._attr_native_min_value = device.config_dict["levels"][0]
|
||||
self._attr_native_max_value = device.config_dict["levels"][-1]
|
||||
self._attr_native_step = 1
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this device."""
|
||||
@ -86,31 +93,16 @@ class VeSyncFanSpeedLevelHA(VeSyncNumberEntity):
|
||||
return f"{super().name} fan speed level"
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
def native_value(self):
|
||||
"""Return the fan speed level."""
|
||||
return self.device.speed
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
"""Return the minimum fan speed level."""
|
||||
return self.device.config_dict["levels"][0]
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
"""Return the maximum fan speed level."""
|
||||
return self.device.config_dict["levels"][-1]
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
"""Return the steps for the fan speed level."""
|
||||
return 1.0
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes of the humidifier."""
|
||||
return {"fan speed levels": self.device.config_dict["levels"]}
|
||||
|
||||
def set_value(self, value):
|
||||
def set_native_value(self, value):
|
||||
"""Set the fan speed level."""
|
||||
self.device.change_fan_speed(int(value))
|
||||
|
||||
@ -118,6 +110,13 @@ class VeSyncFanSpeedLevelHA(VeSyncNumberEntity):
|
||||
class VeSyncHumidifierMistLevelHA(VeSyncNumberEntity):
|
||||
"""Representation of the mist level of a VeSync humidifier."""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the number entity."""
|
||||
super().__init__(device)
|
||||
self._attr_native_min_value = device.config_dict["mist_levels"][0]
|
||||
self._attr_native_max_value = device.config_dict["mist_levels"][-1]
|
||||
self._attr_native_step = 1
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this device."""
|
||||
@ -129,31 +128,16 @@ class VeSyncHumidifierMistLevelHA(VeSyncNumberEntity):
|
||||
return f"{super().name} mist level"
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
def native_value(self):
|
||||
"""Return the mist level."""
|
||||
return self.device.details["mist_virtual_level"]
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
"""Return the minimum mist level."""
|
||||
return self.device.config_dict["mist_levels"][0]
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
"""Return the maximum mist level."""
|
||||
return self.device.config_dict["mist_levels"][-1]
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
"""Return the steps for the mist level."""
|
||||
return 1.0
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes of the humidifier."""
|
||||
return {"mist levels": self.device.config_dict["mist_levels"]}
|
||||
|
||||
def set_value(self, value):
|
||||
def set_native_value(self, value):
|
||||
"""Set the mist level."""
|
||||
self.device.set_mist_level(int(value))
|
||||
|
||||
@ -161,6 +145,13 @@ class VeSyncHumidifierMistLevelHA(VeSyncNumberEntity):
|
||||
class VeSyncHumidifierWarmthLevelHA(VeSyncNumberEntity):
|
||||
"""Representation of the warmth level of a VeSync humidifier."""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the number entity."""
|
||||
super().__init__(device)
|
||||
self._attr_native_min_value = device.config_dict["warm_mist_levels"][0]
|
||||
self._attr_native_max_value = device.config_dict["warm_mist_levels"][-1]
|
||||
self._attr_native_step = 1
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this device."""
|
||||
@ -172,31 +163,16 @@ class VeSyncHumidifierWarmthLevelHA(VeSyncNumberEntity):
|
||||
return f"{super().name} warm mist"
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
def native_value(self):
|
||||
"""Return the warmth level."""
|
||||
return self.device.details["warm_mist_level"]
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
"""Return the minimum mist level."""
|
||||
return self.device.config_dict["warm_mist_levels"][0]
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
"""Return the maximum mist level."""
|
||||
return self.device.config_dict["warm_mist_levels"][-1]
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
"""Return the steps for the mist level."""
|
||||
return 1.0
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes of the humidifier."""
|
||||
return {"warm mist levels": self.device.config_dict["warm_mist_levels"]}
|
||||
|
||||
def set_value(self, value):
|
||||
def set_native_value(self, value):
|
||||
"""Set the mist level."""
|
||||
self.device.set_warm_level(int(value))
|
||||
|
||||
@ -204,6 +180,13 @@ class VeSyncHumidifierWarmthLevelHA(VeSyncNumberEntity):
|
||||
class VeSyncHumidifierTargetLevelHA(VeSyncNumberEntity):
|
||||
"""Representation of the target humidity level of a VeSync humidifier."""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the number entity."""
|
||||
super().__init__(device)
|
||||
self._attr_native_min_value = MIN_HUMIDITY
|
||||
self._attr_native_max_value = MAX_HUMIDITY
|
||||
self._attr_native_step = 1
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this device."""
|
||||
@ -215,25 +198,10 @@ class VeSyncHumidifierTargetLevelHA(VeSyncNumberEntity):
|
||||
return f"{super().name} target level"
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
def native_value(self):
|
||||
"""Return the current target humidity level."""
|
||||
return self.device.config["auto_target_humidity"]
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
"""Return the minimum humidity level."""
|
||||
return MIN_HUMIDITY
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
"""Return the maximum humidity level."""
|
||||
return MAX_HUMIDITY
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
"""Return the humidity change step."""
|
||||
return 1.0
|
||||
|
||||
def set_value(self, value):
|
||||
def set_native_value(self, value):
|
||||
"""Set the target humidity level."""
|
||||
self.device.set_humidity(int(value))
|
||||
|
@ -1,5 +1,5 @@
|
||||
-r requirements.txt
|
||||
homeassistant==2022.6.4
|
||||
homeassistant==2022.7.7
|
||||
black
|
||||
isort
|
||||
flake8
|
||||
|
Loading…
x
Reference in New Issue
Block a user