mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix flaky Tailwind tests by fixing via_device (#106294)
This commit is contained in:
parent
1d0cee5e8a
commit
3404bd4de5
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import TailwindDataUpdateCoordinator
|
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()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
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)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Base entity for the Tailwind integration."""
|
"""Base entity for the Tailwind integration."""
|
||||||
from __future__ import annotations
|
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.entity import EntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
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_unique_id = f"{coordinator.data.device_id}-{entity_description.key}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, coordinator.data.device_id)},
|
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,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@
|
|||||||
'serial_number': None,
|
'serial_number': None,
|
||||||
'suggested_area': None,
|
'suggested_area': None,
|
||||||
'sw_version': '10.10',
|
'sw_version': '10.10',
|
||||||
'via_device_id': None,
|
'via_device_id': <ANY>,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_number_entities[binary_sensor.door_2_operational_status]
|
# name: test_number_entities[binary_sensor.door_2_operational_status]
|
||||||
@ -284,6 +284,6 @@
|
|||||||
'serial_number': None,
|
'serial_number': None,
|
||||||
'suggested_area': None,
|
'suggested_area': None,
|
||||||
'sw_version': '10.10',
|
'sw_version': '10.10',
|
||||||
'via_device_id': None,
|
'via_device_id': <ANY>,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
'serial_number': None,
|
'serial_number': None,
|
||||||
'suggested_area': None,
|
'suggested_area': None,
|
||||||
'sw_version': '10.10',
|
'sw_version': '10.10',
|
||||||
'via_device_id': None,
|
'via_device_id': <ANY>,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_cover_entities[cover.door_2]
|
# name: test_cover_entities[cover.door_2]
|
||||||
@ -142,6 +142,6 @@
|
|||||||
'serial_number': None,
|
'serial_number': None,
|
||||||
'suggested_area': None,
|
'suggested_area': None,
|
||||||
'sw_version': '10.10',
|
'sw_version': '10.10',
|
||||||
'via_device_id': None,
|
'via_device_id': <ANY>,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
Loading…
x
Reference in New Issue
Block a user