Skip to content

Commit acb6dc9

Browse files
authored
Hive fix via_device warning (home-assistant#156173)
1 parent 463796f commit acb6dc9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

homeassistant/components/hive/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
from homeassistant.const import CONF_SCAN_INTERVAL
1616
from homeassistant.core import HomeAssistant
1717
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
2019
from homeassistant.helpers.dispatcher import async_dispatcher_send
2120

2221
from .const import DOMAIN, PLATFORM_LOOKUP, PLATFORMS
@@ -47,6 +46,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: HiveConfigEntry) -> bool
4746
except HiveReauthRequired as err:
4847
raise ConfigEntryAuthFailed from err
4948

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+
5059
await hass.config_entries.async_forward_entry_setups(
5160
entry,
5261
[
@@ -74,7 +83,7 @@ async def async_remove_entry(hass: HomeAssistant, entry: HiveConfigEntry) -> Non
7483

7584

7685
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
7887
) -> bool:
7988
"""Remove a config entry from a device."""
8089
return True

0 commit comments

Comments
 (0)