Do not show graphite warnings if no new_state in event (#36292)

It is not correct to show warning about "unexpected event type" if EVENT_STATE_CHANGED have no new_state field.
We should show this warning only if it is real unexpected event type.
Run task_done() before continue, because we should tell the queue that the processing on the task is complete
  after get().
This commit is contained in:
Igor 2020-05-31 20:58:02 +03:00 committed by GitHub
parent 7197ef76a6
commit 6ed68d8ced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,7 +139,16 @@ class GraphiteFeeder(threading.Thread):
_LOGGER.debug("Event processing thread stopped")
self._queue.task_done()
return
if event.event_type == EVENT_STATE_CHANGED and event.data.get("new_state"):
if event.event_type == EVENT_STATE_CHANGED:
if not event.data.get("new_state"):
_LOGGER.debug(
"Skipping %s without new_state for %s",
event.event_type,
event.data["entity_id"],
)
self._queue.task_done()
continue
_LOGGER.debug(
"Processing STATE_CHANGED event for %s", event.data["entity_id"]
)