OctoPrint-Spoolman icon indicating copy to clipboard operation
OctoPrint-Spoolman copied to clipboard

[Request] Push plugin events with changes in filament usage, and selected tool(s)

Open davidzwa opened this issue 3 months ago • 1 comments

Is your feature request related to a problem? Please describe.

When FDM Monster is connecting to OctoPrint over websocket, I would like to be able to listen to events related to spool usage and selection. This optimizes FDM Monster's implementation: it does not have to query the plugin's API or spoolman continuously for changes in status (polling). Another advantage: FDM Monster is kept up-to-date about which Spoolman spool belongs to which OctoPrint printer, so it can update its UI with fresh information as soon as a change is made.

Another problem that FDM Monster can solve is to detect whether the same spool is assigned to multiple printers at the same time (this would be a conflicting situation). This is an added benefit, but not a high priority one.

Describe the solution you'd like

Push some events for usage and spool selection, which can be listened to over the Websocket event stream. FDM Monster will be able to pick up the event and immediately know which spools are associated to each printer in a farm, and also what extrusion stats were calculated so far. [EDIT] see comment below about using self._plugin_manager.send_plugin_message() instead https://docs.octoprint.org/en/master/plugins/hooks.html#octoprint-events-register-custom-events

Describe alternatives you've considered

Spoolman has no knowledge of printers, therefore FDM Monster would have to query all OctoPrint servers to see which Spoolman spool is associated with which printer. The same goes for spool usage and conflicting spool assignment (multiple printers same spool, edge case).

Additional context

It would be nice if, for example concerning spool usage, absolute values could be pushed (similar to "total extruded since print start" in grams or meters). This avoids external listeners like FDM Monster having to maintain a history of event messages in order to calculate complete spool usage until that point. Relative (temporal) values like increments in usage could be nice for graphing spool consumption over time, so its not a problem if they are included.

Another event that would be awesome to push is the event for spool/tool changes: Which spool id is associated to each print head (tool). I'm assuming multi-color prints here.

Concluding Since it is possible to define multiple tools for a multi-color print, the format of the event should adapt to that. It could contain multiple "tools", and each tool is associated to a spool. The event then contains data for multiple tools of which each entry contains: usage (grams), usage (percentage), spoolman id and tool number.

davidzwa avatar Apr 28 '24 13:04 davidzwa