Observed
Restart labelfab-agent, then read the retained status topic:
{"v":1,"printer_id":"d30-workshop","state":"idle","model":null,"serial":null,
"firmware":null,"battery_pct":null,"voltage_v":null,"media_ok":null,
"tape_width_mm":15.0,"pending_labels":0,"error":null}
Everything the printer reports is null. InvenTree's Machines page therefore reads CONNECTED — media unreported after every agent restart, and only becomes truthful once something prints:
media=True fw=2.1.2 batt=100 voltage_v=4.18
Cause
SourceMqtt._on_connect publishes an initial PrinterStatus carrying only printer_id, state and tape_width_mm. The device fields are populated by _capture_feedback, which only runs inside a send. Nothing queries the printer at agent startup.
The tri-state handling is doing its job here — media_ok: null renders as "media unreported" rather than claiming health, which is correct. The gap is that the information is available and simply not fetched.
Why it is not a trivial fix
Connecting on startup to populate this would wake the printer on every agent restart. The D30 auto-powers-off by design, and device.idle_disconnect defaults to true precisely because a held-open socket just relocates the failure. So an unconditional startup probe trades a cosmetic improvement for battery drain and an unnecessary Bluetooth wake, on a device whose whole operating model is "asleep until needed".
Options, roughly in order of preference:
- Persist the last-known device state across restarts (the spool DB is already there) and republish it on connect, clearly marked as last-known rather than live. No printer wake, and the common case — nothing changed while the agent was down — reads correctly.
- An opt-in
device.probe_on_start for setups where the printer is mains-powered and always awake.
- Leave it, and let the driver render
media unreported until the first job. Honest, just less useful than it could be.
Option 1 also survives the case where the agent restarts more often than it prints, which is the situation that produced this report.
Observed
Restart
labelfab-agent, then read the retained status topic:{"v":1,"printer_id":"d30-workshop","state":"idle","model":null,"serial":null, "firmware":null,"battery_pct":null,"voltage_v":null,"media_ok":null, "tape_width_mm":15.0,"pending_labels":0,"error":null}Everything the printer reports is
null. InvenTree's Machines page therefore readsCONNECTED — media unreportedafter every agent restart, and only becomes truthful once something prints:Cause
SourceMqtt._on_connectpublishes an initialPrinterStatuscarrying onlyprinter_id,stateandtape_width_mm. The device fields are populated by_capture_feedback, which only runs inside a send. Nothing queries the printer at agent startup.The tri-state handling is doing its job here —
media_ok: nullrenders as "media unreported" rather than claiming health, which is correct. The gap is that the information is available and simply not fetched.Why it is not a trivial fix
Connecting on startup to populate this would wake the printer on every agent restart. The D30 auto-powers-off by design, and
device.idle_disconnectdefaults to true precisely because a held-open socket just relocates the failure. So an unconditional startup probe trades a cosmetic improvement for battery drain and an unnecessary Bluetooth wake, on a device whose whole operating model is "asleep until needed".Options, roughly in order of preference:
device.probe_on_startfor setups where the printer is mains-powered and always awake.media unreporteduntil the first job. Honest, just less useful than it could be.Option 1 also survives the case where the agent restarts more often than it prints, which is the situation that produced this report.