H2D temperature regulation G-code

I was checking the start G-code of the H2D and I’m struggling to understand the details due to non-existing documentation by Bambu (or my inability to find it).

{if (overall_chamber_temperature >= 40)}

    M145 P1 ; set airduct mode to heating mode for heating
    M106 P2 S0 ; turn off auxiliary fan
    M106 P3 S0 ; turn off chamber fan

{else}
    M145 P0 ; set airduct mode to cooling mode for cooling
    M106 P2 S178 ; turn on auxiliary fan for cooling
    M106 P3 S127 ; turn on chamber fan for cooling
    M140 S0 ; stop heatbed from heating

    M1002 gcode_claim_action : 29
    M191 S0 ; wait for chamber temp
    M106 P2 S0 ; turn off auxiliary fan
    {if (min_vitrification_temperature <= 50)}
        {if (nozzle_diameter == 0.2)}
            M142 P1 R30 S35 T40 U0.3 V0.5 W0.8 O40 ; set PLA/TPU ND0.2 chamber autocooling
        {else}
            M142 P1 R30 S40 T45 U0.3 V0.5 W0.8 O45; set PLA/TPU ND0.4 chamber autocooling
        {endif}
    {else}
        {if (!is_all_bbl_filament)}
            M142 P1 R35 S40 T45 U0.3 V0.5 W0.8 O45 L1 ; set third-party PETG chamber autocooling
        {else}
            {if (nozzle_diameter == 0.2)}
                M142 P1 R35 S45 T50 U0.3 V0.5 W0.8 O50 L1 ; set PETG ND0.2 chamber autocooling
            {else}
                M142 P1 R35 S50 T55 U0.3 V0.5 W0.8 O55 L1 ; set PETG ND0.4 chamber autocooling
            {endif}
        {endif}
    {endif}
{endif}
;==== set airduct mode ==== 

;===== start to heat heatbed & hotend==========

    M1002 set_filament_type:{filament_type[initial_no_support_extruder]}

    M104 S140 A
    M140 S[bed_temperature_initial_layer_single]

    ;===== set chamber temperature ==========
    {if (overall_chamber_temperature >= 40)}
        M145 P1 ; set airduct mode to heating mode
        M141 S[overall_chamber_temperature] ; Let Chamber begin to heat
    {endif}
    ;===== set chamber temperature ==========

To my understanding, setting 40 °C or more will activate heating mode and if not, cooling mode. So there is no setting where you just set a temperature and the H2D will switch between heating or cooling mode accordingly, depending on the current chamber temperature.
Is that correct?

What is specifically interesting for me:

M191 S0 ; wait for chamber temp
What temperature is it waiting for? I can see it set anywhere.

M142 P1 R35 S50 T55 U0.3 V0.5 W0.8 O55 L1 ; set PETG ND0.4 chamber autocooling
What values are these exactly and why are they different for Bambu and Non-Bambu filament?

To answer any of your questions, I first need to understand what you are trying to achieve.

The chamber temperature is defined by the filament profile. Bambu Lab can only optimize this for their own PETG and other official materials, not for third-party filaments.

Hmm… I thought I wrote it all. I’m trying to understand the temperature management.

I’m trying to understand, if the printer will switch between heating and cooling mode automatically at a set temperature.
And I’m trying to understand what the M142 command does since this is seemingly treating Bambus Filament different to other brands filaments so I understand variances when optimizing my filaments.

It will never switch between heating and cooling automatically.

The reason it differs between their own brand and third-party materials is simple — they know the exact composition of their own filaments and can therefore apply more aggressive settings. With third-party materials, the composition is unknown, so they must stay on the safe side.

I’m not entirely sure what you’re looking to optimize based on this information.

If you can give me an example, I can try to help. I have a large number of precisely tuned filament profiles and processes that might point you in the right direction.

To do that you’d need conditional execution in g-code, and although there are some Bambu extensions to do that for other things I haven’t seen one for chamber temperature.

If that doesn’t make sense let me know and I’ll try to explain.