Skip to content

Commit 7b1b711

Browse files
committed
Enhance PrintJobTracker to backfill filamentUsed from job data for compatibility with new OctoPrint versions
1 parent 1a0af19 commit 7b1b711

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

octoprint_obico/print_job_tracker.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ def status(self, plugin, status_only=False):
9696
data['status']['_ts'] = int(time.time())
9797
data['status']['currentLayerHeight'] = self.current_layer_height # use camel-case to be consistent with the existing convention
9898

99+
# Backfill progress.filamentUsed from job.filament.tool0.length for new OctoPrint versions
100+
progress = data.get('status', {}).get('progress', {})
101+
if progress and 'filamentUsed' not in progress:
102+
filament_length = data.get('status', {}).get('job', {}).get('filament', {}).get('tool0', {}).get('length')
103+
if filament_length is not None:
104+
progress['filamentUsed'] = filament_length
105+
99106
if status_only:
100107
if self._file_metadata_cache:
101108
data['status']['file_metadata'] = self._file_metadata_cache

0 commit comments

Comments
 (0)