mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-08-22 14:54:19 +01:00
Force MQTT pushall re-sync after a report gap (fixes #14)
The printer publishes partial deltas most of the time; the accumulator merges each one onto whatever state it already has. When the printer powers off, our cloud MQTT connection stays up (it's a persistent session to Bambu's broker, not a socket to the printer), so nothing signals the outage. When the printer reconnects and resumes its normal partial updates, those deltas get merged onto the stale pre-outage state — fields the delta doesn't mention (e.g. nozzle_temp) stay frozen at their old values. Sending any command happens to trigger a full report from the printer, which is why toggling the light "fixes" it. Track the time of the last message per BambuPrinter instance. When a new message arrives after a gap longer than BAMBU_RUN_MQTT_RESYNC_GAP_SECONDS (default 90s), request a pushall before processing it, forcing a complete state refresh instead of trusting the partial delta to overwrite stale fields.
This commit is contained in:
@@ -81,5 +81,12 @@ class _Settings:
|
||||
def CLOUD_SYNC_DAYS(self):
|
||||
return get_setting("BAMBU_RUN_CLOUD_SYNC_DAYS", 30)
|
||||
|
||||
# Seconds of silence on the MQTT report topic that, once broken by a new
|
||||
# message, is treated as "the printer was probably offline" and triggers
|
||||
# a pushall re-sync instead of trusting the partial delta to fill in stale
|
||||
# fields left over from before the gap.
|
||||
@property
|
||||
def MQTT_RESYNC_GAP_SECONDS(self):
|
||||
return get_setting("BAMBU_RUN_MQTT_RESYNC_GAP_SECONDS", 90)
|
||||
|
||||
app_settings = _Settings()
|
||||
|
||||
Reference in New Issue
Block a user