power: fix scheduled firmware restarts
Determine if a firmware restart should be postponed by checking Klippy's state. This should correctly schedule the restart regardless of whether or not the device is bound to Klipper. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
7f11214609
commit
6d458125a1
|
@ -316,7 +316,7 @@ class PowerDevice:
|
||||||
return
|
return
|
||||||
self.need_scheduled_restart = False
|
self.need_scheduled_restart = False
|
||||||
if state == "ready":
|
if state == "ready":
|
||||||
logging.info("Klipper reports 'ready', aborting firmware restart")
|
logging.info("Klipper reports 'ready', aborting FIRMWARE_RESTART")
|
||||||
return
|
return
|
||||||
event_loop = self.server.get_event_loop()
|
event_loop = self.server.get_event_loop()
|
||||||
kapis: APIComp = self.server.lookup_component("klippy_apis")
|
kapis: APIComp = self.server.lookup_component("klippy_apis")
|
||||||
|
@ -348,7 +348,11 @@ class PowerDevice:
|
||||||
await machine_cmp.do_service_action(action, self.bound_service)
|
await machine_cmp.do_service_action(action, self.bound_service)
|
||||||
if self.state == "on" and self.klipper_restart:
|
if self.state == "on" and self.klipper_restart:
|
||||||
self.need_scheduled_restart = True
|
self.need_scheduled_restart = True
|
||||||
if self._is_bound_to_klipper():
|
klippy_state = self.server.get_klippy_state()
|
||||||
|
if klippy_state in ["disconnected", "startup"]:
|
||||||
|
# If klippy is currently disconnected or hasn't proceeded past
|
||||||
|
# the startup state, schedule the restart in the
|
||||||
|
# "klippy_started" event callback.
|
||||||
return
|
return
|
||||||
self._schedule_firmware_restart()
|
self._schedule_firmware_restart()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue