diff --git a/CHANGELOG.de.md b/CHANGELOG.de.md index 5c82780..cb5a952 100644 --- a/CHANGELOG.de.md +++ b/CHANGELOG.de.md @@ -1,5 +1,20 @@ # Changelog +## [0.9.12] – 2026-05-20 + +### Fixes +- **Pause-Status** wird jetzt korrekt erkannt: Die Bridge las den Geräte-State + statt des verschachtelten Druckauftrags-States, dadurch wurde ein pausierter + Druck teils noch als „druckend" angezeigt. Layer/Fortschritt/Restzeit kommen + jetzt ebenfalls aus dem Auftrags-Report. + +### Intern +- Frontend (HTML/CSS/JS) aus der Python-Datei nach `web/index.html` ausgelagert, + zur Build-Zeit wieder eingebettet — besser wartbar, für Nutzer keine Änderung. + +### Doku +- Community-**Home-Assistant-Integration** von @gangoke verlinkt. + ## [0.9.11] – 2026-05-20 ### Neu diff --git a/CHANGELOG.md b/CHANGELOG.md index 03f00bc..bcd7d82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [0.9.12] – 2026-05-20 + +### Fixes +- **Pause state** is now read correctly: the bridge was looking at the device-level + state instead of the nested print-job state, so a paused print sometimes still + showed as printing. Layer/progress/remaining-time are now also taken from the + job report. + +### Internal +- Frontend (HTML/CSS/JS) extracted from the Python file into `web/index.html`, + bundled back in at build time — easier to maintain, no change for users. + +### Docs +- Linked the community **Home Assistant integration** by @gangoke. + ## [0.9.11] – 2026-05-20 ### New diff --git a/Dockerfile b/Dockerfile index d1682c3..c474419 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY kobrax_moonraker_bridge.py . +COPY _web_assets.py . COPY config_loader.py . COPY env_loader.py . COPY kobrax_client.py . diff --git a/README.de.md b/README.de.md index b5d15e5..9836123 100644 --- a/README.de.md +++ b/README.de.md @@ -16,6 +16,8 @@ Eine Moonraker-kompatible Bridge, die direkt mit dem Drucker spricht.   [![Releases](https://img.shields.io/badge/Download-Releases-2EA043?style=for-the-badge&logo=gitea&logoColor=white)](https://gitea.it-drui.de/viewit/KX-Bridge-Release/releases)   +[![Downloads](https://img.shields.io/badge/Downloads-800%2B-8957E5?style=for-the-badge&logo=gitea&logoColor=white)](https://gitea.it-drui.de/viewit/KX-Bridge-Release/releases) +  [![Video](https://img.shields.io/badge/YouTube-Tutorial-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/watch?v=1Ql4wfH27fM) Gefällt dir KX-Bridge? Ein Kaffee auf Ko-fi hält das Projekt am Leben. ☕ @@ -99,6 +101,17 @@ Drucker → Verbindungstyp **Moonraker** → Host: `http://BRIDGE-IP:7125` --- +## 🏠 Community & Integrationen + +- **[Home-Assistant-Integration](https://github.com/gangoke/kobrax-lan-hass-component)** + von [@gangoke](https://github.com/gangoke) — bindet Sensoren, Drucksteuerung, + Licht, Kamera und das GCode-Vorschaubild als native Home-Assistant-Entitäten ein. + +> Dies sind **Community-Projekte**, die nicht von KX-Bridge betreut oder +> supportet werden. Bei Fragen oder Problemen bitte das verlinkte Repository nutzen. + +--- + ## 🔧 Zugangsdaten manuell ermitteln Normalerweise nicht nötig — *„+ Drucker hinzufügen"* macht das automatisch. Falls doch: diff --git a/README.md b/README.md index 9b84096..4fefd18 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ A Moonraker-compatible bridge that talks directly to the printer.   [![Releases](https://img.shields.io/badge/Download-Releases-2EA043?style=for-the-badge&logo=gitea&logoColor=white)](https://gitea.it-drui.de/viewit/KX-Bridge-Release/releases)   +[![Downloads](https://img.shields.io/badge/Downloads-800%2B-8957E5?style=for-the-badge&logo=gitea&logoColor=white)](https://gitea.it-drui.de/viewit/KX-Bridge-Release/releases) +  [![Video](https://img.shields.io/badge/YouTube-Tutorial-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/watch?v=1Ql4wfH27fM) Like KX-Bridge? A coffee on Ko-fi keeps the project alive. ☕ @@ -99,6 +101,17 @@ Printer → Connection type **Moonraker** → Host: `http://BRIDGE-IP:7125` --- +## 🏠 Community & Integrations + +- **[Home Assistant integration](https://github.com/gangoke/kobrax-lan-hass-component)** + by [@gangoke](https://github.com/gangoke) — exposes sensors, print controls, + light, camera and the GCode thumbnail as native Home Assistant entities. + +> These are **community projects**, not maintained or supported by KX-Bridge. +> For questions or issues, please use the linked repository. + +--- + ## 🔧 Getting credentials manually Normally not needed — *"+ Add printer"* does this automatically. If you do need it: diff --git a/VERSION b/VERSION index 8225a4b..583b27a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.11 +0.9.12 diff --git a/_web_assets.py b/_web_assets.py new file mode 100644 index 0000000..19b3245 --- /dev/null +++ b/_web_assets.py @@ -0,0 +1,2991 @@ +# AUTOGENERIERT von tools/bundle_web_assets.py – NICHT von Hand editieren. +# Quelle: bridge/web/index.html +INDEX_HTML = r""" + + + + +KX-Bridge + + + + + + + +
+ +
+ +
Anycubic Kobra X
+ +
Standby
+ + + + +
+ + + + + + + +
+ + +
+ +
+
+ +
+
+
📷 Kamera
+
+ 💡 Licht + +
+
+
+
📷 Kamera nicht gestartet
+
+ + + +
+
+ + +
+
Fortschritt
+ +
0%
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ + + + +
+
+ + +
+
Temperaturen
+
+
+
Nozzle
+
+
+
°C
+
+
0°C
+
+
+
+
+ + + +
+
+
+
Bett
+
+
+
°C
+
+
0°C
+
+
+
+
+ + + +
+
+
+
+
Verlauf (letzte 60 Messungen)
+ +
+
+ + +
+
XY-Achsen
+
+
+ +
+ + + +
+ +
+
+
+ + + + +
+
+ + + + +
+
+
+
Z-Achse
+
+ + +
+
Schrittweite: 1 mm
+
+ + +
+
🏎 Druckgeschwindigkeit
+
+ + + +
+
+
+
+
+ + +
+
🌀 Lüfter
+
+ + 0 +
+
+ + + + + +
+
+ + + + +
+
Filament
+
+
Keine AMS-Daten empfangen
+
+
+
+
+ + + +
+
+
+ 🖨 Drucker +
+ + +
+
+
+
+
+ + +
+
+
+ 🗂 Datei-Browser + +
+
+ + + +
+ +
+
+
+ +
+
+
+ Ereignis-Log + ⬇ Download +
+
+ + + +
+
+ Dir: + + + + Topic: + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + +""" diff --git a/kobrax_moonraker_bridge.py b/kobrax_moonraker_bridge.py index 895eb36..1135b6c 100644 --- a/kobrax_moonraker_bridge.py +++ b/kobrax_moonraker_bridge.py @@ -49,6 +49,7 @@ import threading _BASE = os.path.dirname(sys.executable) if getattr(sys, "frozen", False) else os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, _BASE) from kobrax_client import KobraXClient +from _web_assets import INDEX_HTML try: @@ -698,10 +699,28 @@ class KobraXBridge: if not env_loader.get("BRIDGE_PRINTER_NAME") and not getattr(self, "_name_locked", False): self._state["printer_name"] = d.get("printerName", self._state["printer_name"]) self._state["firmware_version"] = d.get("version", self._state["firmware_version"]) - kobra_state = d.get("state", "") + # Der echte Druck-State steckt bei info/report im verschachtelten + # project.state ("printing"/"paused"/…). Das oberste data.state ist nur + # der Geräte-State ("busy"/"free") und würde "paused" verschlucken. + project = d.get("project") or {} + proj_state = project.get("state", "") + kobra_state = proj_state or d.get("state", "") if kobra_state: self._state["print_state"] = KOBRA_TO_KLIPPER_STATE.get(kobra_state, "standby") self._state["kobra_state"] = kobra_state + if project: + if "filename" in project: + self._state["filename"] = project["filename"] + if "progress" in project: + self._state["progress"] = float(project["progress"]) / 100.0 + if "print_time" in project: + self._state["print_duration"] = int(project["print_time"]) * 60 + if "remain_time" in project: + self._state["remain_time"] = int(project["remain_time"]) * 60 + if "curr_layer" in project: + self._state["curr_layer"] = project["curr_layer"] + if "total_layers" in project: + self._state["total_layers"] = project["total_layers"] t = d.get("temp") or {} if t: self._state["nozzle_temp"] = float(t.get("curr_nozzle_temp", 0)) @@ -1956,2994 +1975,7 @@ class KobraXBridge: }) async def handle_index(self, request): - html = r""" - - - - -KX-Bridge - - - - - - - -
- -
- -
Anycubic Kobra X
- -
Standby
- - - - -
- - - - - - - -
- - -
- -
-
- -
-
-
📷 Kamera
-
- 💡 Licht - -
-
-
-
📷 Kamera nicht gestartet
-
- - - -
-
- - -
-
Fortschritt
- -
0%
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
- - - - -
-
- - -
-
Temperaturen
-
-
-
Nozzle
-
-
-
°C
-
-
0°C
-
-
-
-
- - - -
-
-
-
Bett
-
-
-
°C
-
-
0°C
-
-
-
-
- - - -
-
-
-
-
Verlauf (letzte 60 Messungen)
- -
-
- - -
-
XY-Achsen
-
-
- -
- - - -
- -
-
-
- - - - -
-
- - - - -
-
-
-
Z-Achse
-
- - -
-
Schrittweite: 1 mm
-
- - -
-
🏎 Druckgeschwindigkeit
-
- - - -
-
-
-
-
- - -
-
🌀 Lüfter
-
- - 0 -
-
- - - - - -
-
- - - - -
-
Filament
-
-
Keine AMS-Daten empfangen
-
-
-
-
- - - -
-
-
- 🖨 Drucker -
- - -
-
-
-
-
- - -
-
-
- 🗂 Datei-Browser - -
-
- - - -
- -
-
-
- -
-
-
- Ereignis-Log - ⬇ Download -
-
- - - -
-
- Dir: - - - - Topic: - - - - -
-
-
-
-
-
- - - - - - - - - - - - - - - - -""" + html = INDEX_HTML version = self._read_version() html = html.replace("'__VERSION__'", f"'{version}'") return web.Response(text=html, content_type="text/html",