Skip to content

Commit

Permalink
fix(tuya): fix value scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
fhempy committed Dec 17, 2022
1 parent 170181b commit fb32943
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions FHEM/bindings/python/fhempy/lib/tuya/tuya.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ async def set_integer(self, hash, params):
== params["new_val"]
):
params["new_val"] = val
if (
params["function_param"]["values"]["step"] != 1
and params["function_param"]["values"]["scale"] == 0
):
params["new_val"] *= 10
new_val = params["new_val"] / (
params["function_param"]["values"]["step"]
/ (10 ** params["function_param"]["values"]["scale"])
Expand Down Expand Up @@ -523,6 +528,8 @@ async def async_disconnected(self):
def convert(self, value, schema):
if schema["type"] == "Integer":
values = schema["values"]
if values["scale"] == 0 and values["step"] != 1:
value = value / 10
return value * values["step"] / (10 ** values["scale"])
elif schema["type"] == "Boolean":
if value is True:
Expand Down

0 comments on commit fb32943

Please sign in to comment.