get_matter_device_info: Test the Matter config entry is set up (#111792)

Ensure the Matter config entry is set up
pull/112516/head
Paulus Schoutsen 2024-02-28 23:09:48 -05:00
parent b19b5dc451
commit dd85a97a48
1 changed files with 5 additions and 1 deletions

View File

@ -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(