Fix Withings via_device race causing flaky test_devices (#169347)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.config_entry_oauth2_flow import (
|
||||
ImplementationUnavailableError,
|
||||
@@ -152,6 +153,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: WithingsConfigEntry) ->
|
||||
for coordinator in withings_data.coordinators:
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, str(entry.unique_id))},
|
||||
manufacturer="Withings",
|
||||
)
|
||||
entry.runtime_data = withings_data
|
||||
|
||||
webhook_manager = WithingsWebhookManager(hass, entry)
|
||||
|
||||
@@ -31,7 +31,6 @@ class WithingsEntity[_T: WithingsDataUpdateCoordinator[Any]](CoordinatorEntity[_
|
||||
self._attr_unique_id = f"withings_{coordinator.config_entry.unique_id}_{key}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, str(coordinator.config_entry.unique_id))},
|
||||
manufacturer="Withings",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user