mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-17 23:50:42 +08:00
Signed-off-by: oamchronicle <oamchronicle@gmail.com>
This commit is contained in:
parent
33ee65cf75
commit
91dbc2aaf6
@ -1282,7 +1282,20 @@ class MIoTPropertyEntity(Entity):
|
|||||||
|
|
||||||
def __on_value_changed(self, params: dict, ctx: Any) -> None:
|
def __on_value_changed(self, params: dict, ctx: Any) -> None:
|
||||||
_LOGGER.debug('property changed, %s', params)
|
_LOGGER.debug('property changed, %s', params)
|
||||||
value: Any = self.spec.value_format(params['value'])
|
|
||||||
|
raw_value = params["value"]
|
||||||
|
|
||||||
|
if isinstance(raw_value, str):
|
||||||
|
try:
|
||||||
|
numeric_value = float(raw_value)
|
||||||
|
if numeric_value.is_integer():
|
||||||
|
raw_value = int(numeric_value)
|
||||||
|
else:
|
||||||
|
raw_value = numeric_value
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
value = self.spec.value_format(raw_value)
|
||||||
value = self.spec.eval_expr(value)
|
value = self.spec.eval_expr(value)
|
||||||
self._value = self.spec.value_format(value)
|
self._value = self.spec.value_format(value)
|
||||||
if not self._pending_write_ha_state_timer:
|
if not self._pending_write_ha_state_timer:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user