|
|
@@ -522,16 +522,16 @@ class TuyaDpsConfig:
|
|
|
r_dps = self._entity.find_dps(mirror)
|
|
|
return r_dps.get_value(device)
|
|
|
|
|
|
- if scale != 1 and isinstance(result, (int, float)):
|
|
|
- result = result / scale
|
|
|
- replaced = True
|
|
|
-
|
|
|
if invert:
|
|
|
r = self._config.get("range")
|
|
|
if r and "min" in r and "max" in r:
|
|
|
result = -1 * result + r["min"] + r["max"]
|
|
|
replaced = True
|
|
|
|
|
|
+ if scale != 1 and isinstance(result, (int, float)):
|
|
|
+ result = result / scale
|
|
|
+ replaced = True
|
|
|
+
|
|
|
if replaced:
|
|
|
_LOGGER.debug(
|
|
|
"%s: Mapped dps %s value from %s to %s",
|
|
|
@@ -631,12 +631,6 @@ class TuyaDpsConfig:
|
|
|
r_dps = self._entity.find_dps(redirect)
|
|
|
return r_dps.get_values_to_set(device, value)
|
|
|
|
|
|
- if invert:
|
|
|
- r = self._config.get("range")
|
|
|
- if r and "min" in r and "max" in r:
|
|
|
- result = -1 * result + r["min"] + r["max"]
|
|
|
- replaced = True
|
|
|
-
|
|
|
if scale != 1 and isinstance(result, (int, float)):
|
|
|
_LOGGER.debug(f"Scaling {result} by {scale}")
|
|
|
result = result * scale
|
|
|
@@ -645,6 +639,12 @@ class TuyaDpsConfig:
|
|
|
result = remap["dps_val"]
|
|
|
replaced = True
|
|
|
|
|
|
+ if invert:
|
|
|
+ r = self._config.get("range")
|
|
|
+ if r and "min" in r and "max" in r:
|
|
|
+ result = -1 * result + r["min"] + r["max"]
|
|
|
+ replaced = True
|
|
|
+
|
|
|
if step and isinstance(result, (int, float)):
|
|
|
_LOGGER.debug(f"Stepping {result} to {step}")
|
|
|
result = step * round(float(result) / step)
|