Vision
Use machine numbers 1–4 in the high-level API. Trays are 11–18 and channels 0–9. Wire machine indexes are zero-based and are translated internally.
Query before dispensing
jsd.on('vision:machine-status', status => {
console.log(status.machine, status.availabilityToDispense);
});
await jsd.vision.requestMachineStatus({ machine: 1 });getMachineStatus(1) reads the local cache, not the hardware. isAvailableToDispense({ machine: 1 }) requires a connected machine, in service, closed door, and availability AVAILABLE-TO-DISPENSE or ELEVATOR-COLLECTION-POSITION.
Dispense and completion
jsd.on('vision:dispense-status', result => console.log(result.token, result.status));
if (jsd.vision.isAvailableToDispense({ machine: 1 })) {
const delivered = await jsd.vision.dispense({ machine: 1, selection: 12 });
console.log(delivered);
}dispense() maps selection to tray/channel. Speed defaults to 5 and post-run time to 0. dispenseFromSelection() sends a JSD selection directly; channel-based operations check cached availability. dispenseFromChannelExtended() adds fragile/heavy and elevator adjustment options.
Without cart, COLLECTED or WAITING-COLLECTION resolves true. With cart: true, DISPENSED-CAN-MULTIPLE resolves true. Failure statuses resolve false. Other statuses keep the promise pending.
| Code | Status |
|---|---|
| 0 | RECEIVED |
| 1 | IN-PROGRESS |
| 2 | WAITING-COLLECTION |
| 3 | COLLECTED |
| 4 | NO-PERFORMED |
| 5 | TOKEN-NOT-FOUND |
| 6 | QUEUE-FULL |
| 7 | CHANNEL-NO-CONNECTED |
| 8 | SELECTION-UNAVAILABLE |
| 9 | FAILED-DISPENSE |
| 10 | UNCOLLECTED |
| 11 | DISPENSED-CAN-MULTIPLE |
| 12 | DISPENSE-CANCELLED |
| 13 | PRODUCT-EXPIRED |
extendedStatus can report door, motor, sensor, elevator, stock, communication, or expiry details; unknown values produce UNKNOWN. Missing extended details are null. See the event payload.
Channels and carts
jsd.on('vision:channels-progress', data => console.log(data.progress));
const channels = await jsd.vision.assignChannels({ machine: 1 });Assignment verifies 80 selections and emits vision:channels when complete. Only one assignment runs at a time. dispenseCart() groups requests in batches of ten, waits for machine availability between batches, and returns selection results. It logs batch exceptions and continues; it has no cancellation deadline.
Configuration and maintenance
The full method reference includes channel linking, selection configuration, machine identification, temperature, wait timings, active/inactive faults, perishable products, lights, collection, queue management, self-test, and JSD restart. Their responses are all in the Vision event reference.
Do not confuse a machine's CONNECTED state with serial readiness; they describe different layers.