How a Hybrid Inverter Achieves Automatic Grid-Tied and Off-Grid Switching: Maximizing Energy Security in Unstable Regions