fix: correct the property value format after expression calculation (#1366)

This commit is contained in:
Li Shuzhen
2025-08-19 14:36:30 +08:00
committed by GitHub
parent c29f7eecbd
commit 65a7a6d22a

View File

@ -1108,6 +1108,8 @@ class MIoTServiceEntity(Entity):
):
continue
value: Any = prop.value_format(params['value'])
value = prop.eval_expr(value)
value = prop.value_format(value)
self._prop_value_map[prop] = value
if prop in self._prop_changed_subs:
self._prop_changed_subs[prop](prop, value)
@ -1279,8 +1281,9 @@ class MIoTPropertyEntity(Entity):
def __on_value_changed(self, params: dict, ctx: Any) -> None:
_LOGGER.debug('property changed, %s', params)
self._value = self.spec.value_format(params['value'])
self._value = self.spec.eval_expr(self._value)
value: Any = self.spec.value_format(params['value'])
value = self.spec.eval_expr(value)
self._value = self.spec.value_format(value)
if not self._pending_write_ha_state_timer:
self.async_write_ha_state()