Hacking Printrun to send a chat message when a job is finished

My Prusa lives in the workshop room but my main PC lives in our main living area.  In order to be notified when a print is finished I have made a little hack in Printrun so that it sends a message over XMPP to my chat client when the print is finished.

(Note: My version of Printrun is not yet in sync with the latest from Kliment because mine uses Skeinforge and his uses SFACT. If you use SFACT and want this hack then let me know and I will create a branch in my repo to mirror the latest version from Kliment.)

First install the xmpppy library. I used pip:

pip install xmppy

Second step is optional, but I created a jabber account for the printer at jabber.org, so as not to use my day-to-day account:

garyhodgson_3dprinter_prusa@jabber.org

Finally, with the hacked version of pronterface, enter the new xmpp settings in the options tab:

  • xmpp_notification_jid : The jabber id used to send the message.
  • xmpp_notification_password : The password of the jabber id used above.
  • xmpp_notification_server : The server name of the jabber service you wish to use, e.g. jabber.org
  • xmpp_notification_target_jid : the jabber id of the account you wish to send a message to.

(Note: The port defaults to 5222, but it would be trivial to turn this into a setting too.)

That’s it.  Now Printrun will send a message when the job is finished:

One small hiccup I did find is that Printrun calls the “end callback” function when the job is paused as well as at the very end.  This means the message is sent when the job is paused, which is something I can live with at the moment.

The actual code change can be seen in this commit (but note that a later commit fixes the indentation :))

Comments are closed.