The Sages infer from the verse, “You shall not do any melakha” (Shemot 20:10), that the Torah prohibits the actual performance of a melakha; but if the melakha is done automatically, even if a person caused it to be done, it is considered grama, and it is not prohibited by the Torah. In cases of great necessity, one may use grama to achieve the result of a melakha. For example, if a fire is spreading, one may surround the fire with containers filled with water so that when the fire reaches them, the containers will burst open and the water inside them will pour out, putting out the fire (Shabbat 120b; SA 334:22). This ruling is followed in practice. On Shabbat grama is permitted in order to avoid a loss, in service of a mitzva, or for some other great need. Barring these circumstances, one may not cause melakha to be done on Shabbat (Rema 334:22).
However, when it comes to grama on Yom Tov, the poskim disagree. Some argue that the laws of Yom Tov are the same as those of Shabbat, while others maintain that on Yom Tov grama is permitted le-khatḥila, especially in the cases of Mav’ir and Mekhabeh, as they are prohibited only rabbinically on Yom Tov. In practice, one may be lenient concerning grama even without a pressing need. However, if there is no need, it is proper to be stringent.
In the past, people who wanted to cook on Yom Tov would put enough firewood in the oven to allow them to cook what was necessary. This wood would be lit with a flame that had been prepared before Yom Tov. When the cooking was done, the fire would burn itself out, as the amount of firewood used was sufficient for the cooking and no more. Today, however, when we cook with gas burners, turning them off is problematic, as one is not allowed to directly turn off a flame on Yom Tov.
One possible solution is to use grama so that the flame is extinguished indirectly. For example, after the cooking is done, a full kettle of water can be placed on the burner and allowed to boil over. The overflowing water will put out the flame. Once it is out, the knob may be used to turn off the gas. The hot water remaining in the kettle should be used for making tea or washing dishes, so that it will not have been boiled up for no reason.
A better, more convenient way of extinguishing the flame is by means of the Zomet Institute’s Holiday Gas Timer (“Chagaz”), a device invented specifically for cooking on Yom Tov. It involves a spring-operated mechanical timer. While it is on, gas flows through the pipes and feeds the flame; at the pre-set time, the gas supply is cut off, causing the flame to go out. Before one starts to cook, he sets the timer for the desired amount of time. When the time is up, the Chagaz simply cuts off the gas.
. Some maintain that one should not do melakha indirectly on a regular basis, so the above solution may be used only on an occasional basis (SSK 13:13). However, the primary position is that grama is permitted on Yom Tov when there is a need. Therefore, one may cause the flame to go out by causing water to overflow onto it (Devar Yehoshua 2:84; Or Le-Tziyon 3:20:11; Yabi’a Omer 3:30). Netzer Mata’ai §9 maintains that shutting off the valve of a gas canister outside the house qualifies as putting out the fire indirectly and thus is permitted. Si’aḥ Naḥum 27:3 permits shutting off the main gas valve in the kitchen, on condition that there will be a delay of at least a few seconds before the flame goes out. He argues that cutting off the gas at a distance from the flame is comparable to removing wood that has been put in the fire but has not caught fire yet (which is permitted), and is not comparable to removing wood which has already started to burn on one side (which is forbidden). However, many prohibit extinguishing the fire by turning off the gas, whether inside or outside. These include Tzitz Eliezer 6:8-9; Yabi’a Omer 3:30; SSK 13:12 in the name of R. Frank. The reason is that the fire is being extinguished by removing its fuel, which they see as being comparable to cutting off part of a burning candle, which Rosh and SA 514:3 forbid. Furthermore, usually after the valve is turned off the fire goes out immediately, or is at least weakened immediately. Accordingly, Tosafot would agree the action is forbidden, as it cannot be classified as indirect. It seems to me that if there is at least a ten-second delay before the flame goes out, and the gas is turned off from a point which is at a distance from the flame, it can be considered indirect. It is also proper to use a shinui, thus rendering the action a shvut di-shvut.
According to Rema 514:3, one may place a lit candle in an area where there is currently no wind. Even if the wind sometimes blows there, and even though he hopes that the wind will blow out the candle, it is considered grama. However, MA and BHL prohibit this out of concern that the wind might begin blowing at the very moment he places the candle there, in which case he has directly extinguished the flame.
. This device is even less problematic than ordinary grama, because before the gas is turned on, the length of time for which it will burn has already been set. Be-di’avad, if one forgot to set the timer before lighting the gas, he may do so afterward. Since the flame only goes out after a noticeable delay, it is considered indirect extinguishing, which is permitted on Yom Tov when there is a need. According to SA 514:3, one who wants to make sure that a candle does not burn all the way down may place it in loosely packed sand and then light it. When the flame reaches the sand it will go out. In contrast, one may not place a lit candle in the sand. Rema and most poskim (see MB ad loc. 20) disagree, maintaining that it is permitted to place even a lit candle in sand. In pressing circumstances, they may be relied upon.