mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-12 11:50:43 +08:00
Merge 91dbc2aaf6 into 1b87381f43
This commit is contained in:
commit
97f1ecfc21
@ -1283,7 +1283,20 @@ class MIoTPropertyEntity(Entity):
|
||||
|
||||
def __on_value_changed(self, params: dict, ctx: Any) -> None:
|
||||
_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)
|
||||
self._value = self.spec.value_format(value)
|
||||
if not self._pending_write_ha_state_timer:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user