From 9abe2daa8f07b2c0814b8e4697372bde824b9d2c Mon Sep 17 00:00:00 2001 From: fenopy Date: Wed, 3 Jun 2026 10:14:12 -0500 Subject: [PATCH 1/2] fix: in progress notifs --- kobrax_moonraker_bridge.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kobrax_moonraker_bridge.py b/kobrax_moonraker_bridge.py index 79cd195..0025d1b 100644 --- a/kobrax_moonraker_bridge.py +++ b/kobrax_moonraker_bridge.py @@ -800,6 +800,7 @@ class KobraXBridge: self._camera_autostarted: bool = False self.camera_cache: CameraCache = CameraCache() self._prev_kobra_state: str = "" + self._print_active: bool = False self._notify_every_minutes: int = 0 self._notify_every_layers: int = 0 self._last_progress_notif_time: float = 0.0 @@ -1061,14 +1062,19 @@ 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) - self._last_progress_notif_time = time.monotonic() - self._last_progress_notif_layer = self._state.get("curr_layer", 0) + if not self._print_active: + self._print_active = True + self._notify("started", _notif_filename) + self._last_progress_notif_time = time.monotonic() + self._last_progress_notif_layer = self._state.get("curr_layer", 0) elif kobra_state == "finished": + self._print_active = False self._notify("finished", _notif_filename) elif kobra_state == "failed": + self._print_active = False self._notify("failed", _notif_filename) elif kobra_state in ("stoped", "canceled"): + self._print_active = False self._notify("cancelled", _notif_filename) elif kobra_state == "paused": self._notify("paused", _notif_filename) @@ -1138,6 +1144,7 @@ class KobraXBridge: log.warning(f"Kamera-Autostart fehlgeschlagen: {e}") elif kobra_state in ("free", "finished", "stoped", "canceled"): self._camera_autostarted = False + self._print_active = False if project: if "filename" in project: self._state["filename"] = project["filename"] From 068976ebc42e7a85497507e49f23d94343b188c2 Mon Sep 17 00:00:00 2001 From: fenopy Date: Wed, 3 Jun 2026 14:48:34 -0500 Subject: [PATCH 2/2] fix: sending images in notifs --- kobrax_moonraker_bridge.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/kobrax_moonraker_bridge.py b/kobrax_moonraker_bridge.py index 0025d1b..0f9330e 100644 --- a/kobrax_moonraker_bridge.py +++ b/kobrax_moonraker_bridge.py @@ -948,7 +948,6 @@ class KobraXBridge: urls_plain = [e["url"] for e in matching if not e.get("include_image")] urls_image = [e["url"] for e in matching if e.get("include_image")] - jpeg_bytes = self.camera_cache.latest_jpeg if urls_image else b"" def _send(): import apprise, os, tempfile @@ -964,12 +963,25 @@ class KobraXBridge: ap2.add(u) attach = None tmppath = None - if jpeg_bytes: - with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as f: - f.write(jpeg_bytes) - tmppath = f.name - attach = apprise.AppriseAttachment() - attach.add(tmppath) + jpeg = self.camera_cache.latest_jpeg + if not jpeg and self.camera_cache._url: + # Camera URL is set but no frame yet — wait briefly (camera may be starting) + deadline = time.monotonic() + 5.0 + while not jpeg and time.monotonic() < deadline: + time.sleep(0.3) + jpeg = self.camera_cache.latest_jpeg + if jpeg: + try: + with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as f: + f.write(jpeg) + tmppath = f.name + attach = apprise.AppriseAttachment() + attach.add(tmppath) + except Exception as e: + log.warning(f"Kamera-Anhang fehlgeschlagen: {e}") + attach = None + else: + log.debug("Bild-Benachrichtigung ohne Anhang (kein Kamera-Frame verfügbar)") ap2.notify(title=title, body=body, attach=attach) if tmppath: try: