I started a related topic, IoT / microcontroller based power switching back in 2019, but a lot has changed in this last 5 years both in terms of the commercial off-the-shelf (COTS) products available to approach this; in my own attitude to doing custom development; and lastly in the actors on the forum that might want to input their thoughts. There is also a steady stream of new members who want to implement this sort of approach.
There is a spectrum of options here, so let me list