Skip to content

Rehearse with a simulated machine

The physical worldMQTTHTTPbambu-simcompose profiledrills

A 3D printer on the lineStep 7 of 7Unloaded, or a decision for a person

The printer is at the office. The engineer is not.

← An alarm pauses the job, not the escalation

A simulated printer on the compose network speaks the same MQTT and FTPS as the real one, so the whole route runs, and fails on cue, with no printer.

The situation

Testing a line against real hardware means being next to the hardware, and making it fail on purpose means pulling a spool. A simulated machine should look the same on the network, so nothing else changes, and fail on request. Here the bambu-sim profile runs one.

The setup

Point .env at the simulated printer:

.env
BAMBU_SITE_ID=site-1
BAMBU_LINE_ID=print-1
BAMBU_PRINTERS=p1s-01
BAMBU_P1S_01_SERIAL=01P00A000000001
BAMBU_P1S_01_HOST=bambu-sim
BAMBU_P1S_01_CODE=12345678
BAMBU_P1S_01_ENABLED=true
# A print on the simulated printer takes this many seconds
BAMBU_SIM_PRINT_SEC=60

Start the stack with the profile:

shell
docker compose -f docker-compose.yml -f docker-compose.nats.yml -f docker-compose.machines.yml \
-f docker-compose.bambu.yml --profile bambu-sim up -d --build
docker compose exec long-tail npm run bambu:print

bambu-sim serves implicit FTPS on 990 and plays the printer. Its Mosquitto broker shares the same address, on 8883 for bblp and the access code, with a certificate issued to the serial. machine-site reads its CA and renders its bridge, as for a printer. A print takes BAMBU_SIM_PRINT_SEC, 60 by default.

On the floor

Drills on port 8092 play what someone at the printer would do:

Terminal window
curl localhost:8092/ # the printer's state and the files on its storage
curl -X POST localhost:8092/runout # the spool runs out mid-print
curl -X POST localhost:8092/resume # filament loaded, resumed at the printer
curl -X POST localhost:8092/occupy # a print started elsewhere takes the printer
curl -X POST localhost:8092/vacate # the printer is idle again
curl -X POST localhost:8092/hold -d '{"percent":50}' # progress stops at 50% until release
curl -X POST localhost:8092/release

runout raises the servicing alarm and pauses the print escalation. resume clears both. occupy makes the next print a refused one, decided on print-servicing.

The guarantee

The codec, the bridge, the gateway and the route run unchanged against the simulated printer. Only .env names a different host. See Machines.