make sure its set right away when adding the device

This commit is contained in:
J. Nick Koston
2024-02-06 15:56:49 -06:00
parent c09ec8d620
commit 4f9cf6c234

View File

@@ -376,13 +376,9 @@ class DlnaDmrEntity(MediaPlayerEntity):
if not self._device: if not self._device:
return # Can't get all the required information without a connection return # Can't get all the required information without a connection
if not self.registry_entry or not self.registry_entry.config_entry_id: if not set_mac and self._updated_registry:
return # No config registry entry to link to
if self.registry_entry.device_id and not set_mac and self._updated_registry:
return # No new information return # No new information
self._updated_registry = True
# Connections based on the root device's UDN, and the DMR embedded # Connections based on the root device's UDN, and the DMR embedded
# device's UDN. They may be the same, if the DMR is the root device. # device's UDN. They may be the same, if the DMR is the root device.
connections = { connections = {
@@ -404,6 +400,18 @@ class DlnaDmrEntity(MediaPlayerEntity):
(dr.CONNECTION_NETWORK_MAC, self.mac_address) (dr.CONNECTION_NETWORK_MAC, self.mac_address)
) )
self._attr_device_info = dr.DeviceInfo(
connections=connections,
default_manufacturer=self._device.manufacturer,
default_model=self._device.model_name,
default_name=self._device.name,
)
if not self.registry_entry or not self.registry_entry.config_entry_id:
# No config registry entry to update
return
self._updated_registry = True
# Create linked HA DeviceEntry now the information is known. # Create linked HA DeviceEntry now the information is known.
dev_reg = dr.async_get(self.hass) dev_reg = dr.async_get(self.hass)
device_entry = dev_reg.async_get_or_create( device_entry = dev_reg.async_get_or_create(
@@ -423,13 +431,6 @@ class DlnaDmrEntity(MediaPlayerEntity):
device_id=device_entry.id, device_id=device_entry.id,
) )
self._attr_device_info = dr.DeviceInfo(
connections=connections,
default_manufacturer=self._device.manufacturer,
default_model=self._device.model_name,
default_name=self._device.name,
)
async def _device_disconnect(self) -> None: async def _device_disconnect(self) -> None:
"""Destroy connections to the device now that it's not available. """Destroy connections to the device now that it's not available.