Handle Tuya sendings strings instead of numeric values (#65009)

pull/65024/head
Franck Nijhof 2022-01-26 23:05:01 +01:00 committed by GitHub
parent 0f63fb221c
commit 4925cf5aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -74,7 +74,16 @@ class IntegerTypeData:
@classmethod
def from_json(cls, dpcode: DPCode, data: str) -> IntegerTypeData:
"""Load JSON string and return a IntegerTypeData object."""
return cls(dpcode, **json.loads(data))
parsed = json.loads(data)
return cls(
dpcode,
min=int(parsed["min"]),
max=int(parsed["max"]),
scale=float(parsed["scale"]),
step=float(parsed["step"]),
unit=parsed.get("unit"),
type=parsed.get("type"),
)
@dataclass