From 761943e1e67a34d3395f6f095caa1b9b912fb8b1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 23 May 2023 11:56:27 -0500 Subject: [PATCH] Fix non threadsafe call xiaomi_aqara (#93405) --- homeassistant/components/xiaomi_aqara/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/xiaomi_aqara/__init__.py b/homeassistant/components/xiaomi_aqara/__init__.py index be6eba6793e..f51b1a2972b 100644 --- a/homeassistant/components/xiaomi_aqara/__init__.py +++ b/homeassistant/components/xiaomi_aqara/__init__.py @@ -2,6 +2,7 @@ import asyncio from datetime import timedelta import logging +from typing import Any import voluptuous as vol from xiaomi_gateway import AsyncXiaomiGatewayMulticast, XiaomiGateway @@ -351,9 +352,13 @@ class XiaomiDevice(Entity): return True return False + def push_data(self, data: dict[str, Any], raw_data: dict[Any, Any]) -> None: + """Push from Hub running in another thread.""" + self.hass.loop.call_soon(self.async_push_data, data, raw_data) + @callback - def push_data(self, data, raw_data): - """Push from Hub.""" + def async_push_data(self, data: dict[str, Any], raw_data: dict[Any, Any]) -> None: + """Push from Hub handled in the event loop.""" _LOGGER.debug("PUSH >> %s: %s", self, data) was_unavailable = self._async_track_unavailable() is_data = self.parse_data(data, raw_data)