Fix wrong comparison

This commit is contained in:
nielstron 2018-04-28 17:51:04 +02:00
parent f4ef8fd1bc
commit 07d139b3a8
2 changed files with 5 additions and 4 deletions

View file

@ -374,7 +374,7 @@ class RangeFilter(Filter):
self._entity, new_state)
new_state.state = self._upper_bound
elif new_state < self._lower_bound:
elif new_state.state < self._lower_bound:
self._stats_internal['erasures_low'] += 1

View file

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