Improve print check

This commit is contained in:
Peter Cai 2024-07-13 21:57:32 -04:00
parent 8069eb2573
commit c6a64a01db

View file

@ -287,12 +287,7 @@ function bambu_print() {
mqtt_command '{"print": { "sequence_id": 1, "command": "resume", "param": ""}}'
;;
check)
local err="$(FROM_INTERNAL=true bambu_status | jq -r '.print.print_error')"
if [ -z "$err" ] || [ "$err" == "0" ]; then
echo "No errors"
else
printf "Error: 0x%x\n" "$err"
fi
bambu_print_check
;;
*)
die "Unknown subcommand: $subcommand"
@ -300,6 +295,21 @@ function bambu_print() {
esac
}
function bambu_print_check() {
local status="$(FROM_INTERNAL=true bambu_status)"
local err="$(echo "$status" | jq -r '.print.print_error')"
if [ -z "$err" ] || [ "$err" == "0" ]; then
local gcode_state="$(echo "$status" | jq -r '.print.gcode_state')"
if [ "$gcode_state" == "RUNNING" ]; then
echo "Now printing: $(echo "$status" | jq -r '.print.subtask_name')"
echo "Progress: $(echo "$status" | jq -r '.print.mc_percent')%"
fi
echo "No errors"
else
printf "Error: 0x%x\n" "$err"
fi
}
function bambu_print_start() {
local file=""
local timelapse="false"