diff --git a/octoprint_telegram/__init__.py b/octoprint_telegram/__init__.py index e7a3e4c..590f7f4 100644 --- a/octoprint_telegram/__init__.py +++ b/octoprint_telegram/__init__.py @@ -86,20 +86,9 @@ def run(self): elif command=="/status": if self.main._printer.is_printing(): status = self.main._printer.get_current_data() - self.main.on_event("TelegramSendStatus", {'z': (status['currentZ'] or 0.0)}) + self.main.on_event("TelegramSendPrintingStatus", {'z': (status['currentZ'] or 0.0)}) else: - temps = self.main._printer.get_current_temperatures() - # {'bed': {'actual': 1.0, 'target': 1.0, 'offset': 0}, 'tool0': {'actual': 164.76, 'target': 220.0, 'offset': 0}} - # {'bed': {'actual': 0.0, 'target': 0.0, 'offset': 0}, 'tool0': {'actual': 18.7, 'target': 0.0, 'offset': 0}} - msg = "Not printing." - msg+="\n\nTemperatures:\n" - if not (temps['bed']['actual']==0.0 and temps['bed']['target']==0.0) and not (temps['bed']['actual']==1.0 and temps['bed']['target']==1.0): - msg += "Bed: " + str(temps['bed']['actual']) + "/" + str(temps['bed']['target']) + "\n" - if "tool0" in temps: - msg += "Extruder 1: {0} (Target {1})\n".format(temps['tool0']['actual'], temps['tool0']['target']) - if "tool1" in temps: - msg += "Extruder 2: {0} (Target {1})".format(temps['tool1']['actual'], temps['tool1']['target']) - self.main.send_msg(msg) + self.main.on_event("TelegramSendNotPrintingStatus", {}) elif command=="/help": msg = "You can use following commands:\n" msg+= "/photo - Sends a current photo.\n" @@ -194,6 +183,7 @@ def get_settings_defaults(self): PrintFailed = "Printing {file} failed.", ZChange = "Printing at Z={z}.\nBed {bed_temp}/{bed_target}, Extruder {e1_temp}/{e1_target}.\n{time_done}, {percent}% done, {time_left} remaining.", PrintDone = "Finished printing {file}.", + TelegramSendNotPrintingStatus = "Not printing.\nBed {bed_temp}/{bed_target}, Extruder {e1_temp}/{e1_target}." ) ) @@ -221,7 +211,7 @@ def is_notification_necessary(self, new_z, old_z): def on_event(self, event, payload, *args, **kwargs): try: - if event != "PrintDone" and event != "PrintStarted" and event != "ZChange" and event!="PrintFailed" and event!="TelegramSendStatus": + if event != "PrintDone" and event != "PrintStarted" and event != "ZChange" and event!="PrintFailed" and event!="TelegramSendPrintingStatus" and event!="TelegramSendNotPrintingStatus": # return as fast as possible return @@ -260,7 +250,7 @@ def on_event(self, event, payload, *args, **kwargs): return if not self._settings.get_boolean(["message_at_print_failed"]): return - elif event=="TelegramSendStatus": + elif event=="TelegramSendPrintingStatus": z = payload['z'] # Change the event type in order to generate a ZChange message event = "ZChange" diff --git a/octoprint_telegram/templates/telegram_settings.jinja2 b/octoprint_telegram/templates/telegram_settings.jinja2 index 13b8544..d415f3e 100644 --- a/octoprint_telegram/templates/telegram_settings.jinja2 +++ b/octoprint_telegram/templates/telegram_settings.jinja2 @@ -84,6 +84,11 @@ - +