homelab-codex-ws/services/ha-diag-agent/tests/integration/scripts/wait-for-ha.sh
Oskar Kapala 07bd498fd6 feat(ha-diag-agent): test environment with dual HA Docker instances
- dockerized ken + chelsty HA test instances with template fixtures
- snapshot/reset/wait scripts for fixture management
- integration test infrastructure with separate marker
- location_tag promoted from metadata to event payload (Phase 1 flag #3)
- chelsty-infra target_url points to chelsty-ha via tailnet (Phase 1 flag #1)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 12:56:13 +02:00

24 lines
633 B
Bash
Executable file

#!/bin/sh
# Wait until a Home Assistant instance is ready (responds to /api/).
# Usage: wait-for-ha.sh <url> [timeout_seconds]
#
# Exit 0 = HA ready, Exit 1 = timeout reached.
URL="${1:-http://localhost:8123}"
TIMEOUT="${2:-120}"
elapsed=0
printf 'Waiting for HA at %s (timeout %ss)...\n' "$URL" "$TIMEOUT"
while [ "$elapsed" -lt "$TIMEOUT" ]; do
if curl -sf --max-time 3 "$URL/api/" -o /dev/null 2>/dev/null; then
printf 'HA ready at %s (after %ss)\n' "$URL" "$elapsed"
exit 0
fi
sleep 2
elapsed=$((elapsed + 2))
done
printf 'Timeout: HA not ready at %s after %ss\n' "$URL" "$TIMEOUT" >&2
exit 1