mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-19 15:54:27 +02:00
Show Spoolman fill level for AMS Lite and external spools (#293)
AMS Lite units (A1 series) have no weight sensor and always report 0% fill level. When a spool is linked to Spoolman with weight data, use Spoolman's remaining weight as a fallback. External spools also show fill level from Spoolman data instead of always showing unknown. Backend: Enrich GET /spoolman/spools/linked response with remaining_weight and filament_weight alongside spool ID. Frontend: Add getSpoolmanFillLevel() helper. Update regular AMS, HT AMS, and external spool fill computations to use Spoolman fallback when AMS reports 0%. Show "(Spoolman)" indicator in hover card when fill data comes from Spoolman.
This commit is contained in:
@@ -598,7 +598,7 @@ async def get_linked_spools(
|
||||
raise HTTPException(status_code=503, detail="Spoolman is not reachable")
|
||||
|
||||
spools = await client.get_spools()
|
||||
linked: dict[str, int] = {}
|
||||
linked: dict[str, dict] = {}
|
||||
|
||||
for spool in spools:
|
||||
# Check if spool has a tag in extra field
|
||||
@@ -608,7 +608,12 @@ async def get_linked_spools(
|
||||
# Remove quotes if present (JSON encoded string)
|
||||
clean_tag = tag.strip('"').upper()
|
||||
if clean_tag:
|
||||
linked[clean_tag] = spool["id"]
|
||||
filament = spool.get("filament") or {}
|
||||
linked[clean_tag] = {
|
||||
"id": spool["id"],
|
||||
"remaining_weight": spool.get("remaining_weight"),
|
||||
"filament_weight": filament.get("weight"),
|
||||
}
|
||||
|
||||
return {"linked": linked}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user