New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Reply To: Have a Pi in the lab read new Hermetry alarms out loud through a speaker

We do this on our plant floor, a Pi with a horn speaker reads critical alarms over the noise. Ciaran’s right, poll the Alarms API.

Ask your admin for an API key with only the alarm read permission (reading alarms is a User-level permission by default) and an IP allowlist for the uni’s address. Then:

import requests, subprocess, time
H = {"Authorization": f"Bearer {API_KEY}"}
URL = f"https://{HOST}/tenant/{TENANT}/api/iot/alarms"
seen = set()
while True:
    r = requests.get(URL, headers=H, params={"status": "OPEN", "severity": "CRITICAL,MAJOR",
                                             "sort": "opened:desc", "pageSize": 20}, timeout=10)
    for a in r.json()["items"]:
        if a["alarmId"] not in seen:
            seen.add(a["alarmId"])
            subprocess.run(["sh", "-c", f'echo "{a["deviceName"]}: {a["title"]}" | piper --model en_GB-alan-medium.onnx --output-raw | aplay -r 22050 -f S16_LE'])
    time.sleep(15)

Status OPEN means acknowledged alarms stop being read, which people like: ack it in the app and the room goes quiet. Give your alarm rules readable titles because that’s what gets spoken, e.g. “{{device.name}} temperature {{value}}”. Fifteen seconds is a polite poll rate, stay well under the API limits. If you ever do get a public endpoint, the alarm.created webhook would replace the polling: Webhooks.

Accepted solution♥ 2