A shul keeps a defibrilator in a closet. While passing the closet on Shabbat, someone hears the machine beeping. He opens the closet, and sees a warning light saying "low battery".
The shul has many elderly people attending services Shabbat morning, and they have had frequent situations where they have needed to use the defibrillator on Shabbat. As this machine can save a person's life, the machine must be readily operative in an emergency.
May a person change the battery on the defib on Shabbat so that it will be available for a possible emergency that may or may not occur on Shabbat?
My question is not limited to a defib. It's just an example. It can be generalized to knowing of one may do melacha on any equipment so that it will be ready for a possible emergency? E.g. on Shabbat, can one change a dead battery on an ambulance?