mirror of
https://github.com/home-assistant/core.git
synced 2025-08-31 18:31:35 +02:00
Iaqualink: create parent device manually and link entities (#151215)
This commit is contained in:
@@ -24,6 +24,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
@@ -104,6 +105,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: AqualinkConfigEntry) ->
|
||||
f"Error while attempting to retrieve devices list: {svc_exception}"
|
||||
) from svc_exception
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
name=system.name,
|
||||
identifiers={(DOMAIN, system.serial)},
|
||||
manufacturer="Jandy",
|
||||
serial_number=system.serial,
|
||||
)
|
||||
|
||||
for dev in devices.values():
|
||||
if isinstance(dev, AqualinkThermostat):
|
||||
runtime_data.thermostats += [dev]
|
||||
|
@@ -29,6 +29,7 @@ class AqualinkEntity[AqualinkDeviceT: AqualinkDevice](Entity):
|
||||
self._attr_unique_id = f"{dev.system.serial}_{dev.name}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._attr_unique_id)},
|
||||
via_device=(DOMAIN, dev.system.serial),
|
||||
manufacturer=dev.manufacturer,
|
||||
model=dev.model,
|
||||
name=dev.label,
|
||||
|
@@ -43,6 +43,7 @@ def get_aqualink_system(aqualink, cls=None, data=None):
|
||||
data = {}
|
||||
|
||||
num = random.randint(0, 99999)
|
||||
data["name"] = "Pool"
|
||||
data["serial_number"] = f"SN{num:05}"
|
||||
|
||||
return cls(aqualink=aqualink, data=data)
|
||||
|
Reference in New Issue
Block a user