mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Correct dlna_dmr device info (#96480)
This commit is contained in:
parent
5b93017740
commit
8440f14a08
@ -37,7 +37,6 @@ from .const import (
|
|||||||
CONF_CALLBACK_URL_OVERRIDE,
|
CONF_CALLBACK_URL_OVERRIDE,
|
||||||
CONF_LISTEN_PORT,
|
CONF_LISTEN_PORT,
|
||||||
CONF_POLL_AVAILABILITY,
|
CONF_POLL_AVAILABILITY,
|
||||||
DOMAIN,
|
|
||||||
LOGGER as _LOGGER,
|
LOGGER as _LOGGER,
|
||||||
MEDIA_METADATA_DIDL,
|
MEDIA_METADATA_DIDL,
|
||||||
MEDIA_TYPE_MAP,
|
MEDIA_TYPE_MAP,
|
||||||
@ -381,7 +380,6 @@ class DlnaDmrEntity(MediaPlayerEntity):
|
|||||||
device_entry = dev_reg.async_get_or_create(
|
device_entry = dev_reg.async_get_or_create(
|
||||||
config_entry_id=self.registry_entry.config_entry_id,
|
config_entry_id=self.registry_entry.config_entry_id,
|
||||||
connections=connections,
|
connections=connections,
|
||||||
identifiers={(DOMAIN, self.unique_id)},
|
|
||||||
default_manufacturer=self._device.manufacturer,
|
default_manufacturer=self._device.manufacturer,
|
||||||
default_model=self._device.model_name,
|
default_model=self._device.model_name,
|
||||||
default_name=self._device.name,
|
default_name=self._device.name,
|
||||||
|
@ -50,6 +50,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import (
|
from homeassistant.helpers.device_registry import (
|
||||||
CONNECTION_NETWORK_MAC,
|
CONNECTION_NETWORK_MAC,
|
||||||
|
CONNECTION_UPNP,
|
||||||
async_get as async_get_dr,
|
async_get as async_get_dr,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity_component import async_update_entity
|
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
|
# Check the device registry connections for MAC address
|
||||||
dev_reg = async_get_dr(hass)
|
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 is not None
|
||||||
assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) in device.connections
|
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
|
# Check the device registry connections does not include the MAC address
|
||||||
dev_reg = async_get_dr(hass)
|
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 is not None
|
||||||
assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) not in device.connections
|
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."""
|
"""Test a DlnaDmrEntity with a connected DmrDevice."""
|
||||||
# Check hass device information is filled in
|
# Check hass device information is filled in
|
||||||
dev_reg = async_get_dr(hass)
|
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 is not None
|
||||||
# Device properties are set in dmr_device_mock before the entity gets constructed
|
# Device properties are set in dmr_device_mock before the entity gets constructed
|
||||||
assert device.manufacturer == "device_manufacturer"
|
assert device.manufacturer == "device_manufacturer"
|
||||||
@ -1323,7 +1333,10 @@ async def test_unavailable_device(
|
|||||||
|
|
||||||
# Check hass device information has not been filled in yet
|
# Check hass device information has not been filled in yet
|
||||||
dev_reg = async_get_dr(hass)
|
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
|
assert device is None
|
||||||
|
|
||||||
# Unload config entry to clean up
|
# 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
|
# Check hass device information has not been filled in yet
|
||||||
dev_reg = async_get_dr(hass)
|
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
|
assert device is None
|
||||||
|
|
||||||
# Mock device is now available.
|
# Mock device is now available.
|
||||||
@ -1399,7 +1415,10 @@ async def test_become_available(
|
|||||||
assert mock_state.state == MediaPlayerState.IDLE
|
assert mock_state.state == MediaPlayerState.IDLE
|
||||||
# Check hass device information is now filled in
|
# Check hass device information is now filled in
|
||||||
dev_reg = async_get_dr(hass)
|
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 is not None
|
||||||
assert device.manufacturer == "device_manufacturer"
|
assert device.manufacturer == "device_manufacturer"
|
||||||
assert device.model == "device_model_name"
|
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
|
# Check the device registry connections does not include the MAC address
|
||||||
dev_reg = async_get_dr(hass)
|
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 is not None
|
||||||
assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) not in device.connections
|
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()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# Device registry connections should now include the MAC address
|
# 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 device is not None
|
||||||
assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) in device.connections
|
assert (CONNECTION_NETWORK_MAC, MOCK_MAC_ADDRESS) in device.connections
|
||||||
|
Loading…
x
Reference in New Issue
Block a user