When the power goes out

Look at this post Power outage detection for point 1.