diff --git a/homeassistant/components/steamist/entity.py b/homeassistant/components/steamist/entity.py index bd4755fef59..0a2bc239633 100644 --- a/homeassistant/components/steamist/entity.py +++ b/homeassistant/components/steamist/entity.py @@ -4,9 +4,12 @@ from __future__ import annotations from aiosteamist import SteamistStatus from homeassistant.config_entries import ConfigEntry -from homeassistant.helpers.entity import Entity, EntityDescription +from homeassistant.const import CONF_HOST, CONF_NAME +from homeassistant.helpers import device_registry as dr +from homeassistant.helpers.entity import DeviceInfo, Entity, EntityDescription from homeassistant.helpers.update_coordinator import CoordinatorEntity +from .const import CONF_MODEL from .coordinator import SteamistDataUpdateCoordinator @@ -27,6 +30,14 @@ class SteamistEntity(CoordinatorEntity, Entity): if coordinator.device_name: self._attr_name = f"{coordinator.device_name} {description.name}" self._attr_unique_id = f"{entry.entry_id}_{description.key}" + if entry.unique_id: # Only present if UDP broadcast works + self._attr_device_info = DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, entry.unique_id)}, + name=entry.data[CONF_NAME], + manufacturer="Steamist", + model=entry.data[CONF_MODEL], + configuration_url=f"http://{entry.data[CONF_HOST]}", + ) @property def _status(self) -> SteamistStatus: diff --git a/tests/components/steamist/test_init.py b/tests/components/steamist/test_init.py index 6758aacaf74..a40917cfc3c 100644 --- a/tests/components/steamist/test_init.py +++ b/tests/components/steamist/test_init.py @@ -12,6 +12,7 @@ from homeassistant.components.steamist.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.core import HomeAssistant +from homeassistant.helpers import device_registry as dr from homeassistant.setup import async_setup_component from homeassistant.util.dt import utcnow @@ -19,6 +20,7 @@ from . import ( DEFAULT_ENTRY_DATA, DEVICE_30303, DEVICE_IP_ADDRESS, + DEVICE_MODEL, DEVICE_NAME, FORMATTED_MAC_ADDRESS, MOCK_ASYNC_GET_STATUS_ACTIVE, @@ -101,6 +103,14 @@ async def test_config_entry_fills_unique_id_with_directed_discovery( assert config_entry.data[CONF_NAME] == DEVICE_NAME assert config_entry.title == DEVICE_NAME + device_registry = dr.async_get(hass) + device_entry = device_registry.async_get_device( + connections={(dr.CONNECTION_NETWORK_MAC, FORMATTED_MAC_ADDRESS)}, identifiers={} + ) + assert isinstance(device_entry, dr.DeviceEntry) + assert device_entry.name == DEVICE_NAME + assert device_entry.model == DEVICE_MODEL + @pytest.mark.usefixtures("mock_single_broadcast_address") async def test_discovery_happens_at_interval(hass: HomeAssistant) -> None: