Closed PurpleHullPeas closed 4 years ago
The functionality would have to be added, but don't think it would be too difficult to accomplish.
I've added the options into my current dev branch for 0.9.17. Use the url below in plugin manager to install and let me know how it goes. My initial testing with a virtual printer mimicking an error and manually disconnecting seems to be working as expected.
https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/archive/0.9.17.zip
Thanks for the rapid response. Here are some notes from my initial testing.
Currently testing on a Monoprice Mini Delta 3D printer with stock firmware because my other two 3D printers are in pieces for upgrades.
While both "off on disconnect" and "auto disconnect" are selected, I'm unable to turn the printer back on following a power-off event. I.E., as soon as it turns on it turns back off (even with autoconnect off). This is even when "off on error" is not selected. Changing the auto disconnect delay to 15 seconds only delays the power off.
Set A: Off on Error Only Test 1A - Unplug printer - SerialException Error, smartplug remains on. Test 2A - Unplug USB - SerialException Error, smartplug remains on. Test 3A - Unplug thermistor - no error reported, but temperature goes up to a crazy high number Notes: I have another idea for an error test, but I don't have time for it tonight.
Set B: Off on Disconnect Only Test 1B - Unplug printer - smartplug turned off Test 2B - Unplug USB - smartplug turned off Test 3B - N/A Test 4B - Disconnect printer using Octoprint button - smartplug turned off.
Set C: Off on Error, Off on Disconnect, Thermal Runaway Test 1C - Unplug printer - smartplug turns off Test 2C - Unplug USB - smartplug turns off Test 3C - Unplug thermistor - no error reported, but temperature goes up to a crazy high number. Printer remains on. Test 4C - Disconnect printer using Octoprint button - smartplug turned off.
Set D: Thermal Runaway Tests Thermal runaway appears to work if I tell the printer to heat up and it heats beyond the specified temperature. However, it still fails Test 4 where as soon as I unplug the thermistor, the temperature readings go above 400 and are reported within Octoprint. This probably belongs in a separate issue. I guess I should add, that stock firmware for that printer doesn't trigger MINTEMP or MAXTEMP internally when the thermistor is shorted out; however, Marlin4MPMD firmware addresses this. I should be able to test this with the open source firmware soon.
These are very unexpected results. As for the thermal runaway issues, I'm confused how OctoPrint reports a temp when a thermistor is disconnected. Do me a favor and enable debug logging during testing and upload the plugin_tplinksmartplug_debug.log file from logging section of settings. Also, verify if there are any errors in octoprint.log during startup and testing times.
I think C was the testing method I was using, with the exception of thermal runaway was not enabled, but Off on Error and Off on Disconnect were enabled along with the equivalent monitoring options. I had disabled all other options for the specific plug to control.
The debug log looks a bit crowded because I guess it is collecting data for two different octoprint instances.
I also did another test with just "Disconnect on Error" enabled. I forced a thermal runaway error by unplugging the hotend heater wires.
Recv: Error:Heating failed, system stopped! Heater_ID: 0 Recv: Error:Printer halted. kill() called! Send: N23 M10522 WARNING! Received an error from the printer's firmware, ignoring that as configured but you might want to investigate what happened here! Error: Heating failed, system stopped! Heater_ID: 0 - Printer halted. kill() called! Send: N24 M10517
The smartplug remained on until the following timeout message was received:
No response from printer after 3 consecutive communication timeouts, considering it dead. Configure long running commands or increase communication timeout if that happens regularly on specific commands or long moves. Changing monitoring state from "Operational" to "Offline (Error: Too many consecutive timeouts, printer still connected and alive?)" Connection closed, closing down monitor
Sorry for 3 replies in a row, but I have an easier way for you to test the Thermal Runaway problem for yourself.
So, it appears that thermal runaway is only watching the temperature if the user has commanded the printer to heat up. In the event of a mosfet failure, the printer will heat up regardless of whether or not any commands have been sent. That being said, I imagine most mosfet failures (like mine) occurred while the printer was commanded to some temperature.
I'm confused about this line in your above post:
WARNING! Received an error from the printer's firmware, ignoring that as configured but you might want to investigate what happened here! Error: Heating failed, system stopped! Heater_ID: 0 - Printer halted. kill() called!
Do you have some exception configured? That may be the reason why the Error event isn't getting detected right away.
There is an option in Octoprint to do one of the following: a. Disconnect on Error (default) b. Stop printing, but remain connected on error. c. Ignore Error
I had it set to C because I was testing to see if the plugin would shutdown due to an error that is not accompanied by disconnect. Now that I think about it, having the options I listed above makes "Off on Error" a bit redundant. So, for safety issues, it's probably okay to select (a) above in main settings and then "Off on Disconnect" in your plugin.
For this issue, I think removing the "Off on Error" option and keeping the "Off on Disconnect" option should be fine, especially given the built-in Octoprint option of "Disconnect on Error." The issue of not being able to turn the printer back on while both "off on disconnect" and "auto disconnect" are selected may need to be addressed unless that's a printer specific thing.
The issue of max temperature not getting triggered while the printer is idle (i.e., not actively trying to heat up) is still there, but from a safety standpoint, that could be covered by using MAXTEMP protection in the firmware (e.g. flashing Marlin), Octoprint's built-in Disconnect on Error option, and the "Off on Disconnect" feature in this enhancement.
I was going to dig into these issue this weekend. It makes sense to eliminate the Off on Error
option like you said if you can force the Disconnect on Error with built in OctoPrint options, but if I can get it to work with both I will. Need to look at the temperature thing in more detail.
I just made a small change to the 0.9.17 branch that should resolve the temperature runaway issue. If you could reinstall and see if it makes any difference with your thermal runaway test that would be helpful. I think what was happening was because it was also checking to see if there was a target temperature (in your case there wasn't one set) it wasn't triggering the off action.
Just tested. The latest update appears to have fixed the thermal runaway issue.
Released with 0.9.17 version, closing.
I just installed the plugin last night. Really great work! Worth it just for the thermal runaway protection alone as most printers' firmware thermal runaway protection cannot account for a mosfet failure. I was wondering if there was a way to automatically turn off the printer/plug in the event that the printer encounters an error and/or if the printer loses connection at all. E.G., by default, Octoprint will disconnect if it detects an error in the terminal, but I would like to also turn off the smart plug in the event of such an error.