Welcome to the Hubitat Community. There are many ways to do it. Some use bulbs, some use transmitters, etc. Just search for power loss or power failure. You'll find multiple posts and multiple ideas, including several examples of custom code to work with those ideas.