taxilian / OctoPrint-Twilio

Octoprint plugin for print completion notifications using Twilio (for free w/ trial account)
GNU Affero General Public License v3.0
5 stars 9 forks source link

Feature: Add option to send webcam snapshot along with the notification. #5

Closed shadycuz closed 6 years ago

shadycuz commented 6 years ago

Fixes #2 (request for this feature)

Adds a new requirement for "requests" package.

I placed your original code in a function. I then added an If at the top of on_event to look to see if the user has enabled snapshot or not. If so we grab an image from the camera, upload to upload.im and send a notification with a picture msg. If at any point in time this fails we fall back on a regular notification.

Twilio requires the image to be uploaded to a public URL. I'm using upload.im for this purpose. Due to this I have strongly warned the user.

image

I have tested this on my printer and it works OctoPrint 1.3.6 running on OctoPi 0.13.0. I did not get to test failure of third party services like twillio and uploads.im but logic is in place that should deal with it gracefully. Also added logging where it might be needed.

2018-01-14 20:34:32,392 - octoprint.util.comm - INFO - Finished in 0.037 s.
2018-01-14 20:34:32,407 - octoprint.plugins.smsnotifier - INFO - Taking Snapshot.... Say Cheese!
2018-01-14 20:34:33,553 - octoprint.plugins.smsnotifier - INFO - Processing /tmp/tmpsaaPKx.jpg before uploading.
2018-01-14 20:34:41,434 - octoprint.plugins.smsnotifier - INFO - Snapshot uploaded to to http://sk.uploads.im/T1HbB.jpg
2018-01-14 20:34:42,154 - octoprint.plugins.smsnotifier - INFO - Print notification sent to xxxxxxxx

image

image

All that is left I think is to increment the version number. Wasn't sure what you wanted. "0.3.0"?

shadycuz commented 6 years ago

@taxillan

taxilian commented 6 years ago

I haven't had time to test this, but I have merged it, updated the version to 0.3.0, and published it to pypi (https://pypi.python.org/pypi?name=OctoPrint-Twilio&version=0.3.0&:action=display)