|
@@ -20,6 +20,7 @@ from backend.app.schemas.smart_plug import (
|
|
|
SmartPlugEnergy,
|
|
SmartPlugEnergy,
|
|
|
)
|
|
)
|
|
|
from backend.app.services.tasmota import tasmota_service
|
|
from backend.app.services.tasmota import tasmota_service
|
|
|
|
|
+from backend.app.services.printer_manager import printer_manager
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
@@ -178,6 +179,9 @@ async def control_smart_plug(
|
|
|
plug.last_state = expected_state
|
|
plug.last_state = expected_state
|
|
|
if expected_state == "ON":
|
|
if expected_state == "ON":
|
|
|
plug.auto_off_executed = False # Reset flag when manually turning 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()
|
|
plug.last_checked = datetime.utcnow()
|
|
|
await db.commit()
|
|
await db.commit()
|
|
|
|
|
|