IoT & Sensor Alerts
Route alerts from sensors, devices, and physical infrastructure.
IoT devices and sensors generate events that need different response times — a temperature spike in a server room is urgent, a humidity reading is informational. Alphorn routes each alert to the right channel based on severity.
Temperature monitoring
import requests
WEBHOOK = "https://app.alphorn.dev/api/webhooks/wh_abc123"
def check_temperature(sensor_id, temp_celsius, location):
if temp_celsius > 40:
priority, status = 5, "CRITICAL"
elif temp_celsius > 35:
priority, status = 4, "WARNING"
else:
return # Normal range, no notification
requests.post(WEBHOOK, json={
"title": f"Temperature {status}: {location}",
"message": f"Sensor {sensor_id} reading: {temp_celsius}°C",
"priority": priority,
"tags": ["iot", "temperature", status.lower(), location],
})Device offline detection
def check_device_heartbeat(device_id, last_seen, threshold_minutes=10):
from datetime import datetime, timedelta
if datetime.utcnow() - last_seen > timedelta(minutes=threshold_minutes):
requests.post(WEBHOOK, json={
"title": f"Device offline: {device_id}",
"message": f"Last seen: {last_seen.isoformat()}Z ({threshold_minutes}+ minutes ago)",
"priority": 4,
"tags": ["iot", "offline", device_id],
})ESP32 / Arduino (HTTP)
Lightweight devices can POST directly to Alphorn:
#include <WiFi.h>
#include <HTTPClient.h>
void sendAlert(float temperature) {
HTTPClient http;
http.begin("https://app.alphorn.dev/api/webhooks/wh_abc123");
http.addHeader("Content-Type", "application/json");
String body = "{\"title\":\"Sensor alert\",\"message\":\"Temperature: "
+ String(temperature, 1) + "°C\",\"priority\":4,\"tags\":[\"iot\",\"sensor\"]}";
http.POST(body);
http.end();
}MQTT to Alphorn bridge
If your devices use MQTT, write a small bridge that subscribes to topics and forwards to Alphorn:
import paho.mqtt.client as mqtt
import requests
import json
WEBHOOK = "https://app.alphorn.dev/api/webhooks/wh_abc123"
def on_message(client, userdata, msg):
data = json.loads(msg.payload)
requests.post(WEBHOOK, json={
"title": f"Sensor: {msg.topic}",
"message": json.dumps(data, indent=2),
"priority": data.get("priority", 3),
"tags": ["iot", "mqtt", msg.topic.replace("/", "-")],
})
client = mqtt.Client()
client.on_message = on_message
client.connect("mqtt-broker.local")
client.subscribe("sensors/#")
client.loop_forever()Routing examples
| Channel | Filter | Purpose |
|---|---|---|
| PagerDuty | tags CONTAINS "critical" | Immediate response for critical thresholds |
| Slack (#facilities) | tags CONTAINS "temperature" | Temperature events for facilities team |
| Slack (#devices) | tags CONTAINS "offline" | Device outage tracking |
tags CONTAINS "iot" | Full sensor event log |