mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Move Tuya remap method from base to light entity class (#57527)
This commit is contained in:
parent
e23d35c6f0
commit
d44e323e95
@ -22,13 +22,6 @@ class TuyaHaEntity(Entity):
|
|||||||
self.tuya_device = device
|
self.tuya_device = device
|
||||||
self.tuya_device_manager = device_manager
|
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
|
@property
|
||||||
def name(self) -> str | None:
|
def name(self) -> str | None:
|
||||||
"""Return Tuya device name."""
|
"""Return Tuya device name."""
|
||||||
|
@ -384,3 +384,10 @@ class TuyaHaLight(TuyaHaEntity, LightEntity):
|
|||||||
):
|
):
|
||||||
color_modes.append(COLOR_MODE_HS)
|
color_modes.append(COLOR_MODE_HS)
|
||||||
return set(color_modes)
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user