mirror of
https://github.com/home-assistant/core.git
synced 2025-09-12 08:11:38 +02:00
Fix enphase_envoy non existing via device warning at first config. (#149010)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from pyenphase import Envoy
|
from pyenphase import Envoy
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
@@ -42,6 +44,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> b
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# register envoy before via_device is used
|
||||||
|
device_registry = dr.async_get(hass)
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
assert envoy.serial_number
|
||||||
|
device_registry.async_get_or_create(
|
||||||
|
config_entry_id=entry.entry_id,
|
||||||
|
identifiers={(DOMAIN, envoy.serial_number)},
|
||||||
|
manufacturer="Enphase",
|
||||||
|
name=coordinator.name,
|
||||||
|
model=envoy.envoy_model,
|
||||||
|
sw_version=str(envoy.firmware),
|
||||||
|
hw_version=envoy.part_number,
|
||||||
|
serial_number=envoy.serial_number,
|
||||||
|
)
|
||||||
|
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
Reference in New Issue
Block a user