INNER CODE UNIT · Python

async_setup_entry

dummylabs/thewatchman · custom_components/watchman/__init__.py:57

async def async_setup_entry(hass: HomeAssistant, config_entry: WMConfigEntry) -> bool:
    """Set up this integration using UI."""
    from .const import DB_FILENAME, LEGACY_DB_FILENAME

    legacy_db_path = Path(hass.config.path(".storage", LEGACY_DB_FILENAME))
    db_path = Path(hass.config.path(".storage", DB_FILENAME))

    # One-time migration: rename watchman.db to watchman_v2.db
    if not db_path.exists() and legacy_db_path.exists():
        _LOGGER.info(
            "Migrating legacy database %s to %s", LEGACY_DB_FILENAME, DB_FILENAME
        )
        legacy_db_path.rename(db_path)

    integration = await async_get_integration(hass, DOMAIN)

    # Configure obfuscation
    set_obfuscation_config(config_entry.data.get(CONF_LOG_OBFUSCATE, True))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…