|
15 | 15 | from homeassistant.const import CONF_SCAN_INTERVAL |
16 | 16 | from homeassistant.core import HomeAssistant |
17 | 17 | from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady |
18 | | -from homeassistant.helpers import aiohttp_client |
19 | | -from homeassistant.helpers.device_registry import DeviceEntry |
| 18 | +from homeassistant.helpers import aiohttp_client, device_registry as dr |
20 | 19 | from homeassistant.helpers.dispatcher import async_dispatcher_send |
21 | 20 |
|
22 | 21 | from .const import DOMAIN, PLATFORM_LOOKUP, PLATFORMS |
@@ -47,6 +46,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: HiveConfigEntry) -> bool |
47 | 46 | except HiveReauthRequired as err: |
48 | 47 | raise ConfigEntryAuthFailed from err |
49 | 48 |
|
| 49 | + device_registry = dr.async_get(hass) |
| 50 | + device_registry.async_get_or_create( |
| 51 | + config_entry_id=entry.entry_id, |
| 52 | + identifiers={(DOMAIN, devices["parent"][0]["device_id"])}, |
| 53 | + name=devices["parent"][0]["hiveName"], |
| 54 | + model=devices["parent"][0]["deviceData"]["model"], |
| 55 | + sw_version=devices["parent"][0]["deviceData"]["version"], |
| 56 | + manufacturer=devices["parent"][0]["deviceData"]["manufacturer"], |
| 57 | + ) |
| 58 | + |
50 | 59 | await hass.config_entries.async_forward_entry_setups( |
51 | 60 | entry, |
52 | 61 | [ |
@@ -74,7 +83,7 @@ async def async_remove_entry(hass: HomeAssistant, entry: HiveConfigEntry) -> Non |
74 | 83 |
|
75 | 84 |
|
76 | 85 | async def async_remove_config_entry_device( |
77 | | - hass: HomeAssistant, config_entry: HiveConfigEntry, device_entry: DeviceEntry |
| 86 | + hass: HomeAssistant, config_entry: HiveConfigEntry, device_entry: dr.DeviceEntry |
78 | 87 | ) -> bool: |
79 | 88 | """Remove a config entry from a device.""" |
80 | 89 | return True |
|
0 commit comments