Use the bedready plugin to check if the bed is clear or occupied
This commit is contained in:
parent
ae1d00b13f
commit
730a6a3950
1 changed files with 22 additions and 1 deletions
|
@ -69,6 +69,24 @@ def poll_printers(app: App, db: Db) -> None:
|
||||||
log.info(f"Printer {printer.id} {printer.status} -> {status}")
|
log.info(f"Printer {printer.id} {printer.status} -> {status}")
|
||||||
db.update_printer_status(pid=printer.id, status=status)
|
db.update_printer_status(pid=printer.id, status=status)
|
||||||
|
|
||||||
|
def _bed_clear():
|
||||||
|
if not (
|
||||||
|
snapshots := client._post(
|
||||||
|
"/api/plugin/bedready", json={"command": "list_snapshots"}
|
||||||
|
)
|
||||||
|
):
|
||||||
|
return True # Assume the bed is ready
|
||||||
|
|
||||||
|
status = client._post(
|
||||||
|
"/api/plugin/bedready",
|
||||||
|
json={
|
||||||
|
"command": "check_bed",
|
||||||
|
"similarity": 0.97,
|
||||||
|
"reference": snapshots[0],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return status.get("bed_clear", True)
|
||||||
|
|
||||||
printer_job = {}
|
printer_job = {}
|
||||||
try:
|
try:
|
||||||
client = get_client(printer.url, printer.api_key)
|
client = get_client(printer.url, printer.api_key)
|
||||||
|
@ -98,7 +116,10 @@ def poll_printers(app: App, db: Db) -> None:
|
||||||
_set_status("connecting")
|
_set_status("connecting")
|
||||||
|
|
||||||
elif printer_state.get("ready"):
|
elif printer_state.get("ready"):
|
||||||
_set_status("idle")
|
if _bed_clear():
|
||||||
|
_set_status("idle")
|
||||||
|
else:
|
||||||
|
_set_status("occupied")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
Loading…
Reference in a new issue