Added power switch and automation controls to printer card

This commit is contained in:
Martin Ziegler
2025-11-29 11:01:29 +01:00
parent 526de63acd
commit a2b889485d
8 changed files with 657 additions and 447 deletions
+12
View File
@@ -62,6 +62,18 @@ async def create_smart_plug(
return plug
@router.get("/by-printer/{printer_id}", response_model=SmartPlugResponse | None)
async def get_smart_plug_by_printer(printer_id: int, db: AsyncSession = Depends(get_db)):
"""Get the smart plug assigned to a printer."""
result = await db.execute(
select(SmartPlug).where(SmartPlug.printer_id == printer_id)
)
plug = result.scalar_one_or_none()
if not plug:
return None
return plug
@router.get("/{plug_id}", response_model=SmartPlugResponse)
async def get_smart_plug(plug_id: int, db: AsyncSession = Depends(get_db)):
"""Get a specific smart plug."""