Skip to content

Added plugin maintenance_reminder#1458

Open
GarronAnderson wants to merge 6 commits into
OctoPrint:gh-pagesfrom
GarronAnderson:gh-pages
Open

Added plugin maintenance_reminder#1458
GarronAnderson wants to merge 6 commits into
OctoPrint:gh-pagesfrom
GarronAnderson:gh-pages

Conversation

@GarronAnderson

Copy link
Copy Markdown

Added a plugin which provides a simple maintenance reminder function. It counts prints and keeps track of what maintenance is due.

  • You have read the "Registering a new Plugin" guide.
  • You want to and are able to maintain the plugin you are registering, long-term.
  • You understand why the plugin you are registering works.
  • You have read and acknowledge the Code of Conduct.

What is the name of your plugin?

OctoPrint-Maintenance Reminder

What does your plugin do?

It counts your prints and reminds you to perform periodic maintenance before each print if it is due. I wrote this because I wanted a plugin to remind me to wash my PEI sheet and one did not exist.

Where can we find the source code of your plugin?

https://github.com/GarronAnderson/OctoPrint-Maintenance-Reminder

Was any kind of genAI (ChatGPT, Copilot etc) involved in creating this plugin?

ChatGPT was used for some help with JavaScript (I'm a Python guy and the syntax is weird). No agents such as Claude Code were used. A lot of inspiration was me (the human) looking at code for octoprint-spoolman and Top Temp.

Is your plugin commercial in nature?

No, not at all.

Does your plugin rely on some cloud services?

No. I may add support for notifications through ntfy.sh in the future.

Further notes

Added a plugin which provides a simple maintenance reminder function. It counts prints and keeps track of what maintenance is due.

@jneilliii jneilliii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There actually is an unlisted plugin that has been around for quite some time https://github.com/OllisGit/OctoPrint-MaintenanceManager. Looks like the PR validations are failing though, which most likely is a yaml formatting issue.

octoscanner also flagged these items...

╭──────────────────────────────────────────────────── OctoScanner ─────────────────────────────────────────────────────╮
│                                                                                                                      │
│ ╭─ Plugin C:\Users\Jim Neill\Documents\3D Prints\PrinterUprades\OrdBotHadron\OctoprintRelated\octoscanner\plugins_─╮ │
│ │ ╭───────────────────────────────────────── Summary (2 total findings) ─────────────────────────────────────────╮ │ │
│ │ │ 2 security                                                                                                   │ │ │
│ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │ │
│ │ ╭─────────────────────────────────────────── Security (2 findings) ────────────────────────────────────────────╮ │ │
│ │ │ SEC-0001                                                                                                     │ │ │
│ │ │ Plugin implements SimpleApiPlugin but does not override is_api_protected(). Until OctoPrint 2.1.0, the       │ │ │
│ │ │ default implementation returns False, allowing unauthenticated access to SimpleApi endpoints.                │ │ │
│ │ │ File: octoprint_maintenance_reminder\__init__.py:10                                                          │ │ │
│ │ │        9 |                                                                                                   │ │ │
│ │ │   >   10 | class MaintenanceReminderPlugin(                                                                  │ │ │
│ │ │       11 |     octoprint.plugin.SettingsPlugin,                                                              │ │ │
│ │ │ Suggestion: Override is_api_protected() to explicitly return True. Note that this only controls              │ │ │
│ │ │ authentication; you should also verify permissions explicitly in each API handler (e.g.                      │ │ │
│ │ │ Permissions.PLUGIN_MYPLUGIN_ACCESS).                                                                         │ │ │
│ │ │                                                                                                              │ │ │
│ │ │ SEC-0007                                                                                                     │ │ │
│ │ │ Plugin implements TemplatePlugin but does not override is_template_autoescaped(). Until OctoPrint 2.1.0, the │ │ │
│ │ │ default implementation returns False, exposing the templates to XSS via unescaped variables.                 │ │ │
│ │ │ File: octoprint_maintenance_reminder\__init__.py:10                                                          │ │ │
│ │ │        9 |                                                                                                   │ │ │
│ │ │   >   10 | class MaintenanceReminderPlugin(                                                                  │ │ │
│ │ │       11 |     octoprint.plugin.SettingsPlugin,                                                              │ │ │
│ │ │ Suggestion: Override is_template_autoescaped() to return True and use the safe Jinja filter only for         │ │ │
│ │ │ variables that legitimately need to render HTML. See https://faq.octoprint.org/plugin-autoescape.            │ │ │
│ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                                      │
│ ╭──────────────────────────── Rule Statistics (2 rules matched 2 times on 1/1 plugins) ────────────────────────────╮ │
│ │ Matches  Rule ID   Message                                                                                       │ │
│ │       1  SEC-0001  Plugin implements SimpleApiPlugin but does not override is_api_protected(). Until OctoPrint   │ │
│ │                    2.1.0, the default implementation returns False, allowing unauthenticated access to           │ │
│ │                    SimpleApi endpoints.                                                                          │ │
│ │       1  SEC-0007  Plugin implements TemplatePlugin but does not override is_template_autoescaped(). Until       │ │
│ │                    OctoPrint 2.1.0, the default implementation returns False, exposing the templates to XSS      │ │
│ │                    via unescaped variables.                                                                      │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Once these issues are addressed I can do a full review.

Comment thread _plugins/maintenance_reminder.md
@jneilliii

Copy link
Copy Markdown
Contributor

I did just take a quick peak at the plugin code, and their is definitely better approaches over monkeypatching the UI in your js. I'd recommend looking at onBeforePrintStart viewmodel callback. This will allow you to achieve what you are trying to do without interfering with the core OctoPrint code/functions. An example of using this callback can be found in our Bambu plugin here.

Changed from 4 spaces on the YAML to 2 spaces. Added compatibility information per jneilliii.
@GarronAnderson

Copy link
Copy Markdown
Author

Thank you so much for the information @jneilliii ! I did not know about the viewmodel callback and was working off of what octoprint-spoolman had done.

@jneilliii

Copy link
Copy Markdown
Contributor

Another thing that first time plugin developers usually have trouble understanding is knockout bindings. For example, your progress bars could utilize the progress data-binding the way that OctoPrint uses it internally. Example is the gcode viewer that has this type of binding here which on the js side is defined and updated via observables here.

Another example, is instead of adding a click callback via jQuery in your plugin here you could use the knockout data-bind 'click' in your jinja2 file. Are you doing it this way just because your current implementation of the popover is being built on the fly via js for your navbar button? I would recommend looking at other examples that use native dropdown for this like here in my MQTTPublish plugin. This would also eliminate the need for assigning your viewmodel to the window context here I think.

I'm typically online in the OctoPrint Discord server, so if you want to jump in and discuss these options further or need more clarification I'm happy to help in the #dev-plugins channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants