Round Mold Indicator attributes (#43622)

This commit is contained in:
Yuval Aboulafia 2021-01-27 00:14:53 +02:00 committed by GitHub
parent ee8d88e85c
commit 73d2ae76a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -378,7 +378,10 @@ class MoldIndicator(Entity):
def device_state_attributes(self):
"""Return the state attributes."""
if self._is_metric:
return {ATTR_DEWPOINT: self._dewpoint, ATTR_CRITICAL_TEMP: self._crit_temp}
return {
ATTR_DEWPOINT: round(self._dewpoint, 2),
ATTR_CRITICAL_TEMP: round(self._crit_temp, 2),
}
dewpoint = (
util.temperature.celsius_to_fahrenheit(self._dewpoint)
@ -392,4 +395,7 @@ class MoldIndicator(Entity):
else None
)
return {ATTR_DEWPOINT: dewpoint, ATTR_CRITICAL_TEMP: crit_temp}
return {
ATTR_DEWPOINT: round(dewpoint, 2),
ATTR_CRITICAL_TEMP: round(crit_temp, 2),
}

View file

@ -165,8 +165,8 @@ async def test_calculation(hass):
# assert dewpoint
dewpoint = moldind.attributes.get(ATTR_DEWPOINT)
assert dewpoint
assert dewpoint > 9.25
assert dewpoint < 9.26
assert dewpoint > 9.2
assert dewpoint < 9.3
# assert temperature estimation
esttemp = moldind.attributes.get(ATTR_CRITICAL_TEMP)
@ -246,8 +246,8 @@ async def test_unknown_sensor(hass):
dewpoint = moldind.attributes.get(ATTR_DEWPOINT)
assert dewpoint
assert dewpoint > 4.58
assert dewpoint < 4.59
assert dewpoint > 4.5
assert dewpoint < 4.6
esttemp = moldind.attributes.get(ATTR_CRITICAL_TEMP)
assert esttemp