From e16a36c0ab83bdcb69a1db0c66404654a489100e Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 22 Jul 2021 09:17:05 +0100 Subject: [PATCH] Don't report progress on 100 and better times Fixes #5 and fixes #6 --- octoprint_matrix_notifier/plugin.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/octoprint_matrix_notifier/plugin.py b/octoprint_matrix_notifier/plugin.py index dc4993b..5ca64da 100644 --- a/octoprint_matrix_notifier/plugin.py +++ b/octoprint_matrix_notifier/plugin.py @@ -48,7 +48,7 @@ def get_settings_defaults(self): **File**: {filename} **User**: {user} - **Time**: {elapsed_time} / {total_estimated_time} + **Elapsed Time**: {elapsed_time} {temperature} """), "enabled": True, @@ -59,7 +59,7 @@ def get_settings_defaults(self): **File**: {filename} **User**: {user} - **Time**: {elapsed_time} / {total_estimated_time} + **Elapsed Time**: {elapsed_time} {temperature} """), "enabled": True, @@ -70,7 +70,9 @@ def get_settings_defaults(self): **File**: {filename} **User**: {user} - **Time**: {elapsed_time} / {total_estimated_time} + **Elapsed Time**: {elapsed_time} + **Remaining Time**: {remaining_time} + **Total Estimated Time**:{total_estimated_time} {temperature} """), "enabled": True, @@ -81,7 +83,9 @@ def get_settings_defaults(self): **File**: {filename} **User**: {user} - **Time**: {elapsed_time} / {total_estimated_time} + **Elapsed Time**: {elapsed_time} + **Remaining Time**: {remaining_time} + **Total Estimated Time**:{total_estimated_time} {temperature} """), "enabled": True, @@ -210,7 +214,10 @@ def on_event(self, event, payload): def on_print_progress(self, storage, path, progress): interval = self._settings.get(["events", "progress", "interval"]) or 1 - if not progress or not(progress / interval == progress // interval): + # Do not report if no progress, the progress isn't a multiple of + # interval or the progress is 100% because we have PrintCompleted for + # that. + if not progress or not(progress / interval == progress // interval) or progress == 100: return if self._settings.get(["events", "progress", "enabled"]):