Move Tuya remap method from base to light entity class (#57527)

This commit is contained in:
Franck Nijhof 2021-10-12 11:34:18 +02:00 committed by GitHub
parent e23d35c6f0
commit d44e323e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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."""

View File

@ -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