eyal0 / OctoPrint-TimeToFilament

Display time until next filament change and other time-until-whatever info in OctoPrint
3 stars 1 forks source link

Add API #40

Closed kaenguruhs closed 1 year ago

kaenguruhs commented 1 year ago

This adds an API for external applications, reachable via octopi.local/plugin/TimeToFilament.

eyal0 commented 1 year ago

This adds an API for external applications, reachable via octopi.local/plugin/TimeToFilament.

Thanks for your help!

Can you give an example of an external application that would use this?

Maybe this is a silly question but... why not just simply return the data as-is and let the external app deal with the formatting and stuff? Presumably the external app could do whatever it wants.

kaenguruhs commented 1 year ago

Hi eyal0,

you got me - Java and not python is my home turf :-) I will go through your suggested changes and add a commit. First of all: The application using this API could be Octodash. There was an issue, but it was closed because of the missing API in TimeToFilament: https://github.com/UnchartedBull/OctoDash/issues/1547

To the formatting-thing: Isn't it quite difficult for external applications to decide how to format it right? E.g.: In my setup, it is neccessary to add +1 to the layer (Layer ${parseInt(this.plugins.TimeToFilament["^;LAYER:(\\d+)"].groups[0])+1} in <b>${formatDuration(this.progress.printTimeLeft - this.plugins.TimeToFilament["^;LAYER:(\\d+)"].timeLeft)}</b>) because layering starts with 0. I'd like to have all config for this at one place, not distributed. What do you think?

eyal0 commented 1 year ago

I'll assume that you tested this alright? This is a pretty low-risk feature to add because it'll only affect people that try to use it.