Round Mold Indicator attributes (#43622)
This commit is contained in:
parent
ee8d88e85c
commit
73d2ae76a9
2 changed files with 12 additions and 6 deletions
|
@ -378,7 +378,10 @@ class MoldIndicator(Entity):
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
if self._is_metric:
|
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 = (
|
dewpoint = (
|
||||||
util.temperature.celsius_to_fahrenheit(self._dewpoint)
|
util.temperature.celsius_to_fahrenheit(self._dewpoint)
|
||||||
|
@ -392,4 +395,7 @@ class MoldIndicator(Entity):
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
return {ATTR_DEWPOINT: dewpoint, ATTR_CRITICAL_TEMP: crit_temp}
|
return {
|
||||||
|
ATTR_DEWPOINT: round(dewpoint, 2),
|
||||||
|
ATTR_CRITICAL_TEMP: round(crit_temp, 2),
|
||||||
|
}
|
||||||
|
|
|
@ -165,8 +165,8 @@ async def test_calculation(hass):
|
||||||
# assert dewpoint
|
# assert dewpoint
|
||||||
dewpoint = moldind.attributes.get(ATTR_DEWPOINT)
|
dewpoint = moldind.attributes.get(ATTR_DEWPOINT)
|
||||||
assert dewpoint
|
assert dewpoint
|
||||||
assert dewpoint > 9.25
|
assert dewpoint > 9.2
|
||||||
assert dewpoint < 9.26
|
assert dewpoint < 9.3
|
||||||
|
|
||||||
# assert temperature estimation
|
# assert temperature estimation
|
||||||
esttemp = moldind.attributes.get(ATTR_CRITICAL_TEMP)
|
esttemp = moldind.attributes.get(ATTR_CRITICAL_TEMP)
|
||||||
|
@ -246,8 +246,8 @@ async def test_unknown_sensor(hass):
|
||||||
|
|
||||||
dewpoint = moldind.attributes.get(ATTR_DEWPOINT)
|
dewpoint = moldind.attributes.get(ATTR_DEWPOINT)
|
||||||
assert dewpoint
|
assert dewpoint
|
||||||
assert dewpoint > 4.58
|
assert dewpoint > 4.5
|
||||||
assert dewpoint < 4.59
|
assert dewpoint < 4.6
|
||||||
|
|
||||||
esttemp = moldind.attributes.get(ATTR_CRITICAL_TEMP)
|
esttemp = moldind.attributes.get(ATTR_CRITICAL_TEMP)
|
||||||
assert esttemp
|
assert esttemp
|
||||||
|
|
Loading…
Add table
Reference in a new issue