diff --git a/homeassistant/components/tailwind/__init__.py b/homeassistant/components/tailwind/__init__.py index b71fd1cd0fc..f4772050e5a 100644 --- a/homeassistant/components/tailwind/__init__.py +++ b/homeassistant/components/tailwind/__init__.py @@ -4,6 +4,7 @@ from __future__ import annotations from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant +from homeassistant.helpers import device_registry as dr from .const import DOMAIN from .coordinator import TailwindDataUpdateCoordinator @@ -17,6 +18,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await coordinator.async_config_entry_first_refresh() hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator + + # Register the Tailwind device, since other entities will have it as a parent. + # This prevents a child device being created before the parent ending up + # with a missing via_device. + device_registry = dr.async_get(hass) + device_registry.async_get_or_create( + config_entry_id=entry.entry_id, + identifiers={(DOMAIN, coordinator.data.device_id)}, + connections={(dr.CONNECTION_NETWORK_MAC, coordinator.data.mac_address)}, + manufacturer="Tailwind", + model=coordinator.data.product, + sw_version=coordinator.data.firmware_version, + ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) return True diff --git a/homeassistant/components/tailwind/entity.py b/homeassistant/components/tailwind/entity.py index a97d74490dc..843cc600582 100644 --- a/homeassistant/components/tailwind/entity.py +++ b/homeassistant/components/tailwind/entity.py @@ -1,7 +1,7 @@ """Base entity for the Tailwind integration.""" from __future__ import annotations -from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo +from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity import EntityDescription from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -25,10 +25,6 @@ class TailwindEntity(CoordinatorEntity[TailwindDataUpdateCoordinator]): self._attr_unique_id = f"{coordinator.data.device_id}-{entity_description.key}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, coordinator.data.device_id)}, - connections={(CONNECTION_NETWORK_MAC, coordinator.data.mac_address)}, - manufacturer="Tailwind", - model=coordinator.data.product, - sw_version=coordinator.data.firmware_version, ) diff --git a/tests/components/tailwind/snapshots/test_binary_sensor.ambr b/tests/components/tailwind/snapshots/test_binary_sensor.ambr index e3da11f28d1..68a503e7fc0 100644 --- a/tests/components/tailwind/snapshots/test_binary_sensor.ambr +++ b/tests/components/tailwind/snapshots/test_binary_sensor.ambr @@ -212,7 +212,7 @@ 'serial_number': None, 'suggested_area': None, 'sw_version': '10.10', - 'via_device_id': None, + 'via_device_id': , }) # --- # name: test_number_entities[binary_sensor.door_2_operational_status] @@ -284,6 +284,6 @@ 'serial_number': None, 'suggested_area': None, 'sw_version': '10.10', - 'via_device_id': None, + 'via_device_id': , }) # --- diff --git a/tests/components/tailwind/snapshots/test_cover.ambr b/tests/components/tailwind/snapshots/test_cover.ambr index 4e94c1084e4..e5d6306778f 100644 --- a/tests/components/tailwind/snapshots/test_cover.ambr +++ b/tests/components/tailwind/snapshots/test_cover.ambr @@ -69,7 +69,7 @@ 'serial_number': None, 'suggested_area': None, 'sw_version': '10.10', - 'via_device_id': None, + 'via_device_id': , }) # --- # name: test_cover_entities[cover.door_2] @@ -142,6 +142,6 @@ 'serial_number': None, 'suggested_area': None, 'sw_version': '10.10', - 'via_device_id': None, + 'via_device_id': , }) # ---