anoved / OctoPrint-EmailNotifier

Receive email notifications when OctoPrint jobs are complete. Currently broken. Please fork and fix!
GNU Affero General Public License v3.0
16 stars 35 forks source link

Support notifications for other events #1

Open anoved opened 8 years ago

anoved commented 8 years ago

Currently notifications are only sent in response to the PrintDone event, but there are many others.

anoved commented 8 years ago

@foosel @dcwalmsley I created a multievent branch of this plugin that supports email notifications for arbitrary events as discussed in foosel/Octoprint#1070. It is configured with a dict of event names, each with their own notification settings. Any of the event's payload properties can be used in the message template.

Here's an example of what the config looks like now:

  emailnotifier:
    _config_version: 2
    mail_server: smtp.gmail.com
    mail_username: jim.devona@gmail.com
    notifications:
      FileSelected:
        body: '{file} selected for printing.'
        enabled: true
        snapshot: false
        title: Selected {filename}
      MovieDone:
        body: Timelapse of printing {gcode} saved as {movie}.
        enabled: true
        snapshot: false
        title: 'Timelapse rendered: {movie_basename}'
      PrintDone:
        body: '{file} done in {time}.'
        enabled: true
        snapshot: true
        title: 'Print complete: {file}'
    recipient_address: jim@anoved.net

Unfortunately I haven't figured out how to make a settings template interface for notifications, so it has to be edited manually.

anoved commented 8 years ago

As an interim interface solution, the Yamlpatcher plugin can be used to add/edit/remove notifications.

Adding an event notification using yaml patch: yamlpatcher-emailnotifier

Removing an event notification using JSON command: remove-notification

anoved commented 8 years ago

Here is a rough static HTML mockup of the settings interface I envision for multiple notifications.

notifiationsettings

Clicking Add would add another row to the table. Select from available Event names and edit message templates. I'm not sure how to achieve this, though. Do any existing plugins offer a similar interface? I find the Jinja2/knockout/viewmodel/Javascript documentation a bit too overwhelming to work it out from scratch.

foosel commented 8 years ago

@anoved you could take a look at the temperature profile or the terminal filter configuration pages in the OctoPrint settings, those follow a similar pattern:

image

Interesting source code locations:

anoved commented 8 years ago

Thanks for the pointers. Perfect example. I will take a shot at it soon.