jneilliii / OctoPrint-TasmotaMQTT

18 stars 16 forks source link

New update gcode handling #46

Open jneilliii opened 4 years ago

jneilliii commented 4 years ago

https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/issues/285#issuecomment-678742034

jneilliii commented 4 years ago

@yordanov-alexandar I don't think I'll be able to regret the change that caused this, because it was to fix another problem. I think it best you adopt the new idle timer in the latest version for powering off.

yordanov-alexandar commented 4 years ago

Sorry for the delay - I had a long print running. It works although it's less than ideal. However since this is free software I can't really complain :) But isn't it possible that this problem happens elsewhere too? Doesn't the "update mesh" code behave the same was as the octoprint's end gcode? If there is some long running command before the M81 in the end gcode wouldn't the same happen?

jneilliii commented 4 years ago

I think that when you press the update mesh button as long as the printer is doing something I'm pretty sure the idle timer gets reset if the time runs out, but have only tested this while printing, not while "updating mesh" so not 100% sure. I'd have to do some additional testing in regard to that.

It's kind of catch 22 in this situation, I can fix it for you so you can have power off for leveling, or fix the other issue where it causes firmware to crash. It's a matter of priority, I don't want to crash people's firmware.

yordanov-alexandar commented 4 years ago

I totally agree than the firmware crash is more important to solve :) Maybe there is a way to solve this on the Bed Visualizer side? The easiest way I can think of is to check the "update mesh" code and not send any M81 command(s) until Bed Visualizer is done? Or maybe there is a gcode command I can put in my "update mesh" code to wait until Bed Visualizer is done before sending the M81 ?

jneilliii commented 4 years ago

Good point. I'm not 100% sure, but a dwell command with an appropriate time limit might work.

yordanov-alexandar commented 4 years ago

Unfortunately G4 S240 had no effect - the printer still turned off after about 10 seconds

jneilliii commented 4 years ago

Yeah, I was afraid of that because the command still gets put into the queue and is held there until the printer reports ready.

yordanov-alexandar commented 4 years ago

How about something like this:

{% if plugins.bedvisualiser.state == 'done' %}
M81 xxxx
{% endif %}

Would something similar work? Or maybe with a loop every few seconds to check the state?

jneilliii commented 4 years ago

At that point, you're doing exactly what the idle timer is doing. I have to say I use that for my TPLink implementation and it works very well.

yordanov-alexandar commented 4 years ago

Well that's strange - when I told you that the idle timer was working - it did - I set the timer at 3 minutes and it turned off the printer a little before the bed leveling was over (turned out it takes about 3min 30sec for the bed leveling), then I increased it to 4 minutes and it passed although the printer stayed running a few minutes after it was over - much more than the about 30sec it should have stayed on according to my measurements. That's why I said it wasn't ideal - it was inconsistent. And that's why I proposed that pseudo jinja code above for checking the state... But now I tried again and I can't make it work... although I have the idle timer at 4 minutes it still turns off at the 10th second... I have the "Power Off on Idle" check checked, "Idle Timeout" at 4min, "Idle Target Temperature" at 40 degrees and "Off on Idle" check inside the relay editor checked. I think I had the same things the first time I tried. Am I missing something?

jneilliii commented 4 years ago

Your settings seem correct based on your description. The way the idle timer should work is as soon as you startup octoprint it triggers the start of the timer. Timer should also start when you power on a device. Once those 4 minutes are up it runs through a worker process that checks for current printer state, temps, timelapse, etc. to ensure you're not printing, the temp is below the threshold, and there are no timelapses currently rendering. If all of those things pass then it sends the power off command. If they do not pass, then the timer is reset and 4 minutes later it goes through the checks again.