#!/bin/bash # Validate the full doorbell chain WITHOUT flashing a real lamp: # ntfy.sh -> doorbell-listener -> MQTT -> fake zigbee device # Publishes a probe canary (tagged "doorbell-probe") to the ntfy test topic, # then waits for the fake device to echo a TOGGLE on its state topic. set -u NTFY_TOPIC="${NTFY_TOPIC:-ALERT_klubhaus_topic_test}" PROBE_STATE="${PROBE_STATE:-zigbee2mqtt/DoorbellProbe}" MQTT_HOST="${MQTT_HOST:-127.0.0.1}" TIMEOUT="${TIMEOUT:-25}" marker="e2e-$(date +%s)-$$" echo "publishing probe canary to ntfy.sh/$NTFY_TOPIC" curl -fsS -m 10 -o /dev/null -X POST "https://ntfy.sh/$NTFY_TOPIC" \ -H "Title: doorbell-probe" \ -H "Tags: doorbell-probe" \ -d "$marker" || { echo "E2E FAIL: ntfy publish failed"; exit 2; } echo "waiting for TOGGLE echo on $PROBE_STATE (<=${TIMEOUT}s)" if timeout "$TIMEOUT" docker exec mosquitto mosquitto_sub -h 127.0.0.1 -t "$PROBE_STATE" -C 1 -W "$TIMEOUT" 2>/dev/null | grep -q TOGGLE; then echo "E2E OK" exit 0 else echo "E2E FAIL: no TOGGLE echo on $PROBE_STATE within ${TIMEOUT}s" exit 1 fi