kantlivelong / OctoPrint-PSUControl

Smart control of your power supply via GPIO, GCODE Command, System Command, or variety of sub-plugins.
GNU Affero General Public License v3.0
203 stars 113 forks source link

Idle poweroff is not working on prusa MK4 with Firmware 5.1.2 (heatbreak X temp and target temp causes problems) #271

Open netinetwalker opened 9 months ago

netinetwalker commented 9 months ago

On the prusa mk4 idle poweroff is not working correct because of the temp target for cooling fan of the heatbreak is not 0 and should not changed from the target 36.00

Current g-code log of prusa mk4:

T:25.00/0.00 B:23.96/0.00 X:23.95/36.00 A:30.73/0.00 @:0 B@:0 HBR@:0
T:25.00/0.00 B:23.93/0.00 X:23.94/36.00 A:30.75/0.00 @:0 B@:0 HBR@:0
T:25.00/0.00 B:23.96/0.00 X:23.94/36.00 A:30.81/0.00 @:0 B@:0 HBR@:0

octoprint.log

2024-01-21 03:51:55,823 - octoprint.plugins.psucontrol - INFO - Idle timeout reached after 30 minute(s). Turning heaters off prior to shutting off PSU.
2024-01-21 03:51:55,823 - octoprint.plugins.psucontrol - DEBUG - Heater tool0 already off.
2024-01-21 03:51:55,824 - octoprint.plugins.psucontrol - DEBUG - Heater bed already off.
2024-01-21 03:51:55,824 - octoprint.plugins.psucontrol - INFO - Turning off heater: X
2024-01-21 03:51:59,140 - octoprint.plugins.psucontrol - DEBUG - Polling PSU state...

dirty quick fix: (I filter X in the /octoprint/util/comm.py) LINE 6414:

def parse_temperature_line(line, current):
    """
    Parses the provided temperature line.

    The result will be a dictionary mapping from the extruder or bed key to
    a tuple with current and target temperature. The result will be canonicalized
    with :func:`canonicalize_temperatures` before returning.

    Arguments:
        line (str): the temperature line to parse
        current (int): the current active extruder

    Returns:
        tuple: a 2-tuple with the maximum tool number and a dict mapping from
          key to (actual, target) tuples, with key either matching ``Tn`` for ``n >= 0`` or ``B``
    """

    result = {}
    max_tool_num = 0
    for match in re.finditer(regex_temp, line):
        values = match.groupdict()
        sensor = values["sensor"]
        if sensor == "X":
            # skip X sensor
            continue
        if sensor in result:
            # sensor already seen, let's not overwrite stuff
            continue

What were you doing?

Idle poweroff settings activated but printer remains powered.

What did you expect to happen?

Printer turns off

What happened instead?

Printer remains powered

Version of OctoPrint-PSUControl

PSU Control (1.0.6) PSU Control - Shelly (1.0.2)

Operating System running OctoPrint

OctoPrint 1.9.3 - Python 3.9.2OctoPi* 1.0.0cam (build 2023.10.09.154319) on raspbian bullseye

Printer model & used firmware incl. version

Prusa MK4
Prusa-Firmware-Buddy 5.1.2+13478 (Github)

Link to octoprint.log with octoprnt.plugins.psucontrol set to DEBUG

netinetwalker commented 9 months ago

Looks like #267 is the same Issue and the solution from the dedicated OctoPrint-TPLinkSmartplug Plugin with a heater filter list can adapted here too -> https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/issues/336

Sorry for the duplicate

netinetwalker commented 9 months ago

QUICK FIX v2 small filter plugin: filter_heatbrake_temperatures_prusa_mk4.py

# coding=utf-8

def filter_heatbrake_temperatures(comm, parsed_temps):
    parsed_temps.pop("X", None)
    return parsed_temps

__plugin_name__ = "Filter Prusa MK4 heatbrake Temperatures"
__plugin_version__ = "0.0.1"
__plugin_description__ = "A quick heatbrake temperatures filter plugin for Prusa MK4"
__plugin_pythoncompat__ = ">=2.7,<4"
__plugin_hooks__ = {
    "octoprint.comm.protocol.temperatures.received": filter_heatbrake_temperatures
}
jurassic73 commented 6 months ago

Has there been progress with this being implemented so other plugins can reference for control?

mogorman commented 5 months ago

for my prusa xl its "X5" instead of "X"

jurassic73 commented 5 months ago

Edit - found I needed to create the file here: ~/.octoprint/plugins and after an OctoPrint restart I see it in the Plugin Manager in Octoprint. Power off control works again - thanks!

QUICK FIX v2 small filter plugin: filter_heatbrake_temperatures_prusa_mk4.py

# coding=utf-8

def filter_heatbrake_temperatures(comm, parsed_temps):
    parsed_temps.pop("X", None)
    return parsed_temps

__plugin_name__ = "Filter Prusa MK4 heatbrake Temperatures"
__plugin_version__ = "0.0.1"
__plugin_description__ = "A quick heatbrake temperatures filter plugin for Prusa MK4"
__plugin_pythoncompat__ = ">=2.7,<4"
__plugin_hooks__ = {
    "octoprint.comm.protocol.temperatures.received": filter_heatbrake_temperatures
}

Do you create a file in ~/oprint/lib/python3.9/site-packages called filter_heatbrake_temperatures_prusa_mk4.py with this as contents then reload Octoprint?

wseifert commented 5 months ago

I have also this issue, but using this fix does not solve it. The only result is that on the Octodash screen the nozzle temperature stays on the last one and does not decrease. My env is MK4 & MMU3 FW 6.0, Octoprint 1.10, Octodash 2.3.1 Any other hints to solve?

DavyGD commented 3 months ago

I have the same issue, the plugin fixes it but another plugin uses the data that is being filtered so it's not very usable for me. Otherwise works perfectly. A filter for what the plugin ingests would be great.