Trying to set up multiple wifi connections with nmcli
I've found a number of pages on nmcli, but none that spell out clearly several steps of what I need to do.
Goal: Setup a Raspberry Pi Zero 2W to have at least 3 wifi network connections defined and to have Network Manager automatically connect to the one that is in range.
I've been trying to do this, but I'm running into problems. When I use Pi Imager to put an image (for OctoPi or other Linux systems) on a card, it will set up one wifi connect as the default. It does not allow for multiple wifi systems to be defined at the start. Also, when it Imager creates the system, the wifi network it creates is stored in /etc/NetworkManager/system-connections/preconfigured.nmconnection. When I've followed tutorials, and create a 2nd connection, it never stores the password or psk and when I reboot, it won't automatically connect to any wifi network other than the preconfigured one. (Apparently that one is not just given priority, but is the only one it looks for.) If I want it to connect to another wifi network, I have to plug in a keyboard and monitor and tell it to connect manuall.
Almost every tutorial I've found is basically the same with wifi networks: I have to be in range of a network, then tell it to connect and, at that point, it's a temporary connection (without a file in /etc/NetworkManager/system-connections). When I reboot, the connection isn't there. I can add that connection, but when I do, I don't see the psk stored in the file it creates and when I reboot, it won't reconnect with that network.
Once I find out how to do this, I can set it up to connect to my current wifi network, scp a setup script I write to the Pi, execute it, and it would make the needed changes so I have 3 (or more) wifi networks defined and so it'll connect to whichever is in range.
So, in general, I want to know how to do that, but, specifically, I think I can break it down to a few questions:
Is the preconfigured network necessary, or can I delete or rename that file? And if I do that, will it still be a default network?
How do I store an encrypted (or even plain text would work for my needs) password or psk in the connection file?
Is the information on connections stored anywhere other than the files in /etc/NetworkManager/system-connections? If so, where and how do I best edit it?
What do I need to do to add a wifi connection to a network that I can't connect to at the moment?
How can I get it to connect to whatever wifi network it can detect? (I'm not working with any with a hidden SSID and it's not going to be in range of more than one at a time, but if it is, it doesn't matter which one it connects to - as long as it connects.)