Adding loads on gpios to switch

This commit is contained in:
ben 2022-10-21 20:06:50 +01:00
parent d1302e4868
commit c8a33b0b93
3 changed files with 6 additions and 5 deletions

View File

@ -91,6 +91,7 @@ async def lnurl_v1_params(
device_id: str = Query(None),
p: str = Query(None),
atm: str = Query(None),
gpio: str = Query(None),
):
device = await get_lnurldevice(device_id)
if not device:
@ -114,7 +115,7 @@ async def lnurl_v1_params(
deviceid=device.id,
payload="bla",
sats=price_msat,
pin=1,
pin=gpio,
payhash="bla",
)
if not lnurldevicepayment:
@ -236,7 +237,7 @@ async def lnurl_callback(
amount=lnurldevicepayment.sats / 1000,
memo=device.title + "-" + lnurldevicepayment.id,
unhashed_description=(await device.lnurlpay_metadata()).encode("utf-8"),
extra={"tag": "Switch", "id": paymentid, "time": device.amount},
extra={"tag": "Switch", "pin": ,"id": paymentid, "time": device.amount},
)
lnurldevicepayment = await update_lnurldevicepayment(
lnurldevicepayment_id=paymentid, payhash=payment_hash

View File

@ -36,5 +36,5 @@ async def on_invoice_paid(payment: Payment) -> None:
lnurldevicepayment = await update_lnurldevicepayment(
lnurldevicepayment_id=payment.extra.get("id"), payhash="used"
)
return await updater(lnurldevicepayment.deviceid)
return await updater(lnurldevicepayment.deviceid, lnurldevicepayment.pin)
return

View File

@ -103,8 +103,8 @@ async def websocket_endpoint(websocket: WebSocket, lnurldevice_id: str):
manager.disconnect(websocket)
async def updater(lnurldevice_id):
async def updater(lnurldevice_id, lnurldevice_pin):
lnurldevice = await get_lnurldevice(lnurldevice_id)
if not lnurldevice:
return
await manager.send_personal_message(f"{lnurldevice.amount}", lnurldevice_id)
return await manager.send_personal_message(f"pin:{lnurldevice.pin},amount:{lnurldevice.amount}", lnurldevice_id)