Plugin System for Community Extensions #37

Open
opened 2026-01-16 05:06:49 +00:00 by tonym · 0 comments
Owner

Summary

Add a plugin architecture to allow community extensions without modifying core code.

Upstream Issue

Rationale

Some features are too niche for core but valuable to specific users:

  • Moonraker integration / auto-set spool ID
  • Home Assistant webhooks
  • Custom automation triggers
  • Slicer-specific integrations
  • Hardware integrations (scales, NFC readers)

Plugin system lets community build these without forking.

Possible Approaches

Option A: Backend Hooks (Python)

# plugins/my_plugin.py
from spoolman.plugins import hook

@hook("spool.created")
async def on_spool_created(spool):
    # Custom logic
    pass

@hook("spool.used")
async def on_spool_used(spool, amount):
    # Notify Home Assistant
    pass

Option B: Webhook Events

  • Configure webhook URLs in settings
  • Fire HTTP POST on events (spool created, used, low stock)
  • Simple, no code needed

Option C: Frontend Plugins (JS)

  • Load custom JS from plugins directory
  • Add custom buttons/panels to UI
  • More complex but powerful

Events to Hook

  • spool.created, spool.updated, spool.deleted
  • spool.used (filament consumed)
  • spool.low_stock (below threshold)
  • filament.created, filament.imported
  • print_job.created, print_job.completed
  • qr.scanned

Recommendation

Start with Option B (Webhooks) - simplest, covers 80% of use cases.
Add Option A (Python hooks) later for advanced users.

Complexity

This is a significant architectural addition. Consider:

  • Security implications of running user code
  • API stability for plugins
  • Documentation burden
  • Maybe lower priority than core features
## Summary Add a plugin architecture to allow community extensions without modifying core code. ## Upstream Issue - https://github.com/Donkie/Spoolman/issues/72 - Note: Donkie declined - wants to keep Spoolman focused ## Rationale Some features are too niche for core but valuable to specific users: - Moonraker integration / auto-set spool ID - Home Assistant webhooks - Custom automation triggers - Slicer-specific integrations - Hardware integrations (scales, NFC readers) Plugin system lets community build these without forking. ## Possible Approaches ### Option A: Backend Hooks (Python) ```python # plugins/my_plugin.py from spoolman.plugins import hook @hook("spool.created") async def on_spool_created(spool): # Custom logic pass @hook("spool.used") async def on_spool_used(spool, amount): # Notify Home Assistant pass ``` ### Option B: Webhook Events - Configure webhook URLs in settings - Fire HTTP POST on events (spool created, used, low stock) - Simple, no code needed ### Option C: Frontend Plugins (JS) - Load custom JS from plugins directory - Add custom buttons/panels to UI - More complex but powerful ## Events to Hook - `spool.created`, `spool.updated`, `spool.deleted` - `spool.used` (filament consumed) - `spool.low_stock` (below threshold) - `filament.created`, `filament.imported` - `print_job.created`, `print_job.completed` - `qr.scanned` ## Recommendation Start with **Option B (Webhooks)** - simplest, covers 80% of use cases. Add **Option A (Python hooks)** later for advanced users. ## Complexity This is a significant architectural addition. Consider: - Security implications of running user code - API stability for plugins - Documentation burden - Maybe lower priority than core features
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tonym/spoolman2#37
No description provided.