forked from home-assistant/core
Move Tuya remap method from base to light entity class (#57527)
This commit is contained in:
@@ -22,13 +22,6 @@ class TuyaHaEntity(Entity):
|
||||
self.tuya_device = device
|
||||
self.tuya_device_manager = device_manager
|
||||
|
||||
@staticmethod
|
||||
def remap(old_value, old_min, old_max, new_min, new_max):
|
||||
"""Remap old_value to new_value."""
|
||||
return ((old_value - old_min) / (old_max - old_min)) * (
|
||||
new_max - new_min
|
||||
) + new_min
|
||||
|
||||
@property
|
||||
def name(self) -> str | None:
|
||||
"""Return Tuya device name."""
|
||||
|
@@ -384,3 +384,10 @@ class TuyaHaLight(TuyaHaEntity, LightEntity):
|
||||
):
|
||||
color_modes.append(COLOR_MODE_HS)
|
||||
return set(color_modes)
|
||||
|
||||
@staticmethod
|
||||
def remap(old_value, old_min, old_max, new_min, new_max):
|
||||
"""Remap old_value to new_value."""
|
||||
return ((old_value - old_min) / (old_max - old_min)) * (
|
||||
new_max - new_min
|
||||
) + new_min
|
||||
|
Reference in New Issue
Block a user