Home Assistant Unofficial Reference 2024.12.1
util.py
Go to the documentation of this file.
1 """Utility methods for the Tuya integration."""
2 
3 from __future__ import annotations
4 
5 
7  value: float,
8  from_min: float = 0,
9  from_max: float = 255,
10  to_min: float = 0,
11  to_max: float = 255,
12  reverse: bool = False,
13 ) -> float:
14  """Remap a value from its current range, to a new range."""
15  if reverse:
16  value = from_max - value + from_min
17  return ((value - from_min) / (from_max - from_min)) * (to_max - to_min) + to_min
float remap_value(float value, float from_min=0, float from_max=255, float to_min=0, float to_max=255, bool reverse=False)
Definition: util.py:13