There’s an edge driver that can be used to detect if a device on your LAN is online/offline.
With the help of a service that runs on your computer it can detect if an Internet host is online/offline.
Both together and a smart plug could solve your problem.