feat: format value, then evaluate by expression, and set precision at last (#1516)

This commit is contained in:
Li Shuzhen
2025-11-25 09:31:40 +08:00
committed by GitHub
parent 1b87381f43
commit e6750bb746
3 changed files with 26 additions and 9 deletions

View File

@@ -110,7 +110,7 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
self._attr_native_unit_of_measurement = list(
unit_sets)[0] if unit_sets else None
# Set suggested precision
if spec.format_ in {int, float} and spec.expr is None:
if spec.format_ == float:
self._attr_suggested_display_precision = spec.precision
# Set state_class
if spec.state_class: