mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2025-11-21 03:28:57 +08:00
fix: float value precision (#1485)
This commit is contained in:
@@ -66,7 +66,7 @@ class MIoTSpecValueRange:
|
|||||||
"""MIoT SPEC value range class."""
|
"""MIoT SPEC value range class."""
|
||||||
min_: int
|
min_: int
|
||||||
max_: int
|
max_: int
|
||||||
step: int
|
step: int | float
|
||||||
|
|
||||||
def __init__(self, value_range: Union[dict, list]) -> None:
|
def __init__(self, value_range: Union[dict, list]) -> None:
|
||||||
if isinstance(value_range, dict):
|
if isinstance(value_range, dict):
|
||||||
@@ -567,9 +567,8 @@ class MIoTSpecProperty(_MIoTSpecBase):
|
|||||||
return
|
return
|
||||||
self._value_range = MIoTSpecValueRange(value_range=value)
|
self._value_range = MIoTSpecValueRange(value_range=value)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
self.precision = len(str(
|
step_: str = format(value[2], '.10f').rstrip('0').rstrip('.')
|
||||||
value[2]).split('.')[1].rstrip('0')) if '.' in str(
|
self.precision = len(step_.split('.')[1]) if '.' in step_ else 0
|
||||||
value[2]) else 0
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value_list(self) -> Optional[MIoTSpecValueList]:
|
def value_list(self) -> Optional[MIoTSpecValueList]:
|
||||||
|
|||||||
Reference in New Issue
Block a user