forked from viewit/KX-Bridge-Release
fix: avoid multiple print-started notifs
This commit is contained in:
@ -1070,6 +1070,7 @@ class KobraXBridge:
|
||||
self.camera_cache: CameraCache = CameraCache()
|
||||
self._loop: "asyncio.AbstractEventLoop | None" = None
|
||||
self._prev_kobra_state: str = ""
|
||||
self._notified_print_started: bool = False # verhindert Mehrfach-Trigger pro Druck (analog _camera_autostarted)
|
||||
self._print_active: bool = False
|
||||
self._notify_every_minutes: int = 0
|
||||
self._notify_every_layers: int = 0
|
||||
@ -1555,6 +1556,7 @@ class KobraXBridge:
|
||||
elif kobra_state in ("free", "finished", "stoped", "canceled"):
|
||||
self._camera_autostarted = False
|
||||
self._camera_user_stopped = False # release for the next print
|
||||
self._notified_print_started = False
|
||||
|
||||
if kobra_state in ("pause", "paused"):
|
||||
pause_msg = payload.get("msg", "")
|
||||
@ -1599,13 +1601,21 @@ class KobraXBridge:
|
||||
if kobra_state and kobra_state != self._prev_kobra_state:
|
||||
_notif_filename = d.get("filename", self._state.get("filename", ""))
|
||||
if kobra_state == "printing":
|
||||
self._notify("started", _notif_filename)
|
||||
# "printing" is re-entered many times within the same job (after
|
||||
# pause/resume, auto-leveling, filament checks, ...), each of which
|
||||
# would otherwise re-trigger a "started" notification mid-print.
|
||||
if not self._notified_print_started:
|
||||
self._notified_print_started = True
|
||||
self._notify("started", _notif_filename)
|
||||
elif kobra_state == "finished":
|
||||
self._notify("finished", _notif_filename)
|
||||
self._notified_print_started = False
|
||||
elif kobra_state == "failed":
|
||||
self._notify("failed", _notif_filename)
|
||||
self._notified_print_started = False
|
||||
elif kobra_state in ("stoped", "canceled"):
|
||||
self._notify("cancelled", _notif_filename)
|
||||
self._notified_print_started = False
|
||||
elif kobra_state in ("pause", "paused"):
|
||||
self._notify("paused", _notif_filename)
|
||||
self._prev_kobra_state = kobra_state
|
||||
|
||||
Reference in New Issue
Block a user