Skip to content

Commit 6eefb11

Browse files
authored
Merge pull request #135 from c-st/precision
Set suggested precision for sensors
2 parents d8cdd52 + 85ec036 commit 6eefb11

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.ruff.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
target-version = "py310"
44

5+
[lint]
56
select = [
67
"B007", # Loop control variable {name} not used within loop body
78
"B014", # Exception handler with duplicate exception
@@ -25,7 +26,6 @@ select = [
2526
"UP", # pyupgrade
2627
"W", # pycodestyle
2728
]
28-
2929
ignore = [
3030
"D202", # No blank lines allowed after function docstring
3131
"D203", # 1 blank line required before class docstring
@@ -39,9 +39,5 @@ ignore = [
3939
"UP006",
4040
"UP007",
4141
]
42-
43-
[flake8-pytest-style]
44-
fixture-parentheses = false
45-
46-
[mccabe]
47-
max-complexity = 25
42+
mccabe.max-complexity = 25
43+
flake8-pytest-style.fixture-parentheses = false

custom_components/auto_areas/auto_entity.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def device_info(self) -> DeviceInfo:
9191
"suggested_area": self.auto_area.area_name,
9292
}
9393

94+
@cached_property
95+
def suggested_display_precision(self) -> int | None:
96+
"""Set the suggested precision (0.12)."""
97+
return 2
98+
9499
async def async_added_to_hass(self):
95100
"""Start tracking sensors."""
96101
LOGGER.debug(

custom_components/auto_areas/sensors/illuminance.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def native_unit_of_measurement(self) -> str | None:
3636
"""Return unit of measurement."""
3737
return LIGHT_LUX
3838

39+
@override
40+
@cached_property
41+
def suggested_display_precision(self) -> int | None:
42+
"""Set the suggested precision (0)."""
43+
return 0
44+
3945
@property
4046
def state(self) -> Any: # type: ignore
4147
"""Return the state of the entity."""

0 commit comments

Comments
 (0)