Skip to content

Commit 7242b60

Browse files
authored
Klipper notifications (#118)
* Add custom notifications for Klipper Macros * Add extra check * Bump version to 2.1.13
1 parent 4d75589 commit 7242b60

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

moonraker_octoapp/moonrakerclient.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ def _OnWsOpenAndKlippyReady(self):
316316
"webhooks": None,
317317
"virtual_sdcard": None,
318318
"history" : None,
319+
"gcode_macro _OCTOAPP_STATUS": None,
319320
}
320321
})
321322

@@ -403,6 +404,15 @@ def _OnWsNonResponseMessage(self, msg:str):
403404
elif state == "complete":
404405
self.MoonrakerCompat.OnDone()
405406
return
407+
408+
# Check for notifications
409+
octoAppStatusContainerObj = self._GetWsMsgParam(msg, "gcode_macro _OCTOAPP_STATUS")
410+
if octoAppStatusContainerObj is not None:
411+
# Split text at ~~~ and take the first element (second half is CPU time to make the value change with same message repeated)
412+
gcodeNotification = octoAppStatusContainerObj["gcode_macro _OCTOAPP_STATUS"].get("notify_message", None)
413+
message = gcodeNotification.split("~~~")[0] if "~~~" in gcodeNotification else gcodeNotification
414+
if message != "":
415+
self.MoonrakerCompat.OnCustomNotification(message)
406416

407417
# Report progress. Do this after the others so they will report before a potential progress update.
408418
# Progress updates super frequently (like once a second) so there's plenty of chances.
@@ -912,6 +922,14 @@ def OnPrintPaused(self):
912922
fileName = stats["filename"]
913923
self.NotificationHandler.OnPaused(fileName)
914924

925+
# Called the the print is paused.
926+
def OnCustomNotification(self, message):
927+
# Only process notifications when ready, aka after state sync.
928+
if self.IsReadyToProcessNotifications is False:
929+
return
930+
931+
self.NotificationHandler.OnCustomNotification(message)
932+
915933

916934
# Called the the print is resumed.
917935
def OnPrintResumed(self):

octoprint_octoapp/webcamsnapshots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _doContinuouslyUpdateSnapshots(self):
116116
def _updateSnapshotCache(self, webcamIndex, log):
117117
try:
118118
webcamSettings = self._getWebcamSettingsItem(webcamIndex)
119-
snapshotUrl = webcamSettings.SnapshotUrl
119+
snapshotUrl = webcamSettings.SnapshotUrl if webcamSettings is not None else ""
120120

121121
if snapshotUrl == "" or snapshotUrl is None or (not snapshotUrl.startswith("http://") and not snapshotUrl.startswith("https://")):
122122
return True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
2424
# Note that this is also parsed by the moonraker module to pull the version, so the string and format must remain the same!
25-
plugin_version = "2.1.12"
25+
plugin_version = "2.1.13"
2626

2727
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2828
# module

0 commit comments

Comments
 (0)