If you own a P1S, you have probably walked past the printer at 2am and found the chamber lit up over a part that finished hours ago. The search that follows tends to land on the question the Bambu Lab forum asked in November 2023, in a thread called "Gcode control to disable LED lighting": is there a line you can drop into your end-of-print settings so you stop reaching for the screen or the app?

The thread is marked solved and the answer works. It is just not a command. What works is a behavior rule, and which side of it you end up on depends on how you left the light before you hit print.

The rule that works: start with the light off

The rule in the accepted answer is one sentence:

If you have the light off at the beginning of the print, it will turn on when it starts the print and shut off at the end of the print.

The rest of that answer matters just as much: turn it on by hand and you have to turn it off by hand. The person who opened the thread came back the next day and confirmed it, writing that with the light untouched at the start, it came on by itself and went off again at the end. So the behavior most people are looking for is already there, and the only condition is leaving the light off when you send the job and keeping your hands off the panel and the app while it runs. The moment you switch it on yourself, the printer treats the light as yours to manage and leaves the ending to you.

A separate X1 thread from February 2023 describes the same behavior alongside timelapse: with the chamber light off before the print starts and timelapse enabled, the light comes on during the print and goes off when the print completes. Neither thread explains the mechanism; both only report the observation.

There is no G-code for the main light

The second reply in the thread kills the expectation early:

There isn't gcode that can turn the main light off that I know of. There is gcode to turn the tool head light off.

The same user's workaround is to run their printers on wifi-connected plugs, keeping them powered down and bringing them up remotely, which moves the problem outside the slicer entirely.

In February 2024 someone else turns up in the thread and asks what the M code is. The reply two days later is not a code but the absence of one: the original poster writes that no such code exists on the X1 series and that the printer manages the general LED itself. The February 2023 thread "G-code for chamber light X1?" lands in the same place: the user who replies says they could find nothing light-related in the machine code, and the thread settles on the automatic behavior you get when the light is off before the print and timelapse is on.

Knowing this up front saves an evening. What G-code is and what a line of it looks like is covered in the G-code article; what is missing here is not knowledge, it is the command itself.

The one light command you can actually source

The only light command with a traceable source is M960 S5 P0, with M960 S5 P1 as its opposite. Those lines sit in the community-maintained forum reference "Bambu Lab X1 Specific G-Code", a thread opened in November 2022 and edited ever since, where they are listed as Bambu Lab toolhead logo light off / on, meaning the illuminated logo on the toolhead. The person who opened the LED thread says they did exactly that, putting the command in their end G-code; the approach that fails for the main light works for the logo one.

That list opens with a caveat worth repeating: Bambu Lab has published no official G-code documentation, and the entries come from user experimentation and assumption. The command is collected, not documented.

One distinction follows from it:

Light Is there a command
Chamber (main) light No command anyone on the forum can source
X1 toolhead logo light M960 S5 P0 / P1 in the community list

The second distinction is about models. In a December 2024 thread about a P1S chamber light staying on after a job, one user suggests the toolhead light command and another corrects them: the P1 series has no lighted toolhead, that is an X1 feature. On a P1S or an A1, that command has nothing to switch.

Where end-of-print G-code lives

You may still want your own lines at the end of a print, because there are other things worth putting there. The field is in the printer settings, under Machine G-code, in the Machine end G-code box. Whatever runs last after a job finishes lives there.

Do not confuse it with adding code at a layer. To run a command at a specific layer you use Add Custom G-code from the slider in the Preview tab, and that command goes into that one file; the method is in changing temperature at a layer. Machine end G-code is written into the profile instead, and it runs on every print you slice with it.

The risk of editing the start side of that same section is in the calibration article: copy the existing code somewhere before you touch it.

When it does not work

The rule does not produce the same result for everyone, and the forum has that on record.

If you switched the light on by hand. This is the single exception, and the accepted answer states it plainly. Turn the light on mid-print to take a look and it will not go off at the end.

There are reports of it failing on the P1S. In the same thread, a user in April 2025 writes that the automatic behavior has never worked for them and that the chamber light always comes on and stays on. A separate December 2024 thread was opened over the same complaint, and someone there says the behavior became permanent with firmware 1.05. Back in the main thread, a P1S owner reports in June 2024 that updating to 1.06 made no difference. Whether Bambu treats this as a bug or a choice never gets settled on the forum, so there is no rule to draw from it; if it does not work for you, you are not alone.

If the light comes on before you even sent the job. In a January 2024 thread about a P1S whose light started switching itself on after a firmware update, the owner reports it coming on before the file had finished downloading to the printer, which means whatever turns it on is not G-code in the file. The same owner reports adding M960 S5 P0 to their end G-code and the chamber light still not going off.

What it costs you on the camera

Keeping the light off has a hidden price: a dark chamber means a dark camera image. If you watch prints remotely or record timelapses, the light is working for you.

The behavior rule happens to protect that. Leave the light off and the printer runs it for the duration of the print, so monitoring and timelapse are not left in the dark; the light only drops out once the job is done. All you lose is the ability to look at a finished part through the camera overnight.

So this is a small comfort setting, and it gets solved without touching G-code at all. Send the job with the light off, leave the panel alone while it runs, and the printer takes care of the rest.

If that does not work on your machine, the remaining route is not the slicer but something outside the printer, like a smart plug on the wall.