Added power consumption costs calculation

This commit is contained in:
Martin Ziegler
2025-11-29 12:16:53 +01:00
parent 3031c2ae3e
commit 0c2a187191
2 changed files with 11 additions and 5 deletions
+1 -1
View File
@@ -287,7 +287,7 @@ async def on_print_complete(printer_id: int, data: dict):
await service.update_archive_status(
archive_id,
status=status,
completed_at=datetime.now() if status in ("completed", "failed") else None,
completed_at=datetime.now() if status in ("completed", "failed", "aborted") else None,
)
await ws_manager.send_archive_updated({
+10 -4
View File
@@ -251,18 +251,24 @@ class BambuMQTTClient:
"raw_data": data,
})
# Detect print completion (FINISH = success, FAILED = error)
# Detect print completion (FINISH = success, FAILED = error, IDLE = aborted)
if (
self._previous_gcode_state == "RUNNING"
and self.state.state in ("FINISH", "FAILED")
and self.state.state in ("FINISH", "FAILED", "IDLE")
and self.on_print_complete
):
if self.state.state == "FINISH":
status = "completed"
elif self.state.state == "FAILED":
status = "failed"
else:
status = "aborted"
logger.info(
f"[{self.serial_number}] PRINT COMPLETE detected - state: {self.state.state}, "
f"file: {self._previous_gcode_file or current_file}"
f"status: {status}, file: {self._previous_gcode_file or current_file}"
)
self.on_print_complete({
"status": "completed" if self.state.state == "FINISH" else "failed",
"status": status,
"filename": self._previous_gcode_file or current_file,
"raw_data": data,
})