Skip to content

Error migrating entry PoolLab for poollab #51

@figorr

Description

@figorr

First of all … nice update. It is great that we can easily update the endpoint url.

But after updating to 1.1.4 … I have some problems and the integration cannot be loaded after restarting HA.

I saw the following error at log:

Error migrating entry PoolLab for poollab
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1100, in async_migrate
    result = await component.async_migrate_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/poollab/__init__.py", line 110, in async_migrate_entry
    config_entry.version = 2
    ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 555, in __setattr__
    raise AttributeError(
        f"{key} cannot be changed directly, use async_update_entry instead"
    )
AttributeError: version cannot be changed directly, use async_update_entry instead

I changed part of the __init__.py code and the integration loaded fine again.

async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
    """Migrate old entry."""
    version = config_entry.version
    _LOGGER.debug("Migrating from version %s", version)

    if version == 1:
        new_data = {**config_entry.data}
        new_data[CONF_URL] = API_ENDPOINT

        hass.config_entries.async_update_entry(
            config_entry,
            data=new_data,
            version=2,
        )

        _LOGGER.info("Migration to version %s successful", 2)
        return True

    return False

Anyone having a similar issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions