feat: turn off power devices that are associated to the turn on button when shutting down printer

This commit is contained in:
Alfredo Monclus
2024-11-15 19:11:14 -03:00
parent 301514f436
commit 8e4f859b09

View File

@@ -79,4 +79,12 @@ class Panel(ScreenPanel):
if method == "reboot":
self._screen._ws.send_method("machine.reboot")
else:
self.turn_off_power_devices()
self._screen._ws.send_method("machine.shutdown")
def turn_off_power_devices(self):
if self.ks_printer_cfg is not None and self._screen._ws.connected:
power_devices = self.ks_printer_cfg.get("power_devices", "")
if power_devices and self._printer.get_power_devices():
logging.info(f"Turning off associated power devices: {power_devices}")
self._screen.power_devices(widget=None, devices=power_devices, on=False)