New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TPLink power off delay doesn't work correct #366
Comments
This is expected behavior. The delay is generic, it applies to all devices and cannot execute if Moonraker is not running. Moonraker isn't a good candidate for controlling a switch that toggles its host's power, simply because even if you can cut it off you can't cut it back on. FWIW, the "off_when_shutdown" option refers to Klipper's shutdown state, not the host machine. See the configuration documentation for details. |
OK, thanks for the fast feedback. |
I would have to think about it. The issue is that the [power] module is intended to provide a generic interface that toggles any number of underlying devices. From an API perspective I'm not sure about the best way to expose functionality particular to a specific device. I'm not opposed to it, but it needs careful consideration. I think we can keep this open and label it as a feature request. |
I probably found a fix.
If you add the variable "timer" with a reasonable value in the moonraker.conf in the section [power], it works fine. Since TPLink's own count_down routine, which will send the value of timer to the device. This gcode will also perfectly work and first send the timer value to tplink's count_down routine and while
Here is my [power} section:
The "off_when_shutdown_delay" is not needed for TPLinkSmartPlug in this case. My suggestion is either change the documentation for the TPLink Smartplug Configuration in the moonraker docs, or also use "off_when_shutdown_delay" in power.py in the TPLinkSmartPlug class. |
I would like to add the latest information on this topic. The only feasible solution might be to use the idle_timeout to shutdown the printer. PRINT_END macro, performed at the end of the print checking, if the variable "turnoff" is set so that we shutdown the printer:
TURNOFF_CHANGE macro to set the variable turnoff to "0" or "1". Can be set by the printing gcode from the slicer, terminal command or per buttons:
This POWER_OFF_PRINTER macro might haven been called by the "PRINT_END" macro or manually, so we set the turnoff to "1" just in case:
Called when idle_timeout time reached:
|
After testing this recently, found out that this is not working as hoped. Since the TPLink wifi_switch shutdown method is not working as expected, no matter what tricks I tried, I will have to go back to Octopi/Octodash. |
It isn't waiting due to macro expansion. In other words, when the The solution is to wrap the two remote calls in their own respective macros. For example:
By placing the commands in their own macros, expansion is delayed until the previous gcode has been executed. That said, there are likely alternatives to using |
Thanks for the solution |
There is some news to add support to set the delay timer to turn off smartplug? |
What happened
I have a TPLink Smartplug HS110 that powers the printers as well as the Raspberry which runs Mainsail/moonraker/Klipper.
Mainsail is v2.1.1
moonraker (v0.7.1-365-g9be93ff)
Klipper is v0.10.0-263-ge3cbe7ea.
I set up a power section for my HS110 TPLink Smartplug in moonraker:
[power wifi_switch]
type: tplink_smartplug
address: 192.168.178.111
off_when_shutdown: True
off_when_shutdown_delay: 20
locked_while_printing: True
I have the following behaviour:
but no power off after the set 20 seconds.
When I shutdown with this gcode the TPLink will power off immediately and doesn't wait for the system to shutdown:
[gcode_macro POWER_OFF_PRINTER]
gcode:
{% if printer.idle_timeout.state != "Printing" %}
{action_call_remote_method("set_device_power", device="wifi_switch", state="off")}
{action_call_remote_method("shutdown_machine")}
{% endif %}
It seems that the delay procedure doesn't use TPLink_Smartplug's capabilities of a native delay but uses its own delay which doesn't work when the system has already shut down.
The TPLink Plugin in Octoprint however works fine with the delay.
Client
Mainsail
Browser
Firefox
How to reproduce
Additional information
No response
The text was updated successfully, but these errors were encountered: