From dd85a97a484841dba96c8046a17e7287836823c6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 28 Feb 2024 23:09:48 -0500 Subject: [PATCH] get_matter_device_info: Test the Matter config entry is set up (#111792) Ensure the Matter config entry is set up --- homeassistant/components/matter/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/matter/__init__.py b/homeassistant/components/matter/__init__.py index aa89856074f..06c205859bb 100644 --- a/homeassistant/components/matter/__init__.py +++ b/homeassistant/components/matter/__init__.py @@ -1,4 +1,5 @@ """The Matter integration.""" + from __future__ import annotations import asyncio @@ -45,7 +46,10 @@ def get_matter_device_info( hass: HomeAssistant, device_id: str ) -> MatterDeviceInfo | None: """Return Matter device info or None if device does not exist.""" - if not (node := node_from_ha_device_id(hass, device_id)): + # Test hass.data[DOMAIN] to ensure config entry is set up + if not hass.data.get(DOMAIN, False) or not ( + node := node_from_ha_device_id(hass, device_id) + ): return None return MatterDeviceInfo(