Wired up printer parts button

This commit is contained in:
Martin Ziegler
2025-12-02 17:57:08 +01:00
parent 42458974d8
commit 50a8ed8ea9
10 changed files with 762 additions and 399 deletions
+26
View File
@@ -595,3 +595,29 @@ async def set_liveview(
success=success,
message=f"Live view {'enabled' if request.enable else 'disabled'}" if success else "Failed to set live view"
)
# =============================================================================
# Status Refresh Endpoint
# =============================================================================
@router.post("/{printer_id}/control/refresh", response_model=ControlResponse)
async def refresh_status(
printer_id: int,
db: AsyncSession = Depends(get_db),
):
"""Request a full status update from the printer.
This sends a 'pushall' command to get the latest data including nozzle info,
AMS status, and all other printer state.
"""
await get_printer_or_404(printer_id, db)
success = printer_manager.request_status_update(printer_id)
if not success:
raise HTTPException(status_code=503, detail="Printer not connected")
return ControlResponse(
success=success,
message="Status refresh requested"
)
+11
View File
@@ -21,6 +21,7 @@ from backend.app.schemas.printer import (
HMSErrorResponse,
AMSUnit,
AMSTray,
NozzleInfoResponse,
)
from backend.app.services.printer_manager import printer_manager
from backend.app.services.bambu_ftp import (
@@ -183,6 +184,15 @@ async def get_printer_status(printer_id: int, db: AsyncSession = Depends(get_db)
k=vt_data.get("k"),
)
# Convert nozzle info to response format
nozzles = [
NozzleInfoResponse(
nozzle_type=n.nozzle_type,
nozzle_diameter=n.nozzle_diameter,
)
for n in (state.nozzles or [])
]
return PrinterStatus(
id=printer_id,
name=printer.name,
@@ -204,6 +214,7 @@ async def get_printer_status(printer_id: int, db: AsyncSession = Depends(get_db)
sdcard=state.sdcard,
timelapse=state.timelapse,
ipcam=state.ipcam,
nozzles=nozzles,
)