diff --git a/homeassistant/components/dlna_dmr/media_player.py b/homeassistant/components/dlna_dmr/media_player.py index eddb2633bea..50877756d52 100644 --- a/homeassistant/components/dlna_dmr/media_player.py +++ b/homeassistant/components/dlna_dmr/media_player.py @@ -37,7 +37,6 @@ from .const import ( CONF_CALLBACK_URL_OVERRIDE, CONF_LISTEN_PORT, CONF_POLL_AVAILABILITY, - DOMAIN, LOGGER as _LOGGER, MEDIA_METADATA_DIDL, MEDIA_TYPE_MAP, @@ -381,7 +380,6 @@ class DlnaDmrEntity(MediaPlayerEntity): device_entry = dev_reg.async_get_or_create( config_entry_id=self.registry_entry.config_entry_id, connections=connections, - identifiers={(DOMAIN, self.unique_id)}, default_manufacturer=self._device.manufacturer, default_model=self._device.model_name, default_name=self._device.name, diff --git a/tests/components/dlna_dmr/test_media_player.py b/tests/components/dlna_dmr/test_media_player.py index e07e0b6cfcb..f8413e8f620 100644 --- a/tests/components/dlna_dmr/test_media_player.py +++ b/tests/components/dlna_dmr/test_media_player.py @@ -50,6 +50,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import ( CONNECTION_NETWORK_MAC, + CONNECTION_UPNP, async_get as async_get_dr, ) from homeassistant.helpers.entity_component import async_update_entity @@ -347,7 +348,10 @@ async def test_setup_entry_mac_address( # Check the device registry connections for MAC address dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is not None assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) in device.connections @@ -364,7 +368,10 @@ async def test_setup_entry_no_mac_address( # Check the device registry connections does not include the MAC address dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is not None assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) not in device.connections @@ -427,7 +434,10 @@ async def test_available_device( """Test a DlnaDmrEntity with a connected DmrDevice.""" # Check hass device information is filled in dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is not None # Device properties are set in dmr_device_mock before the entity gets constructed assert device.manufacturer == "device_manufacturer" @@ -1323,7 +1333,10 @@ async def test_unavailable_device( # Check hass device information has not been filled in yet dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is None # Unload config entry to clean up @@ -1360,7 +1373,10 @@ async def test_become_available( # Check hass device information has not been filled in yet dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is None # Mock device is now available. @@ -1399,7 +1415,10 @@ async def test_become_available( assert mock_state.state == MediaPlayerState.IDLE # Check hass device information is now filled in dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is not None assert device.manufacturer == "device_manufacturer" assert device.model == "device_model_name" @@ -2231,7 +2250,10 @@ async def test_config_update_mac_address( # Check the device registry connections does not include the MAC address dev_reg = async_get_dr(hass) - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is not None assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) not in device.connections @@ -2248,6 +2270,9 @@ async def test_config_update_mac_address( await hass.async_block_till_done() # Device registry connections should now include the MAC address - device = dev_reg.async_get_device(identifiers={(DLNA_DOMAIN, MOCK_DEVICE_UDN)}) + device = dev_reg.async_get_device( + connections={(CONNECTION_UPNP, MOCK_DEVICE_UDN)}, + identifiers=set(), + ) assert device is not None assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) in device.connections