Spoolman icon indicating copy to clipboard operation
Spoolman copied to clipboard

Include the incremental weight consumption in the web-socket spool_changed messages

Open chof747 opened this issue 8 months ago • 1 comments

I implemented this additional change to the spool_changed event to have a solution for the following problem. Maybe it is useful for others as well who want to get notified about the actual spool consumption.

Problem

I need to track the consumption - in weight - of spools in real time and I need to have the deltas without keeping the previous state.

Solution

I added the delta in weight (weight_decrement) as an extra information (under event_extra) to the data sent by the spool_changed websocket message.

Rationale

Placing this data under extra information does not seem to break anything and works for my purpose, although adding the delta in weight to the standard SpoolEvent attributes would be a cleaner and more intuitive solution.

chof747 avatar Apr 30 '25 16:04 chof747

Sorry for the lack of response,

This is a great addition! However I don't think it's good to slap it onto the Spool object, instead it should be on the the root level of the event instead, like "payload_extras": {"weight_delta": 12.5}, otherwise the data-model will be confusing.

You should additionally update the API by populating the field in api/v1/models.py under SpoolEvent

Donkie avatar May 31 '25 17:05 Donkie