Talker MQTT payloads now carry a Unix-epoch-ms `ts` field on both start
and stop. Stop additionally carries `duration_ms` whenever a matching
start was observed by the same MqttPublisher instance and the resulting
duration is non-negative. Both fields are additive — older consumers
that only read `callsign` continue to work unchanged.
Implementation
- MqttPublisher tracks per-(peer_id, tg) start_ms in a small std::map.
Local talkers use peer_id="" as the map key. The entry is consumed on
the matching stop.
- On stop, duration_ms is computed as `now - start_ms`. The field is
omitted when:
* no matching start was recorded (e.g. reflector restarted mid-talker)
* the resulting duration is negative (backwards NTP correction during
the transmission)
Both edge cases are documented in docs/MQTT.md.
- Applies symmetrically across the four publish paths:
onTalkerStart / onTalkerStop / onPeerTalkerStart / onPeerTalkerStop.
Tests
- test_trunk.py::test_18_mqtt_talker_event extended:
* asserts `ts` is present on start, parses as int, lies within a
+/- 60s window of the test's local clock.
* asserts `ts` on stop is >= start ts.
* asserts `duration_ms` on stop is present, >= the held-talker time
(~500 ms), and equals stop_ts - start_ts.
- Edge-case behaviour (no-start, backwards clock jump) is guarded in
code and documented; reaching it from the integration suite would
require restarting the reflector mid-talker or injecting a clock
step, so it is not asserted from outside.
Docs
- docs/MQTT.md: payload examples updated for both flat and
peer-namespaced talker topics; new paragraph spelling out the two
conditions under which duration_ms is omitted.
- docs/MESSAGING_IDEAS.md: Telegram-bot example extended to also
handle /stop with a `duration_ms >= 1000` filter (kerchunk
suppression) and a short note on how `ts`/`duration_ms` map to
end-to-end pipeline latency and session length.
7.5 KiB
Messaging & Notification Ideas
This document collects ideas for consuming GeuReflector MQTT events and delivering them to operators, sysadmins, and radio communities through external messaging channels.
The common pattern: a lightweight bridge subscribes to MQTT topics and forwards filtered events to one or more destinations.
1. Telegram Bot
What: A bot in a Telegram group or channel posts activity updates.
Useful events:
- Talker start/stop — "IW1GEU is talking on TG 22250"
- Client connect/disconnect — "Node ON4ABC joined the reflector"
- Trunk link up/down — alerts when a peer reflector goes offline
- Periodic activity summary — daily digest of unique callsigns and TG usage
Implementation: A Python script using paho-mqtt + python-telegram-bot.
Subscribe to svxreflector/+/talker/# and svxreflector/+/trunk/#, format
messages, and post to a chat ID. Use Telegram's silent messages for
high-frequency events (talker) and normal notifications for alerts (trunk down).
Filtering ideas:
- Only notify for specific TGs (e.g. your local repeater's TG)
- Suppress repeated talker events within N seconds (debounce)
- Only notify trunk down events that persist beyond a grace period
- Mute overnight (configurable quiet hours)
2. SMS / Signal / WhatsApp Alerts
What: Critical alerts sent via SMS or secure messaging for on-call sysadmins.
Useful events:
- Trunk link down (all directions) — the mesh is degraded
- All clients disconnected — possible reflector issue
- No heartbeat / status missing for extended period
Implementation:
- SMS via Twilio, Vonage, or a local GSM modem (e.g. Gammu)
- Signal via
signal-cli - WhatsApp via WhatsApp Business API
Keep these strictly low-volume — only actionable alerts that need immediate attention. Apply a cooldown (e.g. max 1 SMS per trunk link per 30 minutes).
3. Discord Integration
What: A Discord bot or webhook posts to a channel in your radio club's Discord server.
Useful events:
- Talker activity with TG name mapping — "IW1GEU talking on Liguria (22250)"
- Node online/offline with QTH info — "ON4ABC online from Genova [44.41, 8.93]"
- RX signal levels — embed with colored indicators (green/yellow/red)
Implementation: Discord webhooks are the simplest — just POST a JSON
payload. For richer interaction (slash commands to query status), use a bot
with discord.py. Embed formatting works well for structured radio data.
4. Email Digests
What: Periodic email summaries rather than real-time notifications.
Content ideas:
- Daily activity report: unique callsigns, total TX time per TG, peak hours
- Weekly trunk health: uptime percentages, reconnection counts
- Monthly statistics: most active nodes, TG usage trends
Implementation: A cron job or MQTT consumer that accumulates events in a local database (SQLite), then formats and sends an HTML email via SMTP. Useful for club newsletters or repeater coordinator reports.
5. Web Dashboard via WebSocket Bridge
What: An MQTT-to-WebSocket bridge so browser-based dashboards get
real-time push updates without polling the HTTP /status endpoint.
Implementation options:
- Mosquitto WebSocket listener — Mosquitto natively supports WebSocket on a separate port. Browsers connect directly with an MQTT.js client.
- Dedicated bridge — a small Node.js or Python service subscribes to MQTT and relays to WebSocket clients, adding filtering/auth.
This is the natural backend for SvxReflectorDashboard or any custom
dashboard — subscribe to client/+/rx for live signal meters, talker/#
for activity indicators, and status for the full state on connect.
6. Webhook Relay (Generic)
What: Forward MQTT events as HTTP POST webhooks to any service.
Targets:
- Home Assistant — automate a "repeater active" indicator light
- Node-RED — visual flow-based processing and routing
- IFTTT / Zapier — connect to hundreds of services without code
- Custom REST APIs — feed events into your own logging or monitoring stack
Implementation: A generic MQTT-to-webhook bridge with a config file
mapping topic patterns to URLs and optional payload transforms. Several
open-source projects already do this (e.g. mqttwarn).
7. Push Notifications (Mobile)
What: Native push notifications on Android/iOS.
Options:
- Pushover — simple API, supports priority levels and quiet hours, per-device/group targeting. Ideal for ham radio use.
- ntfy.sh — self-hostable, no account needed, supports topic-based subscriptions
- Firebase Cloud Messaging — if building a dedicated mobile app
Filtering: Essential for mobile — only push trunk alerts and talker events on subscribed TGs. Let users configure which TGs they care about.
8. Logging & Monitoring
What: Feed events into observability infrastructure.
Targets:
- InfluxDB + Grafana — time-series dashboards for signal levels, TX duration, trunk latency, node uptime
- Elasticsearch + Kibana — searchable event log, useful for debugging intermittent issues
- Prometheus — expose MQTT-derived metrics via an exporter; alert on trunk down, node count drop, etc.
Value: Historical data enables trend analysis — which TGs are growing, which nodes have flaky connections, what time of day is busiest.
Architecture Pattern
All of these follow the same decoupled pattern:
GeuReflector
|
| MQTT publish
v
MQTT Broker (Mosquitto)
|
|--- Telegram bridge
|--- SMS alerter
|--- Discord webhook
|--- WebSocket bridge --> Browser dashboard
|--- mqttwarn --> Webhooks, email, push
|--- InfluxDB writer --> Grafana
The reflector only speaks MQTT. Each consumer is independent, can be added or removed without touching the reflector, and can run anywhere with network access to the broker. Multiple consumers can subscribe to the same topics simultaneously.
Getting Started
The simplest starting point is a Telegram bot with mqttwarn or a short
Python script:
pip install paho-mqtt python-telegram-bot
import paho.mqtt.client as mqtt
import telegram
import json
bot = telegram.Bot(token="YOUR_BOT_TOKEN")
CHAT_ID = "YOUR_CHAT_ID"
def on_message(client, userdata, msg):
data = json.loads(msg.payload)
tg = msg.topic.split("/")[-2]
if msg.topic.endswith("/start"):
bot.send_message(CHAT_ID,
f"📡 {data['callsign']} talking on TG {tg}")
elif msg.topic.endswith("/stop") and "duration_ms" in data:
# Skip kerchunks under 1 s; pretty-print the rest.
if data["duration_ms"] >= 1000:
secs = data["duration_ms"] / 1000
bot.send_message(CHAT_ID,
f"🔇 {data['callsign']} stopped on TG {tg} "
f"({secs:.1f} s)")
client = mqtt.Client()
client.username_pw_set("user", "pass")
client.on_message = on_message
client.connect("mqtt.example.com", 1883)
client.subscribe("svxreflector/+/talker/#")
client.loop_forever()
The start and stop payloads carry ts (Unix epoch ms) and stop
additionally carries duration_ms when a matching start was observed —
see docs/MQTT.md for the schema and edge cases. Filtering
on duration_ms < 1000 is a cheap way to suppress kerchunks; using
ts lets you compute end-to-end latency between the reflector and
your bot pipeline.
Contributing Ideas
This is a living document. If you build an integration or have ideas for new ones, open an issue or PR.