|
|
@@ -40,7 +40,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
"""Set up this integration using UI."""
|
|
|
hass.data.setdefault(DOMAIN, {})
|
|
|
|
|
|
- endpoint = entry.data.get(CONF_IP_ADDRESS)
|
|
|
+ ip = entry.data.get(CONF_IP_ADDRESS)
|
|
|
user = entry.data.get(CONF_USERNAME)
|
|
|
password = entry.data.get(CONF_PASSWORD)
|
|
|
scan_interval_seconds = entry.options.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
|
|
|
@@ -48,7 +48,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
scan_interval = timedelta(seconds=scan_interval_seconds)
|
|
|
|
|
|
session = async_get_clientsession(hass)
|
|
|
- client = RouterApiClient(endpoint=endpoint,
|
|
|
+ client = RouterApiClient(ip=ip,
|
|
|
user=user,
|
|
|
password=password,
|
|
|
session=session)
|
|
|
@@ -65,7 +65,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
info = data['DeviceInfo']
|
|
|
|
|
|
device_info = DeviceInfo(
|
|
|
- configuration_url=f'{API_SCHEMA}://{endpoint}',
|
|
|
+ configuration_url=f'{API_SCHEMA}://{ip}',
|
|
|
identifiers={(DOMAIN, entry.entry_id)},
|
|
|
model=info['ModelName'],
|
|
|
manufacturer=info['Manufacturer'],
|
|
|
@@ -106,20 +106,6 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|
|
|
|
|
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
|
|
"""Migrate old entry."""
|
|
|
- _LOGGER.debug("Migrating from version %s", config_entry.version)
|
|
|
-
|
|
|
- if config_entry.version == 1:
|
|
|
- hass.config_entries.async_update_entry(config_entry, version=2)
|
|
|
-
|
|
|
- entity_registry = er.async_get(hass)
|
|
|
- existing_entries = er.async_entries_for_config_entry(
|
|
|
- entity_registry, config_entry.entry_id
|
|
|
- )
|
|
|
-
|
|
|
- for entry in list(existing_entries):
|
|
|
- _LOGGER.debug("Deleting version 1 entity: %s", entry.entity_id)
|
|
|
- entity_registry.async_remove(entry.entity_id)
|
|
|
-
|
|
|
- _LOGGER.debug("Migration to version %s successful", config_entry.version)
|
|
|
+ _LOGGER.warning("Migrating from version %s", config_entry.version)
|
|
|
|
|
|
return True
|