-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Custom script / event support #74
Comments
Hi @irStoopid 80% of the work required here is determine the best way to get your event to the plugin. Luckily OctoPrint already has a mechanism to support the bulk of this functionality. The above SimpleApiPlugin would allow you to post name/value pairs (in JSON) and generate notifications accordingly. Where things get a bit tricky if where you mentioned wanting to introduce conditional logic (e.g. return code == 0). It seems reasonable to add some conditional logic but we'd want to be careful not to overcomplicate the solution - if your source is say a shell script, any complicated logic would likely be better served there rather than anything I whip up within the plugin. here's a rough idea of how this might work:
Thoughts? |
Hi @fraschetti Thanks for the quick response on this. I like the idea of having a more generic API which does not require actively calling scripts of one sort or another as this would definately be more secure and less likely to negatively affect performance compared to calling user definable scripts. A downside however could be that it's slightly more work for a user to ensure some process will run in the background and talk to an API provided than it would be compared to providing a script path and and interval at which it should be run. You mention moving the conditional logic into the scripts. Having all conditionals outside Octoslack would mean simply not perfoming a json POST and thus not sending a notification when this is not required. That would mean that there would also be no need for user definable handlers, as any non-empty request could be used as is for notifications (might be oversimplified). I.e. as I see it custom handlers need not be used to get this to work. Though ofcourse they would allow for a more easy way of configuration. All in all, I think that the SimpleApiPlugin method you propose would make a great addition to Octoslack! |
It's great having a notification interface on octoprint using slack, but I've been tinkering with the idea of expanding the notification support by triggering custom scripts (eg. python or bash) on a set interval and sending a notification Conditionally based on the script output.
For example; I'm running octoprint on a spare netbook. Should it get disconnected from mains power and drain the battery it would be great to be able to send notifications based on certain thresholds.
This is something I'd like to be notified of regardless of printing status, and only conditionally send me a notification based on set conditions, in this case battery status.
One could imagine a feature where if the script return code is 0, the script output is sent as text.
Custom system commands are already included in the current feature-set, but only on an interval / progress when printing or on custom Gcode events (when of course printing).
Sending a notification based on a system command output is currently also unconditional.
The text was updated successfully, but these errors were encountered: