This plugin provides HTML5 Web Push Notifications for OctoPrint completed jobs. This allows you to recieve web push notifications where Web Push Notifications are implemented, see browser support for Push API. Android and most desktop browsers implement this service, while notably iPhone does not yet support it. However, progress is being made and when completed, this plugin should work there as well.
The advantage of HTML5 Web Push Notifications is no 3rd party service needs to be installed on your device to recieve push notifications! However, you may need to configure your OctoPrint instance to be served from a secure origin if it is not already. See below for details.
Due to dependency clashes with older versions of OctoPrint's dependencies, this plugin requires at least verions 1.3.5 of OctoPrint.
Install via the bundled Plugin Manager or manually using this URL:
https://github.com/jcbelanger/OctoPrint-WebNotifications/archive/master.zip
OctoPi users installing via pip should be sure to use the correct python installation:
/home/pi/oprint/bin/python -m pip install https://github.com/jcbelanger/OctoPrint-WebNotifications/archive/master.zip
Web browsers will only offer web notifications if your OctoPrint instance is served from a secure origin! Examples of secure origins are localhost and websites served through https with valid certificates. For OctoPi users, this means the default self-signed certificate will not work! The basic steps for serving your home OctoPi instance from a secure origin are:
- Be sure access control is enabled and you have created a user for OctoPrint's web interface. It would be irresponsible to expose your OctoPrint instance to the public without any authentication.
- Configure your home router to forward traffic on ports 80 and 443 to your OctoPrint instance.
- Register a domain pointing to your home router. There a number of services that offer free domains.
- Use LetsEncrypt to generate a free https certificate for your domain. I've included
le.sh
for this purpose. For example, if your domain wasmypi.com
, you would run the script assudo ./le.sh mypi.com
. OctoPi users comfortable with running the script with admin rights directly from this repository can do so withcurl -s https://raw.githubusercontent.com/jcbelanger/OctoPrint-WebNotifications/master/le.sh | sudo bash -s mypi.com
wheremypi.com
is your domain. - Visit your domain via https. For example https://mypi.com .
- Accept the browser's permission request for push notifications. You may need to re-enable the permission if you accidentally reject the permission request.
Overview of le.sh
- The script will install LetsEncrypt's certbot tool.
- It will then temporarily stop OctoPi's HAProxy for certbot.
- Certbot will request a new certificate for your domain by answering Let's Encrypt's validation challenges.
- It will then overwrite the existing self-signed cert with the certificate from letsencrypt.
- It will then restart HAProxy to enable the new cert.
- TODO: I need to create a cron job to automatically renew the certifiacte -- This isn't a problem for most home users as the certificate only needs to be valid once for the browser to allow push notifications.
- You may need to clear your browser's cache before your browser discovers the new certificate.
- You may need to re-enable push notifications for the site if you accidientally reject the site's permission request.