Skip to content

Commit

Permalink
get_matter_device_info: Test the Matter config entry is set up (#111792)
Browse files Browse the repository at this point in the history
Ensure the Matter config entry is set up
  • Loading branch information
balloob committed Feb 29, 2024
1 parent b19b5dc commit dd85a97
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion homeassistant/components/matter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Matter integration."""

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit dd85a97

Please sign in to comment.