Fixed bug where current printers power stage was not updated in frontend

This commit is contained in:
Martin Ziegler
2025-11-30 15:38:00 +01:00
parent 5548b05f27
commit 46b312704c
2 changed files with 7 additions and 0 deletions
+4
View File
@@ -20,6 +20,7 @@ from backend.app.schemas.smart_plug import (
SmartPlugEnergy,
)
from backend.app.services.tasmota import tasmota_service
from backend.app.services.printer_manager import printer_manager
logger = logging.getLogger(__name__)
@@ -178,6 +179,9 @@ async def control_smart_plug(
plug.last_state = expected_state
if expected_state == "ON":
plug.auto_off_executed = False # Reset flag when manually turning on
elif expected_state == "OFF" and plug.printer_id:
# Mark printer offline immediately for faster UI update
printer_manager.mark_printer_offline(plug.printer_id)
plug.last_checked = datetime.utcnow()
await db.commit()
+3
View File
@@ -116,6 +116,9 @@ class BambuMQTTClient:
client.subscribe(self.topic_subscribe)
# Request full status update
self._request_push_all()
# Immediately broadcast connection state change
if self.on_state_change:
self.on_state_change(self.state)
else:
self.state.connected = False