def get_interface_schema(use_tls: bool, data: ConfigType, from_config_flow: bool) -> Schema:
    """Return the interface schema with or without tls ports."""
    interfaces = data.get(CONF_INTERFACE, {})
    # HmIP-RF
    enable_hmip_rf = Interface.HMIP_RF in interfaces
    hmip_port = (
        custom_port
        if (
            enable_hmip_rf
            and (custom_port := interfaces[Interface.HMIP_RF][CONF_PORT]) not in (IF_HMIP_RF_TLS_PORT, IF_HMIP_RF_PORT)
        )
        else (IF_HMIP_RF_TLS_PORT if use_tls else IF_HMIP_RF_PORT)
    )

    # BidCos-RF
    enable_bidcos_rf = Interface.BIDCOS_RF in interfaces
    bidcos_rf_port = (
        custom_port
        if (
            enable_bidcos_rf
            and (custom_port := interfaces[Interface.BIDCOS_RF][CONF_PORT])
            not in (IF_BIDCOS_RF_TLS_PORT, IF_BIDCOS_RF_PORT)
        )
        else (IF_BIDCOS_RF_TLS_PORT if use_tls else IF_BIDCOS_RF_PORT)
    )

    # Virtual devices
    enable_virtual_devices = Interface.VIRTUAL_DEVICES in interfaces
    virtual_devices_port = (
        custom_port
        if (
            enable_virtual_devices
            and (custom_port := interfaces[Interface.VIRTUAL_DEVICES][CONF_PORT])
            not in (IF_VIRTUAL_DEVICES_TLS_PORT, IF_VIRTUAL_DEVICES_PORT)
        )
        else (IF_VIRTUAL_DEVICES_TLS_PORT if use_tls else IF_VIRTUAL_DEVICES_PORT)
    )

    # BidCos-Wired
    enable_bidcos_wired = Interface.BIDCOS_WIRED in interfaces
    bidcos_wired_port = (
        custom_port
        if (
            enable_bidcos_wired
            and (custom_port := interfaces[Interface.BIDCOS_WIRED][CONF_PORT])
            not in (IF_BIDCOS_WIRED_TLS_PORT, IF_BIDCOS_WIRED_PORT)
        )
        else (IF_BIDCOS_WIRED_TLS_PORT if use_tls else IF_BIDCOS_WIRED_PORT)
    )

    # CCU-Jack
    enable_ccu_jack = Interface.CCU_JACK in interfaces
    # CUxD
    enable_cuxd = Interface.CUXD in interfaces

    advanced_config = bool(data.get(CONF_ADVANCED_CONFIG))
    interface_schema = vol.Schema(
        {
            vol.Required(CONF_ENABLE_HMIP_RF, default=enable_hmip_rf): BOOLEAN_SELECTOR,
            vol.Required(CONF_HMIP_RF_PORT, default=hmip_port): PORT_SELECTOR,
            vol.Required(CONF_ENABLE_BIDCOS_RF, default=enable_bidcos_rf): BOOLEAN_SELECTOR,
            vol.Required(CONF_BIDCOS_RF_PORT, default=bidcos_rf_port): PORT_SELECTOR,
            vol.Required(CONF_ENABLE_VIRTUAL_DEVICES, default=enable_virtual_devices): BOOLEAN_SELECTOR,
            vol.Required(CONF_VIRTUAL_DEVICES_PORT, default=virtual_devices_port): PORT_SELECTOR,
            vol.Required(CONF_VIRTUAL_DEVICES_PATH, default=IF_VIRTUAL_DEVICES_PATH): TEXT_SELECTOR,
            vol.Required(CONF_ENABLE_BIDCOS_WIRED, default=enable_bidcos_wired): BOOLEAN_SELECTOR,
            vol.Required(CONF_BIDCOS_WIRED_PORT, default=bidcos_wired_port): PORT_SELECTOR,
            vol.Required(CONF_ENABLE_CCU_JACK, default=enable_ccu_jack): BOOLEAN_SELECTOR,
            vol.Required(CONF_ENABLE_CUXD, default=enable_cuxd): BOOLEAN_SELECTOR,
            vol.Required(CONF_ADVANCED_CONFIG, default=advanced_config): BOOLEAN_SELECTOR,
        }
    )
    if from_config_flow:
        del interface_schema.schema[CONF_ADVANCED_CONFIG]
    return interface_schema
Return the interface schema with or without tls ports.
custom_components/homematicip_local/config_flow.py