mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add DeviceInfo to steamist (#63773)
This commit is contained in:
parent
7b3e5fdf9d
commit
a8a6e22063
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user