diff --git a/octoprint_signalclirestapi/__init__.py b/octoprint_signalclirestapi/__init__.py index 2fe5496..a13116e 100644 --- a/octoprint_signalclirestapi/__init__.py +++ b/octoprint_signalclirestapi/__init__.py @@ -107,10 +107,12 @@ def get_settings_defaults(self): printfailedevent=True, printcancelledevent=True, printpausedevent=True, + filamentchangeevent=True, printresumedevent=True, printstartedeventtemplate="OctoPrint@{host}: {filename}: Job started.", printdoneeventtemplate="OctoPrint@{host}: {filename}: Job complete after {elapsed_time}.", printpausedeventtemplate="OctoPrint@{host}: {filename}: Job paused!", + filamentchangeeventtemplate="OctoPrint@{host}: Filament change required!", printfailedeventtemplate="OctoPrint@{host}: {filename}: Job failed after {elapsed_time} ({reason})!", printcancelledeventtemplate="OctoPrint@{host}: {filename}: Job cancelled after {elapsed_time}!", printresumedeventtemplate="OctoPrint@{host}: {filename}: Job resumed!", @@ -152,6 +154,10 @@ def print_failed_event(self): def print_paused_event(self): return self._settings.get_boolean(["printpausedevent"]) + @property + def filament_change_event(self): + return self._settings.get_boolean(["filamentchangeevent"]) + @property def print_cancelled_event(self): return self._settings.get_boolean(["printcancelledevent"]) @@ -183,6 +189,10 @@ def print_started_event_template(self): @property def print_paused_event_template(self): return self._settings.get(["printpausedeventtemplate"]) + + @property + def filament_change_event_template(self): + return self._settings.get(["filamentchangeeventtemplate"]) @property def print_cancelled_event_template(self): @@ -307,6 +317,12 @@ def on_event(self, event, payload): self._create_group_if_not_exists() message = self.print_paused_event_template.format(**supported_tags) self._send_message(message) + elif event == "FilamentChange": + if self.enabled and self.filament_change_event: + if self.create_group_for_every_print: + self._create_group_if_not_exists() + message = self.filament_change_event_template.format(**supported_tags) + self._send_message(message) elif event == "PrintResumed": if self.enabled and self.print_resumed_event: if self.create_group_for_every_print: diff --git a/octoprint_signalclirestapi/templates/signalclirestapi_settings.jinja2 b/octoprint_signalclirestapi/templates/signalclirestapi_settings.jinja2 index 41da411..94f86a2 100644 --- a/octoprint_signalclirestapi/templates/signalclirestapi_settings.jinja2 +++ b/octoprint_signalclirestapi/templates/signalclirestapi_settings.jinja2 @@ -127,6 +127,25 @@