Skip to content

setActiveTray function has inverted logic - skips updating active_tray #93

Description

@JuanPSuarez

Summary

setActiveTray function has inverted logic - skips updating active_tray field

Environment

  • OpenSpoolMan version: latest (from ghcr.io/drndos/openspoolman)
  • Deployment: ☑ Docker
  • Browser: Any
  • DISABLE_MISMATCH_WARNING set?: ☐ Yes ☑ No

Additional context

The setActiveTray function in spoolman_service.py has inverted logic in its condition check. It uses == instead of !=, causing it to skip updates when the tray is already assigned.
Steps to Reproduce:

  1. Assign a spool to external spool (tray 254) using "Fill" in OpenSpoolMan - works
  2. Start a print
  3. Try to reassign a different spool using "Fill" - shows "Skipping set active tray" in logs and fails to update SpoolMan

Expected Behavior:
Should update the active_tray field in SpoolMan when assigning a new spool to the tray
Actual Behavior:
Shows "Skipping set active tray" and doesn't update the SpoolMan database
Suggested Fix:
In spoolman_service.py, change line 179 from:
if not spool_extra.get("active_tray") or json.loads(spool_extra.get("active_tray")) == trayUid(ams_id, tray_id):
To:
if not spool_extra.get("active_tray") or json.loads(spool_extra.get("active_tray")) != trayUid(ams_id, tray_id):
The condition logic is inverted - it should update when the value is DIFFERENT (!=), not when it's the same (==).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions