mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 01:57:41 +02:00
Release the plate-clear gate on a powered-down printer (issue #2864)
POST /printers/{id}/clear-plate answered 400 "Printer not connected" for
anything without a live MQTT client, and the printer card hid the button
under the same condition. With Auto Power Off that is the ordinary end of
every print: the reporter's log has printer 1 marked offline at 12:00:55
by the plug and the clear-plate POST rejected at 12:03:12, with the plate
already cleared by hand. Nothing could release the gate short of powering
each printer back on, clearing, and switching it off again.
Nothing in the clear path talks to the printer. set_awaiting_plate_clear
writes an in-memory set and the printers.awaiting_plate_clear column, and
that column exists precisely so the gate survives an Auto Off cycle
(#961). The guard came in with the endpoint in aa87e5598, copied from the
stop/pause/resume handlers beside it, where reaching the printer is the
whole point. The scheduler already reads the flag off a powered-off
printer - it refuses to wake one that is still gated - and the wiki
recommends the MQTT topic for automations because it does not depend on
the printer being powered on. Only the write path disagreed.
The card follows: showClearPlateButton drops the connection term, and the
expanded-view button - which lived inside the block that renders nothing
without a live status - is shared and given its own slot below it. The
bulk filter tests clearPlate before the connection filter; every other
bulk action still needs to reach the machine. The plate pill stays
connected-only, since its only render site is inside that same block.
Two things on the same path needed the flag without a client. GET /status
returned the schema default for a printer with no cached state - manually
disconnected, or not yet reconnected after a restart - reporting a clean
plate the database disagreed with, and hiding the control on exactly the
printers that needed it. And _emit_plate_clear_change bailed when the
printer info cache was empty, which would have left the retained
plate_clear topic (#2525) asserting "awaiting" after the gate was
released; it now falls back to the row.
This does not dispatch to an unreachable printer: _is_printer_idle still
requires a connection. Releasing the gate is what lets the queue switch
the printer on for the next job instead of passing it over.
This commit is contained in:
@@ -465,10 +465,16 @@ async def get_printer_status(
|
||||
|
||||
state = printer_manager.get_status(printer_id)
|
||||
if not state:
|
||||
# No MQTT client state — the printer was never connected this run, or it
|
||||
# was disconnected manually. The plate-clear gate is Bambuddy-side and
|
||||
# persisted, so it still has a truthful value here (#2864); reporting the
|
||||
# schema default instead told clients the plate was clean and hid the
|
||||
# only control that can release the gate.
|
||||
return PrinterStatus(
|
||||
id=printer_id,
|
||||
name=printer.name,
|
||||
connected=False,
|
||||
awaiting_plate_clear=printer_manager.is_awaiting_plate_clear(printer_id),
|
||||
)
|
||||
|
||||
# Determine cover URL if there's an active print (including paused)
|
||||
@@ -3104,8 +3110,12 @@ async def clear_plate(
|
||||
if not printer:
|
||||
raise HTTPException(404, "Printer not found")
|
||||
|
||||
if not printer_manager.is_connected(printer_id):
|
||||
raise HTTPException(400, "Printer not connected")
|
||||
# Deliberately NOT gated on the printer being connected. Acknowledging the plate
|
||||
# only mutates Bambuddy-side state — no MQTT command is sent — and with Auto Power
|
||||
# Off the normal end-of-print state is exactly this: gate up, printer powered down.
|
||||
# The guard this replaces was inherited from the sibling stop/pause/resume handlers,
|
||||
# where reaching the printer IS required, and left farms with no way to release the
|
||||
# gate short of powering each printer back on by hand (#2864).
|
||||
|
||||
# Accept the acknowledgment whenever the printer is awaiting it — not only when the
|
||||
# reported state is FINISH/FAILED. After a power cycle the printer boots into IDLE
|
||||
|
||||
Reference in New Issue
Block a user