mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
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:
@@ -23,6 +23,7 @@ class Emeter(Usage):
|
||||
container=self,
|
||||
unit="W",
|
||||
id="current_power_w", # for homeassistant backwards compat
|
||||
precision_hint=1,
|
||||
)
|
||||
)
|
||||
self._add_feature(
|
||||
@@ -33,6 +34,7 @@ class Emeter(Usage):
|
||||
container=self,
|
||||
unit="kWh",
|
||||
id="today_energy_kwh", # for homeassistant backwards compat
|
||||
precision_hint=3,
|
||||
)
|
||||
)
|
||||
self._add_feature(
|
||||
@@ -42,6 +44,7 @@ class Emeter(Usage):
|
||||
attribute_getter="emeter_this_month",
|
||||
container=self,
|
||||
unit="kWh",
|
||||
precision_hint=3,
|
||||
)
|
||||
)
|
||||
self._add_feature(
|
||||
@@ -52,6 +55,7 @@ class Emeter(Usage):
|
||||
container=self,
|
||||
unit="kWh",
|
||||
id="total_energy_kwh", # for homeassistant backwards compat
|
||||
precision_hint=3,
|
||||
)
|
||||
)
|
||||
self._add_feature(
|
||||
@@ -62,6 +66,7 @@ class Emeter(Usage):
|
||||
container=self,
|
||||
unit="V",
|
||||
id="voltage", # for homeassistant backwards compat
|
||||
precision_hint=1,
|
||||
)
|
||||
)
|
||||
self._add_feature(
|
||||
@@ -72,6 +77,7 @@ class Emeter(Usage):
|
||||
container=self,
|
||||
unit="A",
|
||||
id="current_a", # for homeassistant backwards compat
|
||||
precision_hint=2,
|
||||
)
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user