feat: add cash_level to availability broadcast

Publish cash level (none/low/good/full) in the Kind 30078 event
based on total bill count across all cassettes. Enables monitoring
dashboards to show cash availability without revealing exact amounts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-03-30 16:22:28 -04:00
commit b0ec3ab7b3

View file

@ -48,10 +48,20 @@ export function useAvailabilityBroadcast(options: UseAvailabilityBroadcastOption
return { cashIn, cashOut }
}
/** Cash level: none / low / good / full based on total bills */
function cashLevel(): string {
const totalBills = Object.values(inventory.value).reduce((s, c) => s + c, 0)
if (totalBills === 0) return 'none'
if (totalBills < 20) return 'low'
if (totalBills < 80) return 'good'
return 'full'
}
async function publish(avail: ATMAvailability) {
const content = JSON.stringify({
cash_in: avail.cashIn,
cash_out: avail.cashOut,
cash_level: cashLevel(),
fiat: fiatCode,
model,
})