mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Make matter import in google_assistant late to avoid blocking the event loop (#111335)
related issue https://github.com/home-assistant-libs/python-matter-server/issues/578
This commit is contained in:
parent
49ae81c5c4
commit
8645184dbf
@ -15,7 +15,7 @@ from aiohttp.web import json_response
|
|||||||
from awesomeversion import AwesomeVersion
|
from awesomeversion import AwesomeVersion
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
|
|
||||||
from homeassistant.components import matter, webhook
|
from homeassistant.components import webhook
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
ATTR_SUPPORTED_FEATURES,
|
ATTR_SUPPORTED_FEATURES,
|
||||||
@ -644,16 +644,19 @@ class GoogleEntity:
|
|||||||
return device
|
return device
|
||||||
|
|
||||||
# Add Matter info
|
# Add Matter info
|
||||||
if (
|
if "matter" in self.hass.config.components and any(
|
||||||
"matter" in self.hass.config.components
|
x for x in device_entry.identifiers if x[0] == "matter"
|
||||||
and any(x for x in device_entry.identifiers if x[0] == "matter")
|
|
||||||
and (
|
|
||||||
matter_info := matter.get_matter_device_info(self.hass, device_entry.id)
|
|
||||||
)
|
|
||||||
):
|
):
|
||||||
device["matterUniqueId"] = matter_info["unique_id"]
|
# pylint: disable-next=import-outside-toplevel
|
||||||
device["matterOriginalVendorId"] = matter_info["vendor_id"]
|
from homeassistant.components.matter import get_matter_device_info
|
||||||
device["matterOriginalProductId"] = matter_info["product_id"]
|
|
||||||
|
# Import matter can block the event loop for multiple seconds
|
||||||
|
# so we import it here to avoid blocking the event loop during
|
||||||
|
# setup since google_assistant is imported from cloud.
|
||||||
|
if matter_info := get_matter_device_info(self.hass, device_entry.id):
|
||||||
|
device["matterUniqueId"] = matter_info["unique_id"]
|
||||||
|
device["matterOriginalVendorId"] = matter_info["vendor_id"]
|
||||||
|
device["matterOriginalProductId"] = matter_info["product_id"]
|
||||||
|
|
||||||
# Add deviceInfo
|
# Add deviceInfo
|
||||||
device_info = {}
|
device_info = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user