Files
bambuddy/backend
maziggy f4166bf652 Give an AMS slot a material type, not a product name (issue #2902)
Assigning a spool wrote its material straight into the slot's tray_type.
    A slot that says "PLA+" satisfies nothing that asks for PLA: not
    OrcaSlicer, not Bambu Studio, and not Bambuddy's own dispatch matcher,
    which compares the type the printer reports to the one the 3MF declares
    as plain equality. The reporter's slot was unusable for every PLA plate
    he had.

    Not only a label, either. The same string went into the generic-filament
    lookup, which missed, so the slot went out with no tray_info_idx at all
    -- the half-configured state #2604 documents the printer as reverting
    from -- and took the 200/240 catch-all nozzle range instead of PLA's
    190/230.

    PLA+ is not a special case. Bambuddy's own colour catalogue supplies the
    material dropdown, and around forty of its values are vendor product
    lines rather than filament types: HTPLA, PolyTerra PLA, PLA Matte, ASA
    Extrafill, Flexfill TPU 98A.

    So the four routes that configure a slot reduce the material to a name
    the printer knows before sending it, and the product name moves to
    tray_sub_brands -- which is where Bambu Lab puts it too: their catalogue
    carries a preset named "eSUN PLA+" whose type is PLA. A name the
    reduction cannot place is sent exactly as before rather than guessed at,
    so this can only repair a slot, never break a working one. The spool's
    own wording still leads the id and temperature lookups with the reduced
    type appended behind it, so "PETG HF" keeps its own generic preset
    (GFG96) rather than being traded down to plain PETG's.

    Two guards decide whether a candidate filament id is really a material
    name -- the resolver's, which discards one, and slot reuse, which will
    not carry one forward. Both saw only bare types, so "PLA+" passed as a
    filament id. They share one answer now, which also refuses to read an
    id-shaped value: "GFPLA" ends in a material name, and reducing it would
    throw away the calibrated preset in the slot.

    One thing had to move with it. on_ams_change auto-unlinks an assignment
    whose slot stopped looking the way it did when the spool was assigned,
    and the check that spares a slot Bambuddy itself reconfigured compared
    the printer's reported type against the spool's raw material. With the
    slot now carrying the reduced type, every spool this issue is about
    would have been unlinked from the slot it had just been assigned to.
    Both sides are reduced there -- the printer's too, so slots configured
    by an older version, still reporting "PLA+", keep matching.

    Something starts working as a result: a slot holding a calibrated preset
    is reused when a same-material spool is assigned to it, which could not
    happen for these spools while "PLA" and "PLA+" compared unequal.

    Reverting any one of the behaviours above fails a distinct test -- the
    reduction's four matching rules and its pass-through contract included,
    since that contract is what makes the rest of it safe.
2026-08-23 12:44:18 +02:00
..