This commit is contained in:
oamchronicle 2025-11-24 18:04:56 +08:00 committed by GitHub
commit 97f1ecfc21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: