Added 'change' field to statistics sensor (#7820)

* Added 'change' field to statistics sensor

* Updated statistics sensor test

* Updated statistics sensor test complaint
This commit is contained in:
Jacob Minnis authored and Pascal Vizeli committed 2017-06-07 09:38:00 +02:00
1 parent 5504a511e3
commit bb6fe822f9
2 files changed
+17 -2

No files matched your search

@@ -22,6 +22,8 @@ class TestStatisticsSensor(unittest.TestCase):
self.median = round(statistics.median(self.values), 2)
self.deviation = round(statistics.stdev(self.values), 2)
self.variance = round(statistics.variance(self.values), 2)
self.change = self.values[-1] - self.values[0]
self.average_change = self.change / (len(self.values) - 1)
def teardown_method(self, method):
"""Stop everything that was started."""
@@ -74,6 +76,9 @@ class TestStatisticsSensor(unittest.TestCase):
self.assertEqual(self.count, state.attributes.get('count'))
self.assertEqual(self.total, state.attributes.get('total'))
self.assertEqual('°C', state.attributes.get('unit_of_measurement'))
self.assertEqual(self.change, state.attributes.get('change'))
self.assertEqual(self.average_change,
state.attributes.get('average_change'))
def test_sampling_size(self):
"""Test rotation."""