From 5bba299e8fa8440708ea871ac16f819e5897214b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 23 Oct 2020 10:38:46 -0500 Subject: [PATCH] Ensure event listener integrations do the queue insert as a callback (#42265) --- homeassistant/components/influxdb/__init__.py | 2 ++ homeassistant/components/watson_iot/__init__.py | 2 ++ homeassistant/components/zabbix/__init__.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/homeassistant/components/influxdb/__init__.py b/homeassistant/components/influxdb/__init__.py index 5696424b402..16b6971b11f 100644 --- a/homeassistant/components/influxdb/__init__.py +++ b/homeassistant/components/influxdb/__init__.py @@ -26,6 +26,7 @@ from homeassistant.const import ( STATE_UNAVAILABLE, STATE_UNKNOWN, ) +from homeassistant.core import callback from homeassistant.helpers import event as event_helper, state as state_helper import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_values import EntityValues @@ -500,6 +501,7 @@ class InfluxThread(threading.Thread): self.shutdown = False hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener) + @callback def _event_listener(self, event): """Listen for new messages on the bus and queue them for Influx.""" item = (time.monotonic(), event) diff --git a/homeassistant/components/watson_iot/__init__.py b/homeassistant/components/watson_iot/__init__.py index ecb546f4a8c..99f6b63ec90 100644 --- a/homeassistant/components/watson_iot/__init__.py +++ b/homeassistant/components/watson_iot/__init__.py @@ -21,6 +21,7 @@ from homeassistant.const import ( STATE_UNAVAILABLE, STATE_UNKNOWN, ) +from homeassistant.core import callback from homeassistant.helpers import state as state_helper import homeassistant.helpers.config_validation as cv @@ -165,6 +166,7 @@ class WatsonIOTThread(threading.Thread): self.shutdown = False hass.bus.listen(EVENT_STATE_CHANGED, self._event_listener) + @callback def _event_listener(self, event): """Listen for new messages on the bus and queue them for Watson IoT.""" item = (time.monotonic(), event) diff --git a/homeassistant/components/zabbix/__init__.py b/homeassistant/components/zabbix/__init__.py index 0afe8050d63..b9d02731570 100644 --- a/homeassistant/components/zabbix/__init__.py +++ b/homeassistant/components/zabbix/__init__.py @@ -22,6 +22,7 @@ from homeassistant.const import ( STATE_UNAVAILABLE, STATE_UNKNOWN, ) +from homeassistant.core import callback from homeassistant.helpers import event as event_helper, state as state_helper import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entityfilter import ( @@ -186,6 +187,7 @@ class ZabbixThread(threading.Thread): self.queue.put(None) self.join() + @callback def _event_listener(self, event): """Listen for new messages on the bus and queue them for Zabbix.""" item = (time.monotonic(), event)