summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--__init__.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..996c96f
--- /dev/null
+++ b/__init__.py
@@ -0,0 +1,42 @@
+# coding=utf-8
+from __future__ import absolute_import
+from sleekxmpp import ClientXMPP
+import octoprint.plugin
+
+__plugin_name__ = "OctoXMPP"
+__plugin_version__ = "0.1.0"
+__plugin_description__ = "Notify about some Events over XMPP."
+
+class OctoXMPP(octoprint.plugin.EventHandlerPlugin,
+ octoprint.plugin.SettingsPlugin):
+
+ def initialize(self):
+ jid = self._settings.get("username")
+ passwd = self._settings.get("password")
+
+ self._xmpp = ClientXMPP(jid, passwd)
+ self._xmpp.add_event_handler("session_start", self._xmpp.send_presence)
+
+ self._xmpp.connect()
+ self._xmpp.process(block=False)
+
+ def get_settings_defaults(self):
+ return dict(jid="rupert@derflob.de", password="KosselMini", receivers=["derflob@derflob.de", "jabber@dermeb.de"])
+
+ def _msg_receivers(self, msg):
+ for r in self._settings.get("receivers"):
+ self._xmpp.send_message(mto=r, mbody=msg)
+
+ def on_event(self, event, data):
+ if (event == "PrintDone"):
+ self._msg_receivers("Zack, Feditsch!")
+ elif (event == "PrintFailed"):
+ self._msg_receivers("Da ging was schief!")
+ elif (event == "PrintPaused"):
+ self._msg_receivers("Druck pausiert.")
+ elif (event == "PrintResumed"):
+ self._msg_receivers("Druck resümiert.")
+ elif (event == "PrintCancelled"):
+ self._msg_receivers("Druck abgebrochen!")
+ else:
+ self._xmpp.send_message(mto="derflob@derflob.de", mbody=event)