mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
Fixed bug where current printers power stage was not updated in frontend
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user