Using automator or script to turn on wifi in case of ethernet cable failure, and vice versa?
Isin't 'Set Service Order' in System Preferences &gt; Network sufficient (click  circle with three dots inside at the bottom of left pane to see it)?
Setting Thunderbolt Bridge first and active and WiFi second and active should make MacOS switch automatically if first connection becomes unavailable.