Creating a binary sensor with availability_template

Look at the solution as I suspect that your black out/no electricity is supposed as rare as my smoke detection.

And if it is your solution as well, don’t forget to like Taras’s post describing it.