async def async_setup_entry(hass: HomeAssistant, entry: HomematicConfigEntry) -> bool:
    """Set up Homematic(IP) Local from a config entry."""
    if AwesomeVersion(HMIP_LOCAL_HAHOMEMATIC_VERSION) != AwesomeVersion(HAHM_VERSION):
        _LOGGER.error(
            "This release of Homematic(IP) Local requires hahomematic version %s, but found version %s. "
            "Looks like HA has a problem with dependency management. "
            "This is NOT an issue of the integration.",
            HMIP_LOCAL_HAHOMEMATIC_VERSION,
            HAHM_VERSION,
        )
        _LOGGER.warning("Homematic(IP) Local setup blocked")
        return False
    _LOGGER.debug(
        "Homematic(IP) Local setup with hahomematic version %s",
        HAHM_VERSION,
    )

    if AwesomeVersion(HMIP_LOCAL_MIN_HA_VERSION) > HA_VERSION:
        _LOGGER.warning(
            "This release of Homematic(IP) Local requires HA version %s and above",
            HMIP_LOCAL_MIN_HA_VERSION,
        )
        _LOGGER.warning("Homematic(IP) Local setup blocked")
        return False

    hass.data.setdefault(HM_KEY, HomematicData())
    if (default_callback_port := hass.data[HM_KEY].default_callback_port) is None:
        default_callback_port = find_free_port()
        hass.data[HM_KEY].default_callback_port = default_callback_port

    control = ControlConfig(
        hass=hass,
        entry_id=entry.entry_id,
        data=entry.data,
        default_port=default_callback_port,
    ).create_control_unit()
    entry.runtime_data = control
    await hass.config_entries.async_forward_entry_setups(entry, HMIP_LOCAL_PLATFORMS)
    await control.start_central()
    await async_setup_services(hass)

    # Register on HA stop event to gracefully shutdown Homematic(IP) Local connection
    hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, control.stop_central)
    entry.async_on_unload(entry.add_update_listener(update_listener))
    return True
Set up Homematic(IP) Local from a config entry.
custom_components/homematicip_local/__init__.py