Add precision_hint to feature (#871)

This can be used to hint how the sensor value should be rounded when
displaying it to users.

The values are adapted from the values used by homeassistant.
This commit is contained in:
Teemu R
2024-04-29 13:31:42 +02:00
committed by GitHub
parent fe6b1892cc
commit d7a36fe071
4 changed files with 29 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ class EnergyModule(SmartModule):
attribute_getter="current_power",
container=self,
unit="W",
precision_hint=1,
)
)
self._add_feature(
@@ -35,6 +36,7 @@ class EnergyModule(SmartModule):
attribute_getter="emeter_today",
container=self,
unit="Wh",
precision_hint=2,
)
)
self._add_feature(
@@ -44,6 +46,7 @@ class EnergyModule(SmartModule):
attribute_getter="emeter_this_month",
container=self,
unit="Wh",
precision_hint=2,
)
)