mirror of
https://github.com/home-assistant/core.git
synced 2026-04-28 04:33:49 +01:00
Allow customizing sensor state precision (#86074)
* Allow customizing sensor precision * Don't convert integer strings to floats * Tweak converting sensor state to number * Drop default rounding to 2 decimals * Adjust test * Tweak rounding, improve test coverage * Don't convert to a number if not necessary * Raise if native_precision is set and state is not numeric * Address review comments * Address comments, simplify * Don't call property twice * Make exception more helpful
This commit is contained in:
@@ -98,6 +98,11 @@ class MockSensor(MockEntity, SensorEntity):
|
||||
"""Return the last_reset of this sensor."""
|
||||
return self._handle("last_reset")
|
||||
|
||||
@property
|
||||
def native_precision(self):
|
||||
"""Return the number of digits after the decimal point."""
|
||||
return self._handle("native_precision")
|
||||
|
||||
@property
|
||||
def native_unit_of_measurement(self):
|
||||
"""Return the native unit_of_measurement of this sensor."""
|
||||
|
||||
Reference in New Issue
Block a user