Fixed wrong bound assignment on values below the lower bound

pull/13390/head
nielstron 2018-04-28 18:29:55 +02:00
parent bb98331ba4
commit 25f7c31911
2 changed files with 5 additions and 5 deletions

View File

@ -380,7 +380,7 @@ class RangeFilter(Filter):
_LOGGER.debug("Lower outlier nr. %s in %s: %s",
self._stats_internal['erasures_low'],
self._entity, new_state)
new_state.state = self._upper_bound
new_state.state = self._lower_bound
return new_state

View File

@ -141,14 +141,14 @@ class TestFilterSensor(unittest.TestCase):
lower_bound=lower,
upper_bound=upper)
for unf_state in self.values:
prev = float(unf_state.state)
unf = float(unf_state.state)
filtered = filt.filter_state(unf_state)
if prev < lower:
if unf < lower:
self.assertEqual(lower, filtered.state)
elif prev > upper:
elif unf > upper:
self.assertEqual(upper, filtered.state)
else:
self.assertEqual(prev, filtered.state)
self.assertEqual(unf, filtered.state)
def test_throttle(self):
"""Test if lowpass filter works."""