2blane / OctoPrint-Webhooks

Make OctoPrint events call your custom webhooks!
GNU Affero General Public License v3.0
28 stars 19 forks source link

Using param @job.file.name in PrintDone event results in "None" #18

Closed derekantrican closed 4 years ago

derekantrican commented 4 years ago

If I use the following message for the PRINT DONE event:

image

I get a message like "None finished printing".

What is the correct parameter to use when getting the file name of a finished print?

unclej84 commented 4 years ago

Hi,

has this been using the test of the webhook or after a real print / dry-run? For test mode the filename is set to "None" - even if you have a file selected before.

Regards Jörg

derekantrican commented 4 years ago

No, this is for real prints. In fact, when I do a test webhook event I don't get "None" - I get the previously selected print name

derekantrican commented 4 years ago

@2blane Any insight on this?

2blane commented 4 years ago

The information isn't always provided. This plugin grabs as much info as it can from OctoPrint but a lot of fields can be blank depending on if OctoPrint gives us the data. If this is a recurring problem I will reopen, but for now I'd suggest try uploading and starting your job in different ways if possible to see if you can get the name field to fill out.

derekantrican commented 4 years ago

The name field is fine when it starts printing (I have another webhook for that) - it's just when it finishes printing that it doesn't have the name. So I'm not sure how a different method of uploading will fix this (in fact - I've tried multiple different ways of uploading - even just reprinting from OctoPrint's history all with the "None" name result in the print finished event)

derekantrican commented 3 years ago

It's been a long time (almost exactly a year) but this is definitely a recurring problem. It happens every time I print and I haven't been able to figure out an easy solution. Recently I've had more time and I've been working on a PR for #17 and may have time to look into this.

In the meantime, it seems that when the Print Done event is fired, the "job" payload is all null:

{
  "file": {
    "name": null,
    "path": null,
    "display": null,
    "origin": null,
    "size": null,
    "date": null
  },
  "estimatedPrintTime": null,
  "averagePrintTime": null,
  "lastPrintTime": null,
  "filament": null,
  "user": null
}

Any idea why this might be? Is anyone else seeing the same?

As a workaround it seems like I might be able to use @extra.name so I'll test that out

derekantrican commented 3 years ago

A little bit more digging:

It seems that @job has many null (or None) values because @job comes from self._printer.get_current_data(). At the time of the PrintDone event, that returns the values in the comment above. However, the PrintDone event's payload (@extra) has the info needed.

I would suggest that either:

Thoughts?