diff --git a/homeassistant/components/graphite.py b/homeassistant/components/graphite.py index 0b45714074a..662e3872eee 100644 --- a/homeassistant/components/graphite.py +++ b/homeassistant/components/graphite.py @@ -110,7 +110,7 @@ class GraphiteFeeder(threading.Thread): self._queue.task_done() return elif (event.event_type == EVENT_STATE_CHANGED and - 'new_state' in event.data): + event.data.get('new_state')): self._report_attributes(event.data['entity_id'], event.data['new_state']) self._queue.task_done() diff --git a/tests/components/test_graphite.py b/tests/components/test_graphite.py index 746e72f04c6..14803d885d4 100644 --- a/tests/components/test_graphite.py +++ b/tests/components/test_graphite.py @@ -171,7 +171,8 @@ class TestGraphite(unittest.TestCase): return self.gf._quit_object elif runs: runs.append(1) - return mock.MagicMock(event_type='somethingelse') + return mock.MagicMock(event_type='somethingelse', + data={'new_event': None}) else: runs.append(1) return event