From c4cceced61dda4d656762c9c1d8ce55d3d7cd9c3 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Sun, 29 Dec 2024 22:25:30 +0100 Subject: [PATCH] whyticketcounter --- ledder/animations/TicketCounter.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ledder/animations/TicketCounter.ts b/ledder/animations/TicketCounter.ts index 75c4478..32ff8e9 100644 --- a/ledder/animations/TicketCounter.ts +++ b/ledder/animations/TicketCounter.ts @@ -42,12 +42,24 @@ export default class Template extends Animator { console.log(`MQTT: ${mqttHost.text} connected`) mqttClient.subscribe(mqttTopic.text) + mqttClient.subscribe('why2025/ticketshop/quotas/Event Visitors/pending_orders') }) + let paidCount=undefined + let pendingCount=undefined mqttClient.on('message', async (topic, messageBuf) => { + + let message = messageBuf.toString() - console.log("MQTT:", message) - counter.update(message) + + if (topic==='why2025/ticketshop/quotas/Event Visitors/paid_orders') + paidCount=Number(message) + + if (topic==='why2025/ticketshop/quotas/Event Visitors/pending_orders') + pendingCount=Number(message) + + if (paidCount !==undefined && pendingCount!==undefined) + counter.update(paidCount+pendingCount) }) } }