I have developed an alarm system using an Rpi.
For its connectivity to the internet it can be connected via the ethernet or via the WiFi NICs.
The ethernet connectivity is provided via a DSL router.
The WiFi can be provided via the same router1 (SSID1) but another SSID (SSID2) via another router2 is also available "on demand" and also configured at the RPI.
In case the DSL router gets out of service, i.e. the ethernet and the WiFi connections go out of service, I expect that the RPI will auto connect via SSDI2 to router2.
The alarm app running is in Python 3 and is checking at intervals whether there is connectivity (ping response) to www.google.com to check whether internet access is available.
In case the router1's WAN access is unavailable but the LAN is ok, normally the RPI will remain connected via Ethernet (or via SSID1) but the app will have no internet connectivity.
What I need in this case is the RPI to connect via router2-SSID2.
Can this be configured at OS-Raspbian level to be done automatically or will I have to do this in Python and with os commands to switch between the interfaces and SSIDs?
The order in which I need the RPI to gain internet access is
1. Ethernet cable to router1
2. WiFi to SSID1 of router1
3. WiFi to SSID2 of router2
Thank you in advance